Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samsagaz committed Mar 29, 2020
1 parent 565f6be commit c38d13b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions website/events/helpers/sponsoring_pending.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* calculate_all_sponsoring_pending
"""
from collections import namedtuple
from operator import attrgetter

from django.urls import reverse
from events.constants import SPONSOR_STATE_CHECKED, SPONSOR_STATE_PARTIALLY_PAID
Expand Down Expand Up @@ -37,9 +38,12 @@ def calculate_sponsoring_pending(organizer_user=False):
else:
sponsorings = Sponsoring.objects.all()

open_sponsorings = (
SPONSOR_STATE_PARTIALLY_PAID,
SPONSOR_STATE_CHECKED,
)

for sponsoring in sponsorings:
if sponsoring.state == SPONSOR_STATE_PARTIALLY_PAID or \
sponsoring.state == SPONSOR_STATE_CHECKED:
if sponsoring.state in open_sponsorings:
pending.append(pending_sponsoring(sponsoring))
pending.sort(key=lambda x: x.amount, reverse=True)
return pending
return sorted(pending, key=attrgetter('amount'), reverse=True)

0 comments on commit c38d13b

Please sign in to comment.