Skip to content

Commit

Permalink
1556 profile pages worked on (#1658)
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

* move all sorting to queryset - post black format
  • Loading branch information
jkueloc committed Mar 31, 2022
1 parent db3547c commit 7b8e33a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion concordia/templates/account/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h3>Pages worked on</h3>


<tr class={{asset.item.project.campaign.id}}>
<td><abbr title="{{ asset.last_interaction_time|date:'SHORT_DATE_FORMAT' }}">{{ asset.last_interaction_time }}</abbr></td>
<td><abbr title="{{ asset.latest_activity|date:'SHORT_DATE_FORMAT' }}">{{ asset.latest_activity }}</abbr></td>
<td><a href="{{ asset.item.get_absolute_url }}">{{ asset.item.title }}</a></td>
<td class="text-right"><a href="{{ asset.get_absolute_url }}">{{ asset.sequence }}</a></td>
<td>{{ asset.last_interaction_type.title }}</td>
Expand Down
13 changes: 6 additions & 7 deletions concordia/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from django.core.paginator import Paginator
from django.db import connection
from django.db.models import Case, Count, IntegerField, Max, OuterRef, Q, Subquery, When
from django.db.models.functions import Greatest
from django.db.transaction import atomic
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, render
Expand Down Expand Up @@ -501,11 +502,11 @@ def get_queryset(self):
assets = Asset.objects.filter(
transcription__in=transcriptions,
item__project__campaign__pk=campaignSlug,
).order_by("-latest_date", "-id")
).order_by("-latest_activity", "-id")
else:
campaignSlug = -1
assets = Asset.objects.filter(transcription__in=transcriptions).order_by(
"-latest_date", "-id"
"-latest_activity", "-id"
)

assets = assets.select_related(
Expand All @@ -521,8 +522,9 @@ def get_queryset(self):
"transcription__updated_on",
filter=Q(transcription__reviewed_by=self.request.user),
),
latest_date=Max(
"transcription__updated_on",
latest_activity=Greatest(
"last_transcribed",
"last_reviewed",
filter=Q(transcription__user=self.request.user)
| Q(transcription__reviewed_by=self.request.user),
),
Expand All @@ -544,10 +546,8 @@ def get_context_data(self, *args, **kwargs):
for asset in obj_list:

if asset.last_reviewed:
asset.last_interaction_time = asset.last_reviewed
asset.last_interaction_type = "reviewed"
else:
asset.last_interaction_time = asset.last_transcribed
asset.last_interaction_type = "transcribed"

if int(campaignSlug) == -1:
Expand All @@ -557,7 +557,6 @@ def get_context_data(self, *args, **kwargs):
object_list.append((asset))

user = self.request.user
object_list.sort(key=lambda x: x.last_interaction_time, reverse=True)

contributed_campaigns = (
Campaign.objects.annotate(
Expand Down

0 comments on commit 7b8e33a

Please sign in to comment.