Skip to content

Commit

Permalink
Merge pull request #7857 from zoek1/chore/move-grant-mail-celery
Browse files Browse the repository at this point in the history
chore: move grant creation mail to celery #7747
  • Loading branch information
octavioamu authored Nov 11, 2020
2 parents 216a348 + 1affe60 commit da078c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 9 additions & 1 deletion app/grants/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from celery.utils.log import get_task_logger
from dashboard.models import Profile
from grants.models import Grant, Subscription
from marketing.mails import new_supporter, thank_you_for_supporting
from marketing.mails import new_supporter, thank_you_for_supporting, new_grant_admin, new_grant
from townsquare.models import Comment

logger = get_task_logger(__name__)
Expand Down Expand Up @@ -205,3 +205,11 @@ def recalc_clr(self, grant_id, retry: bool = True) -> None:
network=network,
only_grant_pk=obj.pk
)

@app.shared_task(bind=True, max_retries=3)
def process_grant_creation_email(self, grant_id, profile_id):
grant = Grant.objects.get(pk=grant_id)
profile = Profile.objects.get(pk=profile_id)

new_grant_admin(grant)
new_grant(grant, profile)
6 changes: 2 additions & 4 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
CartActivity, Contribution, Flag, Grant, GrantCategory, GrantCLR, GrantCollection, GrantType, MatchPledge,
PhantomFunding, Subscription,
)
from grants.tasks import update_grant_metadata
from grants.tasks import update_grant_metadata, process_grant_creation_email
from grants.utils import emoji_codes, get_leaderboard, get_user_code, is_grant_team_member, sync_payout
from inbox.utils import send_notification_to_user_from_gitcoinbot
from kudos.models import BulkTransferCoupon, Token
Expand Down Expand Up @@ -1529,9 +1529,7 @@ def grant_new(request):
'grant_type': GrantType.objects.get(name=grant_type),
}


grant = Grant.objects.create(**grant_kwargs)
new_grant_admin(grant)

team_members = (team_members[0].split(','))
team_members.append(profile.id)
Expand Down Expand Up @@ -1560,7 +1558,7 @@ def grant_new(request):
)

record_grant_activity_helper('new_grant', grant, profile)
new_grant(grant, profile)
process_grant_creation_email.delay(grant.pk, profile.pk)

response = {
'status': 200,
Expand Down

0 comments on commit da078c8

Please sign in to comment.