def _process_POST(self): data = dict({ 'background_position': 'stretch', 'items': [] }, **request.json['template']) self.validate_json(TEMPLATE_DATA_JSON_SCHEMA, data) invalid_placeholders = {x['type'] for x in data['items']} - set( get_placeholder_options()) if invalid_placeholders: raise UserValueError('Invalid item types: {}'.format( ', '.join(invalid_placeholders))) image_items = [ item for item in data['items'] if item['type'] == 'fixed_image' ] template_images = {img.id for img in self.template.images} for image_item in image_items: if 'image_id' not in image_item: raise UserValueError( _('A Fixed Image element must contain an image')) if image_item['image_id'] not in template_images: raise UserValueError( _('The image file does not belong to this template')) update_template( self.template, title=request.json['title'], data=data, backside_template_id=request.json['backside_template_id'], is_clonable=request.json['is_clonable'], clear_background=request.json['clear_background']) flash(_('Template successfully saved.'), 'success') return jsonify_data()
def _process_POST(self): data = dict({'background_position': 'stretch', 'items': []}, **request.json['template']) self.validate_json(TEMPLATE_DATA_JSON_SCHEMA, data) update_template(self.template, title=request.json['title'], data=data, backside_template_id=request.json['backside_template_id'], is_clonable=request.json['is_clonable'], clear_background=request.json['clear_background']) flash(_("Template successfully saved."), 'success') return jsonify_data()
def _process_POST(self): data = dict({'background_position': 'stretch', 'items': []}, **request.json['template']) self.validate_json(TEMPLATE_DATA_JSON_SCHEMA, data) update_template(self.template, title=request.json['title'], data=data, backside_template_id=request.json['backside_template_id'], is_clonable=request.json['is_clonable'], clear_background=request.json['clear_background']) flash(_("Template successfully saved."), 'success') return jsonify_data()
def _process_POST(self): data = dict({'background_position': 'stretch', 'items': []}, **request.json['template']) self.validate_json(TEMPLATE_DATA_JSON_SCHEMA, data) invalid_placeholders = {x['type'] for x in data['items']} - set(get_placeholder_options()) - {'fixed'} if invalid_placeholders: raise UserValueError('Invalid item types: {}'.format(', '.join(invalid_placeholders))) update_template(self.template, title=request.json['title'], data=data, backside_template_id=request.json['backside_template_id'], is_clonable=request.json['is_clonable'], clear_background=request.json['clear_background']) flash(_("Template successfully saved."), 'success') return jsonify_data()
def _process_POST(self): data = dict({'background_position': 'stretch', 'items': []}, **request.json['template']) self.validate_json(TEMPLATE_DATA_JSON_SCHEMA, data) invalid_placeholders = {x['type'] for x in data['items']} - set(get_placeholder_options()) - {'fixed'} if invalid_placeholders: raise UserValueError('Invalid item types: {}'.format(', '.join(invalid_placeholders))) update_template(self.template, title=request.json['title'], data=data, backside_template_id=request.json['backside_template_id'], is_clonable=request.json['is_clonable'], clear_background=request.json['clear_background']) flash(_("Template successfully saved."), 'success') return jsonify_data()