-
Notifications
You must be signed in to change notification settings - Fork 47
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
Refactored mail.py reduce code duplication #340
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more. @@ Coverage Diff @@
## next #340 +/- ##
==========================================
- Coverage 80.66% 80.59% -0.08%
==========================================
Files 32 32
Lines 2819 2808 -11
Branches 217 217
==========================================
- Hits 2274 2263 -11
Misses 510 510
Partials 35 35
|
context.update({'mobilepay_comment': escape(mobilepay_comment)}) | ||
|
||
target_template = "deposit_manual.html" if mobilepay_comment else "deposit_automatic.html" | ||
msg['Subject'] = subject | ||
html = render_to_string(f"mail/{target_template}", context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically related to your refactoring but it might be problematic that we don't statically check the existence of our templates. We only have three at the moment, so it's trivial.
I imagine a try-catch on loading template from disk. On error, staff should be notified in some way (mail as logs are read at most twice a decade).
Make an issue/PR if you feel this is interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I've reduced code duplication in mail.py.
Draft for now, as I'll need to see if I can improve it further(Should also fix #187 )