Allow manual updates in spite of update_on_project_update

This makes inventory sources with the that flag set behave
like any other inventory source with manual use.
They will still update when triggered by a project SCM
hash change.
This commit is contained in:
AlanCoding
2017-07-20 08:46:27 -04:00
parent 1c5b0f023e
commit f2d51f99dc
3 changed files with 2 additions and 43 deletions

View File

@@ -2634,24 +2634,9 @@ class InventorySourceUpdateView(RetrieveAPIView):
is_job_start = True
new_in_14 = True
def _update_dependent_project(self, obj, request):
if not self.request.user or not self.request.user.can_access(Project, 'start', obj.source_project):
raise PermissionDenied(detail=_(
'You do not have permission to update project `{}`.'.format(obj.source_project.name)))
project_update = obj.source_project.update()
if not project_update:
return Response({}, status=status.HTTP_400_BAD_REQUEST)
else:
headers = {'Location': project_update.get_absolute_url(request=request)}
return Response(dict(
detail=_('Request to update dependent project has been accepted.'), inventory_update=None),
status=status.HTTP_202_ACCEPTED, headers=headers)
def post(self, request, *args, **kwargs):
obj = self.get_object()
if obj.can_update:
if obj.source == 'scm' and obj.update_on_project_update:
return self._update_dependent_project(obj, request)
update = obj.update()
if not update:
return Response({}, status=status.HTTP_400_BAD_REQUEST)