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

Feature/ogc 1896 mark invalid email addresses #1735

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/onegov/directory/collections/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
return self.query().filter(EntryRecipient.id == id).first()
return None

def by_address(
self,
address: str,
) -> EntryRecipient | None:

query = self.query()
query = query.filter(EntryRecipient.address == address)

Check warning on line 98 in src/onegov/directory/collections/directory.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/directory/collections/directory.py#L97-L98

Added lines #L97 - L98 were not covered by tests

return query.first()

Check warning on line 100 in src/onegov/directory/collections/directory.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/directory/collections/directory.py#L100

Added line #L100 was not covered by tests

def add(
self,
address: str,
Expand Down
24 changes: 23 additions & 1 deletion src/onegov/directory/models/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
return DirectoryEntryForm


class EntryRecipient(Base, TimestampMixin):
class EntryRecipient(Base, TimestampMixin, ContentMixin):
""" Represents a single recipient.
"""

Expand Down Expand Up @@ -628,6 +628,28 @@
nullable=False
)

@property
def is_inactive(self) -> bool:
"""
Checks if the directory entry recipient's email address is marked as
inactive.

Returns:
bool: True if the email address is marked as inactive, False
otherwise.
"""
return self.meta.get('inactive', False)

def mark_inactive(self) -> None:
"""
Marks the recipient's email address as inactive.

This method sets the 'inactive' flag in the recipient's metadata to
True. It is typically used when a bounce event causes the email
address to be deactivated by Postmark.
"""
self.meta['inactive'] = True

Check warning on line 651 in src/onegov/directory/models/directory.py

View check run for this annotation

Codecov / codecov/patch

src/onegov/directory/models/directory.py#L651

Added line #L651 was not covered by tests


class EntrySubscription:
""" Adds subscription management to a recipient. """
Expand Down
3 changes: 3 additions & 0 deletions src/onegov/town6/templates/directory_entry_recipients.pt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
i18n:attributes="data-confirm-extra;data-confirm-yes;data-confirm-no">
unsubscribe
</a>
<span tal:condition="recipient.is_inactive|nothing" class="small-text info-text" title="This recipient has delivery failures, including hard bounces, invalid email addresses, spam complaints, manual deactivations, or being blocked. We recommend unsubscribing it from the list." i18n:attributes="title">
<i class="fa fa-exclamation-triangle"></i>
</span>
</li>
</ul>
</tal:b>
Expand Down
Loading