Repository: DDMAL/CantusDB

Issue:
"My sources" page and sidebar should be ordered by date updated
How are sources supposed to show up in "My sources"? I am an editor for some sources but they don't seem to be in "my sources", so what determines this?



Discussion:
It looks like the logic is that it includes sources that were either (a) created by you or (b) for which you are listed as a "current editor".

Could you give me an example of such a source, and then I can look at which "role" you have with the source that isn't one of these two?
wait, I found the sources I thought I was lacking after all--weirdly, buried in different places in my (very long) list of sources, even though I thought I was added to both as an editor at the same time pretty recently (so I was expecting them together and near the surface.)  So the logic is sound, it's actually a question of the order things are presented to the user (probably the most recently modified should be at the top?)
There is also the "Sources created by user" sidebar. To me it makes more sense to keep it ordered by date created instead of date updated, but we can easily change that as well.
> There is also the "Sources created by user" sidebar. To me it makes more sense to keep it ordered by date created instead of date updated, but we can easily change that as well.

Ok, in testing on staging it looks like #1472 changed the ordering of the "Sources created by user" sidebar, but not the main source list on the "My Source" page.
See https://github.com/DDMAL/CantusDB/pull/1500.

The sidebar on the My Sources page should be changed back to ordering by date created and the list in the table should be ordered by date updated

Resolving patch:
diff --git a/django/cantusdb_project/main_app/views/user.py b/django/cantusdb_project/main_app/views/user.py
--- a/django/cantusdb_project/main_app/views/user.py
+++ b/django/cantusdb_project/main_app/views/user.py
@@ -94,7 +94,7 @@ def get_context_data(self, **kwargs):
                 # | Q(proofreaders=self.request.user)
                 # | Q(other_editors=self.request.user)
             )
-            .order_by("-date_created")
+            .order_by("-date_updated")
             .distinct()
         )
 
@@ -104,7 +104,7 @@ def get_context_data(self, **kwargs):
 
         user_created_sources = (
             Source.objects.filter(created_by=self.request.user)
-            .order_by("-date_updated")
+            .order_by("-date_created")
             .distinct()
         )
         user_created_paginator = Paginator(user_created_sources, 6)


Test patch:
diff --git a/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py b/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py
--- a/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py
+++ b/django/cantusdb_project/main_app/tests/test_assign_chants_to_segments.py
@@ -34,4 +34,4 @@ def test_assign_chants_to_segments(self):
         for chant in source_2_chants:
             self.assertEqual(chant.segment_id, segment_2.id)
         for sequence in sequence_source_sequences:
-            self.assertEqual(sequence.segment_id, segment_2.id)
\ No newline at end of file
+            self.assertEqual(sequence.segment_id, segment_2.id)