Skip to content

Commit

Permalink
1556 profile pages worked on (#1657)
Browse files Browse the repository at this point in the history
* restore profile html filter on campaign

* added class row to pagination div for consistency

* black formatting update

* updated profile qs sort and pagination

* updated profile qs sort and pagination
  • Loading branch information
jkueloc committed Mar 31, 2022
1 parent 84528ac commit db3547c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions concordia/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,10 @@ class AccountProfileView(LoginRequiredMixin, FormView, ListView):
# presented in the template as a standard paginated list of Asset
# instances with annotations
allow_empty = True
paginate_by = 30
paginate_by = 12

def post(self, *args, **kwargs):
self.object_list = self.get_queryset()
self.object_list.sort(key=lambda x: x.last_interaction_time, reverse=True)
return super().post(*args, **kwargs)

def get_queryset(self):
Expand All @@ -502,16 +501,17 @@ def get_queryset(self):
assets = Asset.objects.filter(
transcription__in=transcriptions,
item__project__campaign__pk=campaignSlug,
).order_by("-last_transcribed")
).order_by("-latest_date", "-id")
else:
campaignSlug = -1
assets = Asset.objects.filter(transcription__in=transcriptions).order_by(
"-last_transcribed"
"-latest_date", "-id"
)

assets = assets.select_related(
"item", "item__project", "item__project__campaign"
)

assets = assets.annotate(
last_transcribed=Max(
"transcription__created_on",
Expand All @@ -521,6 +521,11 @@ def get_queryset(self):
"transcription__updated_on",
filter=Q(transcription__reviewed_by=self.request.user),
),
latest_date=Max(
"transcription__updated_on",
filter=Q(transcription__user=self.request.user)
| Q(transcription__reviewed_by=self.request.user),
),
)
return assets

Expand Down

0 comments on commit db3547c

Please sign in to comment.