Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move grant creation mail to celery #7747 #7857

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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