Refactor mail sending and improve invoice/payment admin UX#34
Merged
Conversation
view_helpers: - Add EmailConnectionWrapper: wraps Django mail connection to enable unification of mail sending with create_invoices later. - Extract HTML mail generation as helper functions - Refactor send_invoice_mails() and send_reminder_mails() to use the wrapper; eliminate nested try/except in favor of bool checks - send_invoice_mails() now requires users_autolocked and rolls back autolocks on mail failure or connection error - Extract create_invoices() from InvoiceCreateView; tracks and reports auto-unlocks - send_reminder_mails() skips users with balance >= 0, reports skipped count - Set context["subject"] in all mail-sending paths and debug views views / forms: - PaymentForm: restrict user dropdown to self-paying users; block others on submit - InvoiceCreateView: pre-select user via ?user=<pk> query param (get_initial) UI: - Invoice creation: Show filter box for user names (kind of a hack) - User detail: "Create invoice" button (self-paying users only), payment reminder button (balance < 0 only), mail preview footer buttons - Payment detail: always show "Generate invoice for user" button - Invoice detail: mail preview footer button
…ionWrapper in standalone views Single connection for all mails per call; invoices only persist if mail succeeds. InvoiceResendView and PaymentReminderSendView now use EmailConnectionWrapper directly.
db07ac5 to
aea2c88
Compare
Owner
Author
|
I think I'll commit a sin here and merge this before independent review... Need to have this go live quickly. I let Claude "review" it and checked the potential issues, which IMO are fine:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
view_helpers:
views / forms:
UI: