kopia lustrzana https://github.com/wagtail/wagtail
Fix `get_valid_recipients` and `get_recipient_users` returning None
rodzic
cae85c7dc5
commit
a97403c465
|
@ -228,7 +228,8 @@ class EmailNotificationMixin:
|
||||||
return {
|
return {
|
||||||
recipient
|
recipient
|
||||||
for recipient in self.get_recipient_users(instance, **kwargs)
|
for recipient in self.get_recipient_users(instance, **kwargs)
|
||||||
if recipient.is_active
|
if recipient
|
||||||
|
and recipient.is_active
|
||||||
and recipient.email
|
and recipient.email
|
||||||
and getattr(
|
and getattr(
|
||||||
UserProfile.get_for_user(recipient),
|
UserProfile.get_for_user(recipient),
|
||||||
|
@ -312,7 +313,7 @@ class BaseWorkflowStateEmailNotifier(EmailNotificationMixin, Notifier):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__((WorkflowState,))
|
super().__init__((WorkflowState,))
|
||||||
|
|
||||||
def get_context(self, workflow_state, **kwargs):
|
def get_context(self, workflow_state: WorkflowState, **kwargs):
|
||||||
context = super().get_context(workflow_state, **kwargs)
|
context = super().get_context(workflow_state, **kwargs)
|
||||||
context["workflow"] = workflow_state.workflow
|
context["workflow"] = workflow_state.workflow
|
||||||
context["object"] = workflow_state.content_object
|
context["object"] = workflow_state.content_object
|
||||||
|
@ -327,11 +328,11 @@ class WorkflowStateApprovalEmailNotifier(BaseWorkflowStateEmailNotifier):
|
||||||
|
|
||||||
notification = "approved"
|
notification = "approved"
|
||||||
|
|
||||||
def get_recipient_users(self, workflow_state, **kwargs):
|
def get_recipient_users(self, workflow_state: WorkflowState, **kwargs):
|
||||||
triggering_user = kwargs.get("user", None)
|
triggering_user = kwargs.get("user", None)
|
||||||
recipients = set()
|
recipients = set()
|
||||||
requested_by = workflow_state.requested_by
|
requested_by = workflow_state.requested_by
|
||||||
if requested_by != triggering_user:
|
if requested_by is not None and requested_by != triggering_user:
|
||||||
recipients = {requested_by}
|
recipients = {requested_by}
|
||||||
|
|
||||||
return recipients
|
return recipients
|
||||||
|
@ -342,11 +343,11 @@ class WorkflowStateRejectionEmailNotifier(BaseWorkflowStateEmailNotifier):
|
||||||
|
|
||||||
notification = "rejected"
|
notification = "rejected"
|
||||||
|
|
||||||
def get_recipient_users(self, workflow_state, **kwargs):
|
def get_recipient_users(self, workflow_state: WorkflowState, **kwargs):
|
||||||
triggering_user = kwargs.get("user", None)
|
triggering_user = kwargs.get("user", None)
|
||||||
recipients = set()
|
recipients = set()
|
||||||
requested_by = workflow_state.requested_by
|
requested_by = workflow_state.requested_by
|
||||||
if requested_by != triggering_user:
|
if requested_by is not None and requested_by != triggering_user:
|
||||||
recipients = {requested_by}
|
recipients = {requested_by}
|
||||||
|
|
||||||
return recipients
|
return recipients
|
||||||
|
@ -365,7 +366,7 @@ class WorkflowStateSubmissionEmailNotifier(BaseWorkflowStateEmailNotifier):
|
||||||
|
|
||||||
notification = "submitted"
|
notification = "submitted"
|
||||||
|
|
||||||
def get_recipient_users(self, workflow_state, **kwargs):
|
def get_recipient_users(self, workflow_state: WorkflowState, **kwargs):
|
||||||
triggering_user = kwargs.get("user", None)
|
triggering_user = kwargs.get("user", None)
|
||||||
recipients = get_user_model().objects.none()
|
recipients = get_user_model().objects.none()
|
||||||
include_superusers = getattr(
|
include_superusers = getattr(
|
||||||
|
@ -406,7 +407,7 @@ class BaseGroupApprovalTaskStateEmailNotifier(EmailNotificationMixin, Notifier):
|
||||||
context["page"] = context["object"].specific
|
context["page"] = context["object"].specific
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_recipient_users(self, task_state, **kwargs):
|
def get_recipient_users(self, task_state: TaskState, **kwargs):
|
||||||
triggering_user = kwargs.get("user", None)
|
triggering_user = kwargs.get("user", None)
|
||||||
|
|
||||||
group_members = get_user_model().objects.filter(
|
group_members = get_user_model().objects.filter(
|
||||||
|
|
Ładowanie…
Reference in New Issue