Skip to content

Commit

Permalink
Order revisions by date created
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylorhq committed Dec 31, 2019
1 parent 3b28eaf commit 9156545
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions RIGS/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,12 @@ def get_for_multiple_models(self, model_array):
for model in model_array:
content_types.append(ContentType.objects.get_for_model(model))

return self.filter(content_type__in=content_types).select_related("revision").order_by("-pk")
return self.filter(content_type__in=content_types).select_related("revision").order_by("-revision__date_created")


class RIGSVersion(Version):
class Meta:
proxy = True
ordering = ['-date_created']

objects = RIGSVersionManager.as_manager()

Expand Down Expand Up @@ -207,7 +206,7 @@ class VersionHistory(generic.ListView):
paginate_by = 25

def get_queryset(self, **kwargs):
return RIGSVersion.objects.get_for_object(self.get_object()).select_related("revision", "revision__user").all()
return RIGSVersion.objects.get_for_object(self.get_object()).select_related("revision", "revision__user").all().order_by("-revision__date_created")

def get_object(self, **kwargs):
return get_object_or_404(self.kwargs['model'], pk=self.kwargs['pk'])
Expand All @@ -226,7 +225,7 @@ class ActivityTable(generic.ListView):

def get_queryset(self):
versions = RIGSVersion.objects.get_for_multiple_models([models.Event, models.Venue, models.Person, models.Organisation, models.EventAuthorisation])
return versions
return versions.order_by("-revision__date_created")


class ActivityFeed(generic.ListView):
Expand All @@ -236,7 +235,7 @@ class ActivityFeed(generic.ListView):

def get_queryset(self):
versions = RIGSVersion.objects.get_for_multiple_models([models.Event, models.Venue, models.Person, models.Organisation, models.EventAuthorisation])
return versions
return versions.order_by("-revision__date_created")

def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
Expand Down

0 comments on commit 9156545

Please sign in to comment.