def POST(self, auth_user=None, auth_app_id=None): ''' Create a new app and return a JSON object containing the new app information. ''' params = web.input(data=None) try: if params.data: data = decode_json(params.data) else: data = decode_json(web.ctx.data) App.validate(data) except Exception, e: logging.error(e) return error_response(400, 'Data did not pass validation')
@public_api_auth def PUT(self, app_id, auth_user=None, auth_app_id=None): ''' Update the given app, and returns a JSON object containing the new timestamp. ''' try: app_id = ObjectId(app_id) except Exception, e: logging.error(e) return error_response(400, 'Not a valid app id') try: data = decode_json(web.ctx.data) App.validate(data) except Exception, e: return error_response(400, 'Data did not pass validation') try: app = App.collection.find_one({'_id': app_id, 'deleted': False}) except Exception, e: logging.error(e) return error_response(500, 'Server Error') if not app: message = 'App does not exist' logging.warn(message) return error_response(404, message) if not app.user_can_update(auth_user): message = 'App cannot be accessed by the user'