Skip to content

Commit bb1b2dd

Browse files
committed
improved on sourcery suggestion
1 parent b2d6595 commit bb1b2dd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

app/eventyay/plugins/sendmail/forms.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,16 @@ def clean_emails(self):
512512
if email.strip()
513513
]
514514

515-
if len(updated_emails) > len(self.recipient_objects):
515+
if len(updated_emails) == 0:
516516
raise ValidationError(
517-
_("You cannot add new recipients. Only editing existing email addresses is allowed.")
517+
_("At least one recipient must remain. You cannot remove all recipients.")
518518
)
519+
520+
if len(updated_emails) != len(self.recipient_objects):
521+
raise ValidationError(
522+
_("You cannot add new recipients or remove recipients. Only editing existing email addresses is allowed.")
523+
)
524+
519525
return updated_emails
520526

521527
def save(self, commit=True):

app/eventyay/plugins/sendmail/models.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ def _build_email_context(self, order, position, position_or_address, recipient):
139139
return None
140140

141141
def _finalize_send_status(self):
142-
if all(r.sent for r in self.recipients.all()):
143-
self.sent_at = now()
144-
else:
145-
self.sent_at = None
142+
self.sent_at = now() if all(r.sent for r in self.recipients.all()) else None
146143
self.save(update_fields=["sent_at"])
147144

148145
def _send_to_recipient(self, recipient, subject, message):

0 commit comments

Comments
 (0)