def create(self, author, data): from mini_fiction.models import AdminLog data = Validator(CHARACTER).validated(data) errors = {} exist_character = self.model.get(name=data['name']) if exist_character: errors['name'] = [lazy_gettext('Character already exists')] from mini_fiction.models import CharacterGroup group = CharacterGroup.get(id=data['group']) if not group: errors['group'] = [lazy_gettext('Group not found')] if errors: raise ValidationError(errors) picture = self.validate_and_get_picture_data(data.pop('picture')) character = self.model(picture='pending', sha256sum='pending', **data) character.flush() character.bl.set_picture_data(picture) AdminLog.bl.create(user=author, obj=character, action=AdminLog.ADDITION) return character
def create(self, author, data): from mini_fiction.models import AdminLog data = Validator(CHARACTER).validated(data) errors = {} exist_character = self.model.get(name=data['name']) if exist_character: errors['name'] = [lazy_gettext('Character already exists')] from mini_fiction.models import CharacterGroup group = CharacterGroup.get(id=data['group']) if not group: errors['group'] = [lazy_gettext('Group not found')] if errors: raise ValidationError(errors) picture = self.validate_and_get_picture_data(data.pop('picture')) character = self.model(picture='pending', sha256sum='pending', **data) character.flush() character.bl.set_picture_data(picture) AdminLog.bl.create(user=author, obj=character, action=AdminLog.ADDITION) return character
def create(self, author, data): from mini_fiction.models import AdminLog data = Validator(LOGOPIC).validated(data) picture = data.pop('picture') logopic = self.model(picture='pending', sha256sum='pending', **data) logopic.flush() logopic.bl.set_picture_data(picture) current_app.cache.delete('logopics') AdminLog.bl.create(user=author, obj=logopic, action=AdminLog.ADDITION) return logopic
def create(self, author, data): from mini_fiction.models import AdminLog data = Validator(LOGOPIC).validated(data) picture = data.pop('picture') logopic = self.model(picture='pending', sha256sum='pending', **data) logopic.flush() logopic.bl.set_picture_data(picture) current_app.cache.delete('logopics') AdminLog.bl.create(user=author, obj=logopic, action=AdminLog.ADDITION) return logopic