Skip to content

Add default/fallback behavior for subscription category with 'Cannot unsubscribe' checked #90

@cjg89

Description

@cjg89

Currently, if you create a subscription category with the 'Cannot unsubscribe' checkbox checked, but no 'Applies to' value, the front-facing recipient subscriptions view will throw an error due to attempting to match the user's email address against an invalid regex pattern. This also occurs if 'Applies to' is set to *.

{% if category|can_unsubscribe:recipient.email_address %}

@register.filter
def can_unsubscribe(category, email_address):
if category.cannot_unsubscribe and category.applies_to_email(email_address):
return False
return True

https://github.com/UCF/PostMaster/blob/master/manager/models.py#L164-L168

It would be nice if the 'Applies to' value could be empty or * and prevent unsubscribes for all email addresses. Alternatively, if that's not desirable, we could show/hide the 'Applies to' field with some basic js logic depending on if 'Cannot unsubscribe' is checked, and/or add a field description that mentions the 'Applies to' field being required and that a wildcard * is not supported.

Metadata

Metadata

Labels

bugA problem with existing functionalityenhancementNew features or functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions