Esempio n. 1
0
      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'
      logging.warn(message)
      return error_response(403, message)

    try:
      app.update(data)
      app.save()
      update_json = {'updated': app.updated_timestamp()}
      return encode_json(update_json)
    except Exception, e:
      logging.error(e)
      return error_response(500)

  @public_api_auth
  def DELETE(self, app_id, auth_user=None, auth_app_id=None):
    '''
    Delete the given app, and returns a JSON object containing a
    success notification.
    '''
    try:
      app_id = ObjectId(app_id)
            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'
            logging.warn(message)
            return error_response(403, message)

        try:
            app.update(data)
            app.save()
            update_json = {'updated': app.updated_timestamp()}
            return encode_json(update_json)
        except Exception, e:
            logging.error(e)
            return error_response(500)

    @public_api_auth
    def DELETE(self, app_id, auth_user=None, auth_app_id=None):
        '''
    Delete the given app, and returns a JSON object containing a
    success notification.
    '''
        try:
            app_id = ObjectId(app_id)