Skip to content

Commit

Permalink
Merge pull request #582 from fragforce/dev
Browse files Browse the repository at this point in the history
Update prod
  • Loading branch information
AevumDecessus committed Apr 14, 2023
2 parents e691949 + 1ecd4d0 commit 75d299b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ffdonations/tasks/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def note_new_donation(self, donationID):
payload = {
'webauth': settings.FRAG_BOT_KEY,
'user': settings.FRAG_BOT_BOT,
'message': message,
'message': message.encode('utf-8'),
}
r = requests.put(settings.FRAG_BOT_API, headers=payload)
r.raise_for_status()
Expand Down
2 changes: 1 addition & 1 deletion ffsite/templates/ff/root/donate.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2>Donating to Fragforce via Extra-Life (US and Canada only)</h2>
<div>
<ul>
<li>Donate to a random Fragforce team member:
<a href="{{ rnd_pct.donate_link }}">{{ rnd_pct.name }}</a>
<a href="https://extra-life.org/participant/{{ rnd_pct.id }}">{{ rnd_pct.displayName }}</a>
</li>
<li>
Alternatively, instead of donating to someone else, you can Join the team and raise money
Expand Down
22 changes: 10 additions & 12 deletions ffsite/utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
from ffsfdc.models import *
from random import randint

from django.db.models import Q, Max, Min

from ffsfdc.models import *
from random import choice

from ffdonations.models import ParticipantModel
from ffdonations.utils import el_teams

def random_contact():
""" Returns a randomly selected Contact """
# Limit all queries to these
baseQ = Q(extra_life_id__isnull=False)
info = Contact.objects.filter(baseQ).all().aggregate(Min('id'), Max('id'))
pk = randint(info['id__min'], info['id__max'])
r = Contact.objects.filter(baseQ).filter(pk=pk).first()
if r:
return r
participants = ParticipantModel.objects.filter(team__id__in=el_teams())
if len(participants) > 0:
pk = choice(participants)
else:
pk = ParticipantModel()
if pk:
return pk
else:
# Retry if the contact doesn't exist
return random_contact()

0 comments on commit 75d299b

Please sign in to comment.