Repository: DDMAL/CantusDB

Issue:
Hide certain fields in admin area
Several of our models' fields are designed to improve database operation, or to preserve an archive of past information, and should not be edited by users. These fields include `json_info` (present in several models - i.e. the response from OldCantus from when we last synced the data), `next_chant` (Chant, Sequence), `is_last_chant_in_feast` (Chant, Sequence) `number_of_chants` and `number_of_melodies` (Source); there may be others.

We can `exclude` these fields in our Admin configuration - this shouldn't be too hard to fix.
Hide certain fields in admin area
Several of our models' fields are designed to improve database operation, or to preserve an archive of past information, and should not be edited by users. These fields include `json_info` (present in several models - i.e. the response from OldCantus from when we last synced the data), `next_chant` (Chant, Sequence), `is_last_chant_in_feast` (Chant, Sequence) `number_of_chants` and `number_of_melodies` (Source); there may be others.

We can `exclude` these fields in our Admin configuration - this shouldn't be too hard to fix.


Discussion:
Further, since `Chant` and `Sequence` both inherit from `BaseChant`, there are certain fields that are only relevant to Sequences and not to Chants (e.g. `s_sequence`, `col_1`, etc.) and vice versa (e.g. `c_sequence`). These fields should be hidden on those pages as well.

We should also add help text (in the model definition) to `c_sequence` and `s_sequence`, explaining why these fields are now called this, and why they're no longer just called `sequence` as they were in OldCantus. Alternately, we can create a custom form in the admin area, in order to label these fields "Sequence", rather than "C sequence" or "S sequence" as we currently do.

All this for the benefit of Debra and other administrators, who don't really need to know what's going on under the hood with how we represent Chants and Sequences in the database.
Further, since `Chant` and `Sequence` both inherit from `BaseChant`, there are certain fields that are only relevant to Sequences and not to Chants (e.g. `s_sequence`, `col_1`, etc.) and vice versa (e.g. `c_sequence`). These fields should be hidden on those pages as well.

We should also add help text (in the model definition) to `c_sequence` and `s_sequence`, explaining why these fields are now called this, and why they're no longer just called `sequence` as they were in OldCantus. Alternately, we can create a custom form in the admin area, in order to label these fields "Sequence", rather than "C sequence" or "S sequence" as we currently do.

All this for the benefit of Debra and other administrators, who don't really need to know what's going on under the hood with how we represent Chants and Sequences in the database.

Resolving patch:
diff --git a/django/cantusdb_project/main_app/admin.py b/django/cantusdb_project/main_app/admin.py
--- a/django/cantusdb_project/main_app/admin.py
+++ b/django/cantusdb_project/main_app/admin.py
@@ -1,12 +1,11 @@
 from django.contrib import admin
 from main_app.models import *
 
-# Register your models here.
-
+# these fields should not be editable by all classes
+EXCLUDE = ("created_by", "last_updated_by", "json_info")
 
 class BaseModelAdmin(admin.ModelAdmin):
-    # these fields should not be editable
-    exclude = ("created_by", "last_updated_by")
+    exclude = EXCLUDE
 
     # if an object is created in the admin interface, assign the user to the created_by field
     # else if an object is updated in the admin interface, assign the user to the last_updated_by field
@@ -23,8 +22,7 @@ class CenturyAdmin(BaseModelAdmin):
 
 
 class ChantAdmin(BaseModelAdmin):
-    pass
-
+    exclude = EXCLUDE + ("col1", "col2", "col3", "next_chant", "s_sequence", "is_last_chant_in_feast")
 
 class FeastAdmin(BaseModelAdmin):
     pass
@@ -55,8 +53,7 @@ class SegmentAdmin(BaseModelAdmin):
 
 
 class SequenceAdmin(BaseModelAdmin):
-    pass
-
+    exclude = EXCLUDE + ("c_sequence", "next_chant", "is_last_chant_in_feast")
 
 class SourceAdmin(BaseModelAdmin):
     # from the Django docs:
diff --git a/django/cantusdb_project/main_app/models/base_chant.py b/django/cantusdb_project/main_app/models/base_chant.py
--- a/django/cantusdb_project/main_app/models/base_chant.py
+++ b/django/cantusdb_project/main_app/models/base_chant.py
@@ -30,9 +30,9 @@ class Meta:
     )
     # The "s_sequence" char field, used for Sequences, is used to indicate the relative positions of sequences on the page.
     # It sometimes features non-numeric characters and leading zeroes, so it's a CharField.
-    s_sequence = models.CharField(blank=True, null=True, max_length=255)
+    s_sequence = models.CharField("Sequence", blank=True, null=True, max_length=255)
     # The "c_sequence" integer field, used for Chants, similarly indicates the relative positions of chants on the page
-    c_sequence = models.PositiveIntegerField(
+    c_sequence = models.PositiveIntegerField("Sequence",
         help_text='Each folio starts with "1"', null=True, blank=True
     )
     genre = models.ForeignKey("Genre", blank=True, null=True, on_delete=models.PROTECT)


Test patch: