Refactor NotificationTemplate to Notifier

This commit is contained in:
Matthew Jones
2016-02-17 15:18:18 +00:00
parent 9d6739045a
commit dde70dafec
15 changed files with 145 additions and 141 deletions

View File

@@ -21,7 +21,7 @@ from django.utils.timezone import now, make_aware, get_default_timezone
from awx.lib.compat import slugify
from awx.main.models.base import * # noqa
from awx.main.models.jobs import Job
from awx.main.models.notifications import NotificationTemplate
from awx.main.models.notifications import Notifier
from awx.main.models.unified_jobs import * # noqa
from awx.main.utils import update_scm_url
@@ -316,16 +316,16 @@ class Project(UnifiedJobTemplate, ProjectOptions):
# Return all notifiers defined on the Project, and on the Organization for each trigger type
# TODO: Currently there is no org fk on project so this will need to be added back once that is
# available after the rbac pr
base_notifiers = NotificationTemplate.objects.filter(active=True)
base_notifiers = Notifier.objects.filter(active=True)
# error_notifiers = list(base_notifiers.filter(Q(project_notifications_for_errors__in=self) |
# Q(organization_notifications_for_errors__in=self.organization)))
# success_notifiers = list(base_notifiers.filter(Q(project_notifications_for_success__in=self) |
# Q(organization_notifications_for_success__in=self.organization)))
# any_notifiers = list(base_notifiers.filter(Q(project_notifications_for_any__in=self) |
# Q(organization_notifications_for_any__in=self.organization)))
error_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifications_for_errors=self))
success_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifications_for_success=self))
any_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifications_for_any=self))
error_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifiers_for_errors=self))
success_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifiers_for_success=self))
any_notifiers = list(base_notifiers.filter(unifiedjobtemplate_notifiers_for_any=self))
return dict(error=error_notifiers, success=success_notifiers, any=any_notifiers)
def get_absolute_url(self):