mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Merge pull request #4251 from cchurch/workflows-license-feature
Add workflows as a licensed feature
This commit is contained in:
@@ -296,7 +296,7 @@ class ParentMixin(object):
|
|||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
|
|
||||||
|
|
||||||
class SubListAPIView(ListAPIView, ParentMixin):
|
class SubListAPIView(ParentMixin, ListAPIView):
|
||||||
# Base class for a read-only sublist view.
|
# Base class for a read-only sublist view.
|
||||||
|
|
||||||
# Subclasses should define at least:
|
# Subclasses should define at least:
|
||||||
@@ -501,7 +501,7 @@ class DeleteLastUnattachLabelMixin(object):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
class SubDetailAPIView(generics.RetrieveAPIView, GenericAPIView, ParentMixin):
|
class SubDetailAPIView(ParentMixin, generics.RetrieveAPIView, GenericAPIView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
291
awx/api/views.py
291
awx/api/views.py
@@ -88,6 +88,36 @@ def api_exception_handler(exc, context):
|
|||||||
return exception_handler(exc, context)
|
return exception_handler(exc, context)
|
||||||
|
|
||||||
|
|
||||||
|
class ActivityStreamEnforcementMixin(object):
|
||||||
|
'''
|
||||||
|
Mixin to check that license supports activity streams.
|
||||||
|
'''
|
||||||
|
def check_permissions(self, request):
|
||||||
|
if not feature_enabled('activity_streams'):
|
||||||
|
raise LicenseForbids(_('Your license does not allow use of the activity stream.'))
|
||||||
|
return super(ActivityStreamEnforcementMixin, self).check_permissions(request)
|
||||||
|
|
||||||
|
|
||||||
|
class SystemTrackingEnforcementMixin(object):
|
||||||
|
'''
|
||||||
|
Mixin to check that license supports system tracking.
|
||||||
|
'''
|
||||||
|
def check_permissions(self, request):
|
||||||
|
if not feature_enabled('system_tracking'):
|
||||||
|
raise LicenseForbids(_('Your license does not permit use of system tracking.'))
|
||||||
|
return super(SystemTrackingEnforcementMixin, self).check_permissions(request)
|
||||||
|
|
||||||
|
|
||||||
|
class WorkflowsEnforcementMixin(object):
|
||||||
|
'''
|
||||||
|
Mixin to check that license supports workflows.
|
||||||
|
'''
|
||||||
|
def check_permissions(self, request):
|
||||||
|
if not feature_enabled('workflows'):
|
||||||
|
raise LicenseForbids(_('Your license does not allow use of workflows.'))
|
||||||
|
return super(WorkflowsEnforcementMixin, self).check_permissions(request)
|
||||||
|
|
||||||
|
|
||||||
class ApiRootView(APIView):
|
class ApiRootView(APIView):
|
||||||
|
|
||||||
authentication_classes = []
|
authentication_classes = []
|
||||||
@@ -795,7 +825,7 @@ class OrganizationTeamsList(SubListCreateAttachDetachAPIView):
|
|||||||
parent_key = 'organization'
|
parent_key = 'organization'
|
||||||
|
|
||||||
|
|
||||||
class OrganizationActivityStreamList(SubListAPIView):
|
class OrganizationActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -803,16 +833,6 @@ class OrganizationActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(OrganizationActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class OrganizationNotificationTemplatesList(SubListCreateAttachDetachAPIView):
|
class OrganizationNotificationTemplatesList(SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
@@ -960,7 +980,7 @@ class TeamProjectsList(SubListAPIView):
|
|||||||
return self.model.accessible_objects(self.request.user, 'read_role').filter(pk__in=[t.content_object.pk for t in proj_roles])
|
return self.model.accessible_objects(self.request.user, 'read_role').filter(pk__in=[t.content_object.pk for t in proj_roles])
|
||||||
|
|
||||||
|
|
||||||
class TeamActivityStreamList(SubListAPIView):
|
class TeamActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -968,16 +988,6 @@ class TeamActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(TeamActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -1061,7 +1071,7 @@ class ProjectSchedulesList(SubListCreateAttachDetachAPIView):
|
|||||||
new_in_148 = True
|
new_in_148 = True
|
||||||
|
|
||||||
|
|
||||||
class ProjectActivityStreamList(SubListAPIView):
|
class ProjectActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1069,16 +1079,6 @@ class ProjectActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(ProjectActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -1348,7 +1348,7 @@ class UserAdminOfOrganizationsList(OrganizationCountsMixin, SubListAPIView):
|
|||||||
return my_qs & user_qs
|
return my_qs & user_qs
|
||||||
|
|
||||||
|
|
||||||
class UserActivityStreamList(SubListAPIView):
|
class UserActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1356,16 +1356,6 @@ class UserActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(UserActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -1509,7 +1499,7 @@ class CredentialDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
serializer_class = CredentialSerializer
|
serializer_class = CredentialSerializer
|
||||||
|
|
||||||
|
|
||||||
class CredentialActivityStreamList(SubListAPIView):
|
class CredentialActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1517,16 +1507,6 @@ class CredentialActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(CredentialActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class CredentialAccessList(ResourceAccessList):
|
class CredentialAccessList(ResourceAccessList):
|
||||||
|
|
||||||
@@ -1606,7 +1586,7 @@ class InventoryDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
return super(InventoryDetail, self).destroy(request, *args, **kwargs)
|
return super(InventoryDetail, self).destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class InventoryActivityStreamList(SubListAPIView):
|
class InventoryActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1614,16 +1594,6 @@ class InventoryActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(InventoryActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -1750,7 +1720,7 @@ class HostInventorySourcesList(SubListAPIView):
|
|||||||
new_in_148 = True
|
new_in_148 = True
|
||||||
|
|
||||||
|
|
||||||
class HostActivityStreamList(SubListAPIView):
|
class HostActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1758,16 +1728,6 @@ class HostActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(HostActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -1775,18 +1735,7 @@ class HostActivityStreamList(SubListAPIView):
|
|||||||
return qs.filter(Q(host=parent) | Q(inventory=parent.inventory))
|
return qs.filter(Q(host=parent) | Q(inventory=parent.inventory))
|
||||||
|
|
||||||
|
|
||||||
class SystemTrackingEnforcementMixin(APIView):
|
class HostFactVersionsList(SystemTrackingEnforcementMixin, ParentMixin, ListAPIView):
|
||||||
'''
|
|
||||||
Use check_permissions instead of initial() because it's in the OPTION's path as well
|
|
||||||
'''
|
|
||||||
def check_permissions(self, request):
|
|
||||||
if not feature_enabled("system_tracking"):
|
|
||||||
raise LicenseForbids(_("Your license does not permit use "
|
|
||||||
"of system tracking."))
|
|
||||||
return super(SystemTrackingEnforcementMixin, self).check_permissions(request)
|
|
||||||
|
|
||||||
|
|
||||||
class HostFactVersionsList(ListAPIView, ParentMixin, SystemTrackingEnforcementMixin):
|
|
||||||
|
|
||||||
model = Fact
|
model = Fact
|
||||||
serializer_class = FactVersionSerializer
|
serializer_class = FactVersionSerializer
|
||||||
@@ -1812,7 +1761,7 @@ class HostFactVersionsList(ListAPIView, ParentMixin, SystemTrackingEnforcementMi
|
|||||||
return Response(dict(results=self.serializer_class(queryset, many=True).data))
|
return Response(dict(results=self.serializer_class(queryset, many=True).data))
|
||||||
|
|
||||||
|
|
||||||
class HostFactCompareView(SubDetailAPIView, SystemTrackingEnforcementMixin):
|
class HostFactCompareView(SystemTrackingEnforcementMixin, SubDetailAPIView):
|
||||||
|
|
||||||
model = Fact
|
model = Fact
|
||||||
new_in_220 = True
|
new_in_220 = True
|
||||||
@@ -1946,7 +1895,7 @@ class GroupInventorySourcesList(SubListAPIView):
|
|||||||
new_in_148 = True
|
new_in_148 = True
|
||||||
|
|
||||||
|
|
||||||
class GroupActivityStreamList(SubListAPIView):
|
class GroupActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -1954,16 +1903,6 @@ class GroupActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(GroupActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
self.check_parent_access(parent)
|
self.check_parent_access(parent)
|
||||||
@@ -2204,7 +2143,7 @@ class InventorySourceSchedulesList(SubListCreateAttachDetachAPIView):
|
|||||||
new_in_148 = True
|
new_in_148 = True
|
||||||
|
|
||||||
|
|
||||||
class InventorySourceActivityStreamList(SubListAPIView):
|
class InventorySourceActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -2212,16 +2151,6 @@ class InventorySourceActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(InventorySourceActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class InventorySourceNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView):
|
class InventorySourceNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
@@ -2514,13 +2443,13 @@ class JobTemplateSurveySpec(GenericAPIView):
|
|||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateSurveySpec(JobTemplateSurveySpec):
|
class WorkflowJobTemplateSurveySpec(WorkflowsEnforcementMixin, JobTemplateSurveySpec):
|
||||||
|
|
||||||
model = WorkflowJobTemplate
|
model = WorkflowJobTemplate
|
||||||
parent_model = WorkflowJobTemplate
|
parent_model = WorkflowJobTemplate
|
||||||
|
|
||||||
|
|
||||||
class JobTemplateActivityStreamList(SubListAPIView):
|
class JobTemplateActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -2528,16 +2457,6 @@ class JobTemplateActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(JobTemplateActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class JobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView):
|
class JobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
@@ -2771,28 +2690,28 @@ class JobTemplateObjectRolesList(SubListAPIView):
|
|||||||
return Role.objects.filter(content_type=content_type, object_id=po.pk)
|
return Role.objects.filter(content_type=content_type, object_id=po.pk)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobNodeList(ListAPIView):
|
class WorkflowJobNodeList(WorkflowsEnforcementMixin, ListAPIView):
|
||||||
|
|
||||||
model = WorkflowJobNode
|
model = WorkflowJobNode
|
||||||
serializer_class = WorkflowJobNodeListSerializer
|
serializer_class = WorkflowJobNodeListSerializer
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobNodeDetail(RetrieveAPIView):
|
class WorkflowJobNodeDetail(WorkflowsEnforcementMixin, RetrieveAPIView):
|
||||||
|
|
||||||
model = WorkflowJobNode
|
model = WorkflowJobNode
|
||||||
serializer_class = WorkflowJobNodeDetailSerializer
|
serializer_class = WorkflowJobNodeDetailSerializer
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNodeList(ListCreateAPIView):
|
class WorkflowJobTemplateNodeList(WorkflowsEnforcementMixin, ListCreateAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplateNode
|
model = WorkflowJobTemplateNode
|
||||||
serializer_class = WorkflowJobTemplateNodeListSerializer
|
serializer_class = WorkflowJobTemplateNodeListSerializer
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNodeDetail(RetrieveUpdateDestroyAPIView):
|
class WorkflowJobTemplateNodeDetail(WorkflowsEnforcementMixin, RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplateNode
|
model = WorkflowJobTemplateNode
|
||||||
serializer_class = WorkflowJobTemplateNodeDetailSerializer
|
serializer_class = WorkflowJobTemplateNodeDetailSerializer
|
||||||
@@ -2809,7 +2728,7 @@ class WorkflowJobTemplateNodeDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
return super(WorkflowJobTemplateNodeDetail, self).update_raw_data(data)
|
return super(WorkflowJobTemplateNodeDetail, self).update_raw_data(data)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNodeChildrenBaseList(EnforceParentRelationshipMixin, SubListCreateAttachDetachAPIView):
|
class WorkflowJobTemplateNodeChildrenBaseList(WorkflowsEnforcementMixin, EnforceParentRelationshipMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplateNode
|
model = WorkflowJobTemplateNode
|
||||||
serializer_class = WorkflowJobTemplateNodeListSerializer
|
serializer_class = WorkflowJobTemplateNodeListSerializer
|
||||||
@@ -2881,7 +2800,7 @@ class WorkflowJobTemplateNodeAlwaysNodesList(WorkflowJobTemplateNodeChildrenBase
|
|||||||
relationship = 'always_nodes'
|
relationship = 'always_nodes'
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobNodeChildrenBaseList(SubListAPIView):
|
class WorkflowJobNodeChildrenBaseList(WorkflowsEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = WorkflowJobNode
|
model = WorkflowJobNode
|
||||||
serializer_class = WorkflowJobNodeListSerializer
|
serializer_class = WorkflowJobNodeListSerializer
|
||||||
@@ -2912,7 +2831,7 @@ class WorkflowJobNodeAlwaysNodesList(WorkflowJobNodeChildrenBaseList):
|
|||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
class WorkflowJobTemplateList(ListCreateAPIView):
|
class WorkflowJobTemplateList(WorkflowsEnforcementMixin, ListCreateAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplate
|
model = WorkflowJobTemplate
|
||||||
serializer_class = WorkflowJobTemplateListSerializer
|
serializer_class = WorkflowJobTemplateListSerializer
|
||||||
@@ -2931,7 +2850,7 @@ class WorkflowJobTemplateList(ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
class WorkflowJobTemplateDetail(RetrieveUpdateDestroyAPIView):
|
class WorkflowJobTemplateDetail(WorkflowsEnforcementMixin, RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplate
|
model = WorkflowJobTemplate
|
||||||
serializer_class = WorkflowJobTemplateSerializer
|
serializer_class = WorkflowJobTemplateSerializer
|
||||||
@@ -2939,7 +2858,7 @@ class WorkflowJobTemplateDetail(RetrieveUpdateDestroyAPIView):
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateCopy(GenericAPIView):
|
class WorkflowJobTemplateCopy(WorkflowsEnforcementMixin, GenericAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplate
|
model = WorkflowJobTemplate
|
||||||
parent_model = WorkflowJobTemplate
|
parent_model = WorkflowJobTemplate
|
||||||
@@ -2965,12 +2884,12 @@ class WorkflowJobTemplateCopy(GenericAPIView):
|
|||||||
return Response(data, status=status.HTTP_201_CREATED)
|
return Response(data, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateLabelList(JobTemplateLabelList):
|
class WorkflowJobTemplateLabelList(WorkflowsEnforcementMixin, JobTemplateLabelList):
|
||||||
parent_model = WorkflowJobTemplate
|
parent_model = WorkflowJobTemplate
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateLaunch(RetrieveAPIView):
|
class WorkflowJobTemplateLaunch(WorkflowsEnforcementMixin, RetrieveAPIView):
|
||||||
|
|
||||||
|
|
||||||
model = WorkflowJobTemplate
|
model = WorkflowJobTemplate
|
||||||
@@ -3010,7 +2929,7 @@ class WorkflowJobTemplateLaunch(RetrieveAPIView):
|
|||||||
return Response(data, status=status.HTTP_201_CREATED)
|
return Response(data, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobRelaunch(GenericAPIView):
|
class WorkflowJobRelaunch(WorkflowsEnforcementMixin, GenericAPIView):
|
||||||
|
|
||||||
model = WorkflowJob
|
model = WorkflowJob
|
||||||
serializer_class = EmptySerializer
|
serializer_class = EmptySerializer
|
||||||
@@ -3030,7 +2949,7 @@ class WorkflowJobRelaunch(GenericAPIView):
|
|||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
class WorkflowJobTemplateWorkflowNodesList(SubListCreateAPIView):
|
class WorkflowJobTemplateWorkflowNodesList(WorkflowsEnforcementMixin, SubListCreateAPIView):
|
||||||
|
|
||||||
model = WorkflowJobTemplateNode
|
model = WorkflowJobTemplateNode
|
||||||
serializer_class = WorkflowJobTemplateNodeListSerializer
|
serializer_class = WorkflowJobTemplateNodeListSerializer
|
||||||
@@ -3046,7 +2965,7 @@ class WorkflowJobTemplateWorkflowNodesList(SubListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
class WorkflowJobTemplateJobsList(SubListAPIView):
|
class WorkflowJobTemplateJobsList(WorkflowsEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = WorkflowJob
|
model = WorkflowJob
|
||||||
serializer_class = WorkflowJobListSerializer
|
serializer_class = WorkflowJobListSerializer
|
||||||
@@ -3056,7 +2975,7 @@ class WorkflowJobTemplateJobsList(SubListAPIView):
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateSchedulesList(SubListCreateAttachDetachAPIView):
|
class WorkflowJobTemplateSchedulesList(WorkflowsEnforcementMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
view_name = _("Workflow Job Template Schedules")
|
view_name = _("Workflow Job Template Schedules")
|
||||||
|
|
||||||
@@ -3068,7 +2987,7 @@ class WorkflowJobTemplateSchedulesList(SubListCreateAttachDetachAPIView):
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView):
|
class WorkflowJobTemplateNotificationTemplatesAnyList(WorkflowsEnforcementMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
model = NotificationTemplate
|
model = NotificationTemplate
|
||||||
serializer_class = NotificationTemplateSerializer
|
serializer_class = NotificationTemplateSerializer
|
||||||
@@ -3077,7 +2996,7 @@ class WorkflowJobTemplateNotificationTemplatesAnyList(SubListCreateAttachDetachA
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNotificationTemplatesErrorList(SubListCreateAttachDetachAPIView):
|
class WorkflowJobTemplateNotificationTemplatesErrorList(WorkflowsEnforcementMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
model = NotificationTemplate
|
model = NotificationTemplate
|
||||||
serializer_class = NotificationTemplateSerializer
|
serializer_class = NotificationTemplateSerializer
|
||||||
@@ -3086,7 +3005,7 @@ class WorkflowJobTemplateNotificationTemplatesErrorList(SubListCreateAttachDetac
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateNotificationTemplatesSuccessList(SubListCreateAttachDetachAPIView):
|
class WorkflowJobTemplateNotificationTemplatesSuccessList(WorkflowsEnforcementMixin, SubListCreateAttachDetachAPIView):
|
||||||
|
|
||||||
model = NotificationTemplate
|
model = NotificationTemplate
|
||||||
serializer_class = NotificationTemplateSerializer
|
serializer_class = NotificationTemplateSerializer
|
||||||
@@ -3095,14 +3014,14 @@ class WorkflowJobTemplateNotificationTemplatesSuccessList(SubListCreateAttachDet
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateAccessList(ResourceAccessList):
|
class WorkflowJobTemplateAccessList(WorkflowsEnforcementMixin, ResourceAccessList):
|
||||||
|
|
||||||
model = User # needs to be User for AccessLists's
|
model = User # needs to be User for AccessLists's
|
||||||
resource_model = WorkflowJobTemplate
|
resource_model = WorkflowJobTemplate
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateObjectRolesList(SubListAPIView):
|
class WorkflowJobTemplateObjectRolesList(WorkflowsEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = Role
|
model = Role
|
||||||
serializer_class = RoleSerializer
|
serializer_class = RoleSerializer
|
||||||
@@ -3115,7 +3034,7 @@ class WorkflowJobTemplateObjectRolesList(SubListAPIView):
|
|||||||
return Role.objects.filter(content_type=content_type, object_id=po.pk)
|
return Role.objects.filter(content_type=content_type, object_id=po.pk)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobTemplateActivityStreamList(SubListAPIView):
|
class WorkflowJobTemplateActivityStreamList(WorkflowsEnforcementMixin, ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -3123,19 +3042,9 @@ class WorkflowJobTemplateActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_310 = True
|
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:
|
# TODO:
|
||||||
class WorkflowJobList(ListCreateAPIView):
|
class WorkflowJobList(WorkflowsEnforcementMixin, ListCreateAPIView):
|
||||||
|
|
||||||
model = WorkflowJob
|
model = WorkflowJob
|
||||||
serializer_class = WorkflowJobListSerializer
|
serializer_class = WorkflowJobListSerializer
|
||||||
@@ -3143,14 +3052,14 @@ class WorkflowJobList(ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
class WorkflowJobDetail(RetrieveDestroyAPIView):
|
class WorkflowJobDetail(WorkflowsEnforcementMixin, RetrieveDestroyAPIView):
|
||||||
|
|
||||||
model = WorkflowJob
|
model = WorkflowJob
|
||||||
serializer_class = WorkflowJobSerializer
|
serializer_class = WorkflowJobSerializer
|
||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobWorkflowNodesList(SubListAPIView):
|
class WorkflowJobWorkflowNodesList(WorkflowsEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = WorkflowJobNode
|
model = WorkflowJobNode
|
||||||
serializer_class = WorkflowJobNodeListSerializer
|
serializer_class = WorkflowJobNodeListSerializer
|
||||||
@@ -3161,7 +3070,7 @@ class WorkflowJobWorkflowNodesList(SubListAPIView):
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobCancel(RetrieveAPIView):
|
class WorkflowJobCancel(WorkflowsEnforcementMixin, RetrieveAPIView):
|
||||||
|
|
||||||
model = WorkflowJob
|
model = WorkflowJob
|
||||||
serializer_class = WorkflowJobCancelSerializer
|
serializer_class = WorkflowJobCancelSerializer
|
||||||
@@ -3179,7 +3088,7 @@ class WorkflowJobCancel(RetrieveAPIView):
|
|||||||
return self.http_method_not_allowed(request, *args, **kwargs)
|
return self.http_method_not_allowed(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobNotificationsList(SubListAPIView):
|
class WorkflowJobNotificationsList(WorkflowsEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = Notification
|
model = Notification
|
||||||
serializer_class = NotificationSerializer
|
serializer_class = NotificationSerializer
|
||||||
@@ -3188,7 +3097,7 @@ class WorkflowJobNotificationsList(SubListAPIView):
|
|||||||
new_in_310 = True
|
new_in_310 = True
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobActivityStreamList(SubListAPIView):
|
class WorkflowJobActivityStreamList(WorkflowsEnforcementMixin, ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -3196,16 +3105,6 @@ class WorkflowJobActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_310 = True
|
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):
|
class SystemJobTemplateList(ListAPIView):
|
||||||
|
|
||||||
@@ -3320,11 +3219,11 @@ class JobLabelList(SubListAPIView):
|
|||||||
parent_key = 'job'
|
parent_key = 'job'
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJobLabelList(JobLabelList):
|
class WorkflowJobLabelList(WorkflowsEnforcementMixin, JobLabelList):
|
||||||
parent_model = WorkflowJob
|
parent_model = WorkflowJob
|
||||||
|
|
||||||
|
|
||||||
class JobActivityStreamList(SubListAPIView):
|
class JobActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -3332,16 +3231,6 @@ class JobActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_145 = True
|
new_in_145 = 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(JobActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class JobStart(GenericAPIView):
|
class JobStart(GenericAPIView):
|
||||||
|
|
||||||
@@ -3916,7 +3805,7 @@ class AdHocCommandAdHocCommandEventsList(BaseAdHocCommandEventsList):
|
|||||||
new_in_220 = True
|
new_in_220 = True
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandActivityStreamList(SubListAPIView):
|
class AdHocCommandActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
@@ -3924,16 +3813,6 @@ class AdHocCommandActivityStreamList(SubListAPIView):
|
|||||||
relationship = 'activitystream_set'
|
relationship = 'activitystream_set'
|
||||||
new_in_220 = True
|
new_in_220 = 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(AdHocCommandActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandNotificationsList(SubListAPIView):
|
class AdHocCommandNotificationsList(SubListAPIView):
|
||||||
|
|
||||||
@@ -4170,39 +4049,19 @@ class LabelDetail(RetrieveUpdateAPIView):
|
|||||||
new_in_300 = True
|
new_in_300 = True
|
||||||
|
|
||||||
|
|
||||||
class ActivityStreamList(SimpleListAPIView):
|
class ActivityStreamList(ActivityStreamEnforcementMixin, SimpleListAPIView):
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
new_in_145 = True
|
new_in_145 = 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.
|
class ActivityStreamDetail(ActivityStreamEnforcementMixin, RetrieveAPIView):
|
||||||
return super(ActivityStreamList, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ActivityStreamDetail(RetrieveAPIView):
|
|
||||||
|
|
||||||
model = ActivityStream
|
model = ActivityStream
|
||||||
serializer_class = ActivityStreamSerializer
|
serializer_class = ActivityStreamSerializer
|
||||||
new_in_145 = True
|
new_in_145 = 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(ActivityStreamDetail, self).get(request, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class RoleList(ListAPIView):
|
class RoleList(ListAPIView):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user