Esempio n. 1
0
 def put(self, username):
     # get the json from the request, it's already validated
     req_json = request.get_json(force=True)
     # is the id specified
     if not id:
         return jsonify(message=strings.ENTITY_NO_ID), 400
     # try and get the object from the database
     try:
         self.resource_type.objects.get(id)
     # if we git more than one, something is horribly wrong
     except self.entity_type.MultipleObjectsReturned:
         return jsonify(message=strings.ENTITY_MULTIPLE_RESULTS), 500
     # if it doesn't exist, inform the user
     except self.entity_type.DoesNotExist:
         return jsonify(message=strings.ENTITY_NOT_FOUND), 404
     # if everything went smoothly, update the entity
     UserService.update_user(req_json)
     # indicate success
     return jsonify(message=strings.API_SUCCESS), 200
Esempio n. 2
0
 def put(self, username):
     # get the json from the request, it's already validated
     req_json = request.get_json(force=True)
     # is the id specified
     if not id:
         return jsonify(message=strings.ENTITY_NO_ID), 400
     # try and get the object from the database
     try:
         self.resource_type.objects.get(id)
     # if we git more than one, something is horribly wrong
     except self.entity_type.MultipleObjectsReturned:
         return jsonify(message=strings.ENTITY_MULTIPLE_RESULTS), 500
     # if it doesn't exist, inform the user
     except self.entity_type.DoesNotExist:
         return jsonify(message=strings.ENTITY_NOT_FOUND), 404
     # if everything went smoothly, update the entity
     UserService.update_user(req_json)
     # indicate success
     return jsonify(message=strings.API_SUCCESS), 200