Skip to content

Commit

Permalink
use sponsor_profiles instead of sponsors (#7589)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiantf authored Oct 4, 2020
1 parent ad0045d commit 143649f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -2018,20 +2018,22 @@ def tribe_hackathon_prizes(hackathon):
from dashboard.models import TribeMember, Sponsor
from marketing.utils import generate_hackathon_email_intro

sponsors = hackathon.sponsors.all()
tribe_members_in_sponsors = TribeMember.objects.filter(org__in=[sponsor.tribe for sponsor in sponsors]).exclude(status='rejected').exclude(profile__user=None).only('profile')
sponsors = hackathon.sponsor_profiles.all()
tribe_members_in_sponsors = TribeMember.objects.filter(org__in=[sponsor for sponsor in sponsors]).exclude(status='rejected').exclude(profile__user=None).only('profile')

for tribe_member in tribe_members_in_sponsors.distinct('profile'):
# Get all records of this tribe_member for each sponsor he is a member of
tribe_member_records = tribe_members_in_sponsors.filter(profile=tribe_member.profile)

sponsors_prizes = []
for sponsor in sponsors.filter(tribe__in=[tribe_member_record.org for tribe_member_record in tribe_member_records]):
prizes = hackathon.get_current_bounties.filter(bounty_owner_profile=sponsor.tribe)
sponsor_prize = {
"sponsor": sponsor,
"prizes": prizes
}
sponsors_prizes.append(sponsor_prize)
for sponsor in sponsors:
if sponsor in [tribe_member_record.org for tribe_member_record in tribe_member_records]:
prizes = hackathon.get_current_bounties.filter(bounty_owner_profile=sponsor)
sponsor_prize = {
"sponsor": sponsor,
"prizes": prizes
}
sponsors_prizes.append(sponsor_prize)

subject_begin = generate_hackathon_email_intro(sponsors_prizes)
subject = f"{subject_begin} participating in {hackathon.name} on Gitcoin 🚀"
Expand Down
4 changes: 2 additions & 2 deletions app/retail/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,8 +1712,8 @@ def tribe_hackathon_prizes(request):
hackathon = HackathonEvent.objects.filter(start_date__date=(timezone.now()+timezone.timedelta(days=3))).first()

sponsors_prizes = []
for sponsor in hackathon.sponsors.all()[:3]:
prizes = hackathon.get_current_bounties.filter(bounty_owner_profile=sponsor.tribe)
for sponsor in hackathon.sponsor_profiles.all()[:3]:
prizes = hackathon.get_current_bounties.filter(bounty_owner_profile=sponsor)
sponsor_prize = {
"sponsor": sponsor,
"prizes": prizes
Expand Down

0 comments on commit 143649f

Please sign in to comment.