Commit 166c1697 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Reorder a module

parent b22c2c6b
......@@ -27,6 +27,53 @@ class DeploymentsView(generics.ListAPIView):
return self.request.user.site.pending_tasks
class ResponseView(views.APIView):
authentication_classes = AUTHENTICATION_CLASSES
def post(self, request):
client_site = request.user.site
output = request.data.get('output', {})
state_id = request.data.get('id', None)
_service = request.data.get('service', {})
service = None
service_query = client_site.services.filter(
name=_service['name'],
)
#LOGGER.debug("[ResponseView]services: %s %s", service_query, len(service_query))
if service_query.exists() and len(service_query) == 1:
service = service_query.first()
else:
LOGGER.error(
'[ResponseView] Unknown service %s from %s',
_service['name'],
request.user,
)
return response_view_error('unable to determine service')
if state_id is None:
err = 'no state id'
LOGGER.error('Error parsing response from %s: %s', request.user, err)
return response_view_error(err)
# find the corresponding NewDeploymentStateItem for this response
try:
state_item = client_site.state_items.get(
parent__id=int(state_id),
site=client_site,
service=service,
)
err = state_item.client_response(output)
if err is not None:
LOGGER.error('[ResponseView] Error parsing response from %s: %s', request.user, err)
return response_view_error(err)
return Response({})
except models.NewDeploymentStateItem.DoesNotExist:
LOGGER.error('[ResponseView] No matching DStateItem')
return response_view_error('no matching NewDeploymentStateItem')
# the client has to fetch the configuration (like services etc.) here
class ConfigurationView(views.APIView):
authentication_classes = AUTHENTICATION_CLASSES
......@@ -103,50 +150,3 @@ def response_view_error(err):
data={'error': err},
status=500,
)
class ResponseView(views.APIView):
authentication_classes = AUTHENTICATION_CLASSES
def post(self, request):
client_site = request.user.site
output = request.data.get('output', {})
state_id = request.data.get('id', None)
_service = request.data.get('service', {})
service = None
service_query = client_site.services.filter(
name=_service['name'],
)
#LOGGER.debug("[ResponseView]services: %s %s", service_query, len(service_query))
if service_query.exists() and len(service_query) == 1:
service = service_query.first()
else:
LOGGER.error(
'[ResponseView] Unknown service %s from %s',
_service['name'],
request.user,
)
return response_view_error('unable to determine service')
if state_id is None:
err = 'no state id'
LOGGER.error('Error parsing response from %s: %s', request.user, err)
return response_view_error(err)
# find the corresponding NewDeploymentStateItem for this response
try:
state_item = client_site.state_items.get(
parent__id=int(state_id),
site=client_site,
service=service,
)
err = state_item.client_response(output)
if err is not None:
LOGGER.error('[ResponseView] Error parsing response from %s: %s', request.user, err)
return response_view_error(err)
return Response({})
except models.NewDeploymentStateItem.DoesNotExist:
LOGGER.error('[ResponseView] No matching DStateItem')
return response_view_error('no matching NewDeploymentStateItem')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment