Skip to content

[Fix #4675] Implement feature to send paid plan details to challenge hosts when requested for approval#4701

Merged
RishabhJain2018 merged 28 commits intoCloud-CV:masterfrom
Zahed-Riyaz:email-plan
Jul 31, 2025
Merged

[Fix #4675] Implement feature to send paid plan details to challenge hosts when requested for approval#4701
RishabhJain2018 merged 28 commits intoCloud-CV:masterfrom
Zahed-Riyaz:email-plan

Conversation

@Zahed-Riyaz
Copy link
Copy Markdown
Contributor

@Zahed-Riyaz Zahed-Riyaz commented Jun 24, 2025

This PR is a fix for #4675. It implements the following :

  1. New email-dispatch utility
    challenges/utils.py now contains send_subscription_plans_email(challenge) and helper send_emails(...).
    • Generates a personalised “subscription plans” message for every host of a challenge, supports plain-text+HTML (via EmailMultiAlternatives) and graceful error / logging paths.
    • Falls back to sensible defaults if optional settings (e.g. hostname, support address) are missing.

  2. HTML placeholder template for the paid plans email.

  3. Approval workflow extended
    apps/challenges/views.request_challenge_approval_by_pk
    – on success, calls send_subscription_plans_email.

  4. Robust test-suite for the feature
    a. tests/unit/challenges/test_utils.py – 12 new cases covering:
    • successful sends, per-recipient delivery, HTML body attach, unicode titles, image/no-image paths, SMTP or template exceptions, etc.
    b. tests/unit/challenges/test_views.py – new API tests in ChallengeSendApprovalRequestTest validating that:
    • email fires only when submissions are complete & requester is a host,
    • failures are tolerated,
    • non-hosts can’t trigger it,

Here's a video showcasing the email with a dummy template : (temporarily removed phase submission conditions for the approval to get through, they were restored after.)

test_email.mp4

@Zahed-Riyaz Zahed-Riyaz changed the title [Fix #4675] [Fix #4675] Implement feature to send paid plan details to challenge hosts when requested for approval Jun 24, 2025
@Zahed-Riyaz Zahed-Riyaz marked this pull request as ready for review July 3, 2025 11:57
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.91%. Comparing base (96968d6) to head (8effb2d).
⚠️ Report is 1230 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4701      +/-   ##
==========================================
+ Coverage   72.93%   76.91%   +3.98%     
==========================================
  Files          83       21      -62     
  Lines        5368     3608    -1760     
==========================================
- Hits         3915     2775    -1140     
+ Misses       1453      833     -620     

see 75 files with indirect coverage changes
see 75 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cce5ad...8effb2d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@RishabhJain2018 RishabhJain2018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on the email plan email. Will send it to you soon!

Comment thread apps/challenges/utils.py Outdated
"challenge_id": challenge.pk,
"host_team_name": challenge.creator.team_name,
"support_email": getattr(
settings, "CLOUDCV_TEAM_EMAIL", "team@cloudcv.org"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change it to team@eval.ai

Comment thread apps/challenges/utils.py Outdated
subject=subject,
body="Please view this email in HTML format.", # Plain text fallback
from_email=getattr(
settings, "CLOUDCV_TEAM_EMAIL", "team@cloudcv.org"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above!

@gchhablani gchhablani self-requested a review July 11, 2025 23:50
@RishabhJain2018
Copy link
Copy Markdown
Member

Hey @Zahed-Riyaz , Please update the email template. Please check your DM.

@RishabhJain2018 RishabhJain2018 merged commit 76e39f8 into Cloud-CV:master Jul 31, 2025
3 checks passed
RishabhJain2018 pushed a commit that referenced this pull request Mar 2, 2026
…hosts when requested for approval (#4701)

* implement email logic

* Add templates + refine email logic

* Add tests for paid plans email feature

* Omit debugs

* Update utils.ppy

* implement email logic

* Add templates + refine email logic

* Add tests for paid plans email feature

* Omit debugs

* Update utils.ppy

* Refine tests

* Modify tests

* remove unnecessary imports

* Update docker-compose.yml

* Handle undefined variables

* Update test_views.py

* Update env variables and tests

* Update env variables and tests

* Update email

* fix isort checks

* Resolve Flake8 checks

* Update email template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants