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

Refactored mail.py reduce code duplication #340

Merged
merged 5 commits into from
Sep 3, 2023

Conversation

krestenlaust
Copy link
Member

@krestenlaust krestenlaust commented Aug 16, 2023

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 )

@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2023

Codecov Report

Merging #340 (79eb31c) into next (e9675ca) will decrease coverage by 0.08%.
The diff coverage is 50.00%.

❗ Current head 79eb31c differs from pull request most recent head c6ea1aa. Consider uploading reports for the commit c6ea1aa to get more accurate results

❗ 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              
Files Changed Coverage Δ
stregsystem/mail.py 77.77% <50.00%> (-6.44%) ⬇️

@krestenlaust krestenlaust marked this pull request as ready for review September 2, 2023 18:38
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)
Copy link
Member

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.

Copy link
Member

@falkecarlsen falkecarlsen left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@falkecarlsen falkecarlsen merged commit a9bb19d into f-klubben:next Sep 3, 2023
3 checks passed
@krestenlaust krestenlaust deleted the refactor-mail branch September 3, 2023 08:57
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.

Remove hardcoded mailserver & -address
3 participants