Skip to content

Commit

Permalink
Merge pull request #325 from mekanix/feature/cluster-service
Browse files Browse the repository at this point in the history
Check if ID is valid
  • Loading branch information
mekanix authored Jul 22, 2016
2 parents 5868db6 + 877af4e commit a0f132d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 3 additions & 0 deletions onelove/api/cluster_services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask_restplus import abort
from mongoengine.errors import ValidationError

from ..models import Service
from .fields.cluster_service import post_fields
Expand Down Expand Up @@ -45,6 +46,8 @@ def post(self, cluster_id):
service = Service.objects.get(id=service_id)
except Service.DoesNotExist:
abort(404, 'No such service')
except ValidationError as e:
abort(409, e.message)

cluster.services.append(service)
cluster.save()
Expand Down
2 changes: 0 additions & 2 deletions onelove/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def get(self, id):
service = self._find_service(id)
return service

@ns_service.expect(fields)
@ns_service.marshal_with(get_fields)
@ns_service.expect(fields)
@ns_service.marshal_with(get_fields)
def patch(self, id):
Expand Down

0 comments on commit a0f132d

Please sign in to comment.