Remaining license differentiation for activity streams.

This commit is contained in:
Luke Sneeringer
2015-05-21 11:35:34 -04:00
parent 9cc68d4da7
commit d5a781f43e

View File

@@ -508,7 +508,7 @@ class OrganizationList(ListCreateAPIView):
# if no organizations exist in the system. # if no organizations exist in the system.
if (not feature_enabled('multiple_organizations') and if (not feature_enabled('multiple_organizations') and
self.model.objects.filter(active=True).count() > 0): self.model.objects.filter(active=True).count() > 0):
raise LicenseForbids('This Tower license only permits a single ' raise LicenseForbids('Your Tower license only permits a single '
'organization to exist.') 'organization to exist.')
# Okay, create the organization as usual. # Okay, create the organization as usual.
@@ -566,7 +566,7 @@ class OrganizationActivityStreamList(SubListAPIView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
# Sanity check: Does this license allow activity streams? # Sanity check: Does this license allow activity streams?
# If not, forbid this request. # If not, forbid this request.
if not feature_enabled('activity_stream'): if not feature_enabled('activity_streams'):
raise LicenseForbids('Your license does not allow use of ' raise LicenseForbids('Your license does not allow use of '
'the activity stream.') 'the activity stream.')
@@ -635,7 +635,7 @@ class TeamActivityStreamList(SubListAPIView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
# Sanity check: Does this license allow activity streams? # Sanity check: Does this license allow activity streams?
# If not, forbid this request. # If not, forbid this request.
if not feature_enabled('activity_stream'): if not feature_enabled('activity_streams'):
raise LicenseForbids('Your license does not allow use of ' raise LicenseForbids('Your license does not allow use of '
'the activity stream.') 'the activity stream.')
@@ -718,6 +718,16 @@ 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(type(self), 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)
@@ -851,6 +861,16 @@ 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(type(self), 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)
@@ -907,6 +927,16 @@ 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(type(self), self).get(request, *args, **kwargs)
class PermissionDetail(RetrieveUpdateDestroyAPIView): class PermissionDetail(RetrieveUpdateDestroyAPIView):
model = Permission model = Permission
@@ -955,6 +985,16 @@ 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(type(self), 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)
@@ -1059,6 +1099,16 @@ 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(type(self), 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)
@@ -1267,6 +1317,16 @@ 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(type(self), 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)
@@ -1543,6 +1603,16 @@ 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(type(self), self).get(request, *args, **kwargs)
class InventorySourceHostsList(SubListAPIView): class InventorySourceHostsList(SubListAPIView):
model = Host model = Host
@@ -1744,6 +1814,16 @@ 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(type(self), self).get(request, *args, **kwargs)
class JobTemplateCallback(GenericAPIView): class JobTemplateCallback(GenericAPIView):
model = JobTemplate model = JobTemplate
@@ -1989,6 +2069,16 @@ 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(type(self), self).get(request, *args, **kwargs)
class JobStart(GenericAPIView): class JobStart(GenericAPIView):
model = Job model = Job
@@ -2579,6 +2669,16 @@ 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(type(self), self).get(request, *args, **kwargs)
class SystemJobList(ListCreateAPIView): class SystemJobList(ListCreateAPIView):
@@ -2670,12 +2770,34 @@ class ActivityStreamList(SimpleListAPIView):
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(type(self), self).get(request, *args, **kwargs)
class ActivityStreamDetail(RetrieveAPIView): 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(type(self), self).get(request, *args, **kwargs)
# Create view functions for all of the class-based views to simplify inclusion # Create view functions for all of the class-based views to simplify inclusion
# in URL patterns and reverse URL lookups, converting CamelCase names to # in URL patterns and reverse URL lookups, converting CamelCase names to
# lowercase_with_underscore (e.g. MyView.as_view() becomes my_view). # lowercase_with_underscore (e.g. MyView.as_view() becomes my_view).