Merge pull request #4094 from jangsutsr/4078_hookup_activity_stream_with_workflow

Hook up activity stream with workflow
This commit is contained in:
Aaron Tan 2016-11-22 10:29:27 -05:00 committed by GitHub
commit 16c0bc29a5
4 changed files with 48 additions and 4 deletions

View File

@ -2217,6 +2217,7 @@ class WorkflowJobTemplateSerializer(LabelsListMixin, UnifiedJobTemplateSerialize
launch = reverse('api:workflow_job_template_launch', args=(obj.pk,)),
workflow_nodes = reverse('api:workflow_job_template_workflow_nodes_list', args=(obj.pk,)),
labels = reverse('api:workflow_job_template_label_list', args=(obj.pk,)),
activity_stream = reverse('api:workflow_job_template_activity_stream_list', args=(obj.pk,)),
notification_templates_any = reverse('api:workflow_job_template_notification_templates_any_list', args=(obj.pk,)),
notification_templates_success = reverse('api:workflow_job_template_notification_templates_success_list', args=(obj.pk,)),
notification_templates_error = reverse('api:workflow_job_template_notification_templates_error_list', args=(obj.pk,)),
@ -2249,6 +2250,7 @@ class WorkflowJobSerializer(LabelsListMixin, UnifiedJobSerializer):
res['notifications'] = reverse('api:workflow_job_notifications_list', args=(obj.pk,))
res['workflow_nodes'] = reverse('api:workflow_job_workflow_nodes_list', args=(obj.pk,))
res['labels'] = reverse('api:workflow_job_label_list', args=(obj.pk,))
res['activity_stream'] = reverse('api:workflow_job_activity_stream_list', args=(obj.pk,))
if obj.can_cancel or True:
res['cancel'] = reverse('api:workflow_job_cancel', args=(obj.pk,))
return res

View File

@ -265,6 +265,7 @@ workflow_job_template_urls = patterns('awx.api.views',
url(r'^(?P<pk>[0-9]+)/schedules/$', 'workflow_job_template_schedules_list'),
url(r'^(?P<pk>[0-9]+)/survey_spec/$', 'workflow_job_template_survey_spec'),
url(r'^(?P<pk>[0-9]+)/workflow_nodes/$', 'workflow_job_template_workflow_nodes_list'),
url(r'^(?P<pk>[0-9]+)/activity_stream/$', 'workflow_job_template_activity_stream_list'),
url(r'^(?P<pk>[0-9]+)/notification_templates_any/$', 'workflow_job_template_notification_templates_any_list'),
url(r'^(?P<pk>[0-9]+)/notification_templates_error/$', 'workflow_job_template_notification_templates_error_list'),
url(r'^(?P<pk>[0-9]+)/notification_templates_success/$', 'workflow_job_template_notification_templates_success_list'),
@ -280,6 +281,7 @@ workflow_job_urls = patterns('awx.api.views',
url(r'^(?P<pk>[0-9]+)/labels/$', 'workflow_job_label_list'),
url(r'^(?P<pk>[0-9]+)/cancel/$', 'workflow_job_cancel'),
url(r'^(?P<pk>[0-9]+)/notifications/$', 'workflow_job_notifications_list'),
url(r'^(?P<pk>[0-9]+)/activity_stream/$', 'workflow_job_activity_stream_list'),
)

View File

@ -3026,6 +3026,32 @@ class WorkflowJobTemplateNotificationTemplatesSuccessList(SubListCreateAttachDet
new_in_310 = True
class WorkflowJobTemplateAccessList(ResourceAccessList):
model = User # needs to be User for AccessLists's
resource_model = WorkflowJobTemplate
new_in_310 = True
class WorkflowJobTemplateActivityStreamList(SubListAPIView):
model = ActivityStream
serializer_class = ActivityStreamSerializer
parent_model = WorkflowJobTemplate
relationship = 'activitystream_set'
new_in_310 = True
def get(self, request, *args, **kwargs):
# Sanity check: Does this license allow activity streams?
# If not, forbid this request.
if not feature_enabled('activity_streams'):
raise LicenseForbids(_('Your license does not allow use of '
'the activity stream.'))
# Okay, let it through.
return super(WorkflowJobTemplateActivityStreamList, self).get(request, *args, **kwargs)
# TODO:
class WorkflowJobList(ListCreateAPIView):
@ -3080,11 +3106,23 @@ class WorkflowJobNotificationsList(SubListAPIView):
new_in_310 = True
class WorkflowJobTemplateAccessList(ResourceAccessList):
class WorkflowJobActivityStreamList(SubListAPIView):
model = User # needs to be User for AccessLists's
resource_model = WorkflowJobTemplate
new_in_310 = True
model = ActivityStream
serializer_class = ActivityStreamSerializer
parent_model = WorkflowJob
relationship = 'activitystream_set'
new_in_310 = True
def get(self, request, *args, **kwargs):
# Sanity check: Does this license allow activity streams?
# If not, forbid this request.
if not feature_enabled('activity_streams'):
raise LicenseForbids(_('Your license does not allow use of '
'the activity stream.'))
# Okay, let it through.
return super(WorkflowJobActivityStreamList, self).get(request, *args, **kwargs)
class SystemJobTemplateList(ListAPIView):

View File

@ -115,3 +115,5 @@ activity_stream_registrar.connect(NotificationTemplate)
activity_stream_registrar.connect(Notification)
activity_stream_registrar.connect(Label)
activity_stream_registrar.connect(User)
activity_stream_registrar.connect(WorkflowJobTemplate)
activity_stream_registrar.connect(WorkflowJob)