Skip to content

Commit

Permalink
#117 Show up to 4 older decklists if there are no recent ones for a g…
Browse files Browse the repository at this point in the history
…iven card
  • Loading branch information
Enhaloed committed Mar 27, 2023
1 parent 1dadfef commit cf6e2df
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cardDatabase/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ def view_card(request, card_id=None):
one_month_ago = datetime.datetime.now() - datetime.timedelta(days=30)
ctx['recent_decklists'] = DeckList.objects.filter(public=True, cards__card__in=([card] + list(card.other_sides)),
last_modified__gt=one_month_ago).distinct().order_by('-last_modified')
if not ctx['recent_decklists'].count():
# There are no recent ones, just grab the up to the 4 most recent ones instead
ctx['recent_decklists'] = DeckList.objects.filter(public=True, cards__card__in=([card] + list(card.other_sides))).distinct().order_by('-last_modified')[:4]

return render(request, 'cardDatabase/html/view_card.html', context=ctx)

Expand Down

0 comments on commit cf6e2df

Please sign in to comment.