def put(self, hashkey): from app import db mod = self.get_group_by_key(hashkey) context = ExecutionContext(user=current_user) perm_manager = GroupPermissions(context) perm = perm_manager.check_perms(mod, "update") data = get_data() if perm: mod.description = data.get('description', mod.description) db.session.commit() return self.convert_group(mod), 200
def post(self): from app import db data = get_data() name = data.get('name') description = data.get('description') mod = Group(owner=current_user) mod.name = name mod.description = description current_user.groups.append(mod) db.session.commit() return self.convert_group(mod), 201
def post(self, scope, hashkey): data = get_data() positions = data.pop('positions', None) if positions is None: return {}, 400 context, mod = get_context_for_scope(scope, hashkey) row = 0 for (i, pos) in enumerate(positions): manager = ResourceManager(context) manager.update_model(pos['hashkey'], dict(layout=pos['layout'])) row += self.get_resource(pos['hashkey']).layout.sizeX return {}, 200
def post(self, scope, hashkey): data = get_data() positions = data.pop("positions", None) if positions is None: return {}, 400 context, mod = get_context_for_scope(scope, hashkey) row = 0 for (i, pos) in enumerate(positions): manager = ResourceManager(context) manager.update_model(pos["hashkey"], dict(layout=pos["layout"])) row += self.get_resource(pos["hashkey"]).layout.sizeX return {}, 200
def post(self): data = get_data() if data is not None: form = self.form_class(MultiDict(data)) else: form = self.form_class() if form.validate_on_submit(): login_user(form.user, remember=form.remember.data) after_this_request(_commit) # This returns the response and the status code. See function. return authentication_response(form) return form.as_json(), 400
def post(self): """ JSON params - token (string) Returns - id, hashkey, email """ data = get_data() token = data['token'] user = check_token(token) authenticated = user is not None data = dict(authenticated=authenticated) code = 401 if authenticated: data.update(dict( email=user.email, hashkey=user.hashkey, id=user.id, )) code = 200 return data, code
def post(self): """ JSON params - token (string) Returns - id, hashkey, email """ data = get_data() token = data['token'] user = check_token(token) authenticated = user is not None data = dict(authenticated=authenticated) code = 401 if authenticated: data.update( dict( email=user.email, hashkey=user.hashkey, id=user.id, )) code = 200 return data, code
def put(self, hashkey): from app import db model, model_settings = self.get_model() data = get_data() for attr in self.fields: if data is not None and attr in data: val = data.get(attr, getattr(model, attr)) if attr == "settings": try: val = json.loads(val) except Exception: pass settings = model.settings for k in val: settings[k] = val[k] val = settings setattr(model, attr, val) db.session.commit() return {}, 200
def post(self): """ Registers a user. JSON params - username (string), password (string) Returns - form with inline errors if error, authentication response otherwise. """ data = get_data() if data is not None: form = self.form_class(MultiDict(data)) else: form = self.form_class() if form.validate_on_submit(): user = register_user(**form.to_dict()) form.user = user if not _security.confirmable or _security.login_without_confirmation: after_this_request(_commit) login_user(user) # This returns the response and the status code. See function. return authentication_response(form) return form.as_json(), 400
def save_settings(self, scope, hashkey, plugin_hashkey): runner = self.get_runner(scope, hashkey) response = runner.save_settings(plugin_hashkey, MultiDict(get_data())) return response
def post(self, scope, hashkey): data = get_data() return self.convert(scope, hashkey, self.make_model(scope, hashkey, **data))
def patch(self, scope, hashkey, resource_hashkey): settings = get_data() context, mod = get_context_for_scope(scope, hashkey) manager = ResourceManager(context) model = manager.update_resource(resource_hashkey, settings) return self.convert(scope, hashkey, model)
def post(self, scope, hashkey): data = get_data() root = self.process_related(scope, hashkey, data) return self.convert(scope, hashkey, root, find_related=True)
def find_post_data(self): data = get_data() return self.get_key(data)