def create_reference_type(data): reference_type = ReferenceType() reference_type.populate_from_dict(data) db.session.add(reference_type) db.session.flush() logger.info('Reference type "%s" created by %s', reference_type, session.user) return reference_type
def create_reference_type(data): reference_type = ReferenceType() reference_type.populate_from_dict(data) db.session.add(reference_type) db.session.flush() logger.info('Reference type "%s" created by %s', reference_type, session.user) return reference_type
def validate_name(self, field): query = ReferenceType.find( db.func.lower(ReferenceType.name) == field.data.lower()) if self.reference_type: query = query.filter(ReferenceType.id != self.reference_type.id) if query.count(): raise ValidationError(_("This name is already in use."))
def migrate_reference_types(self): for name in self.reference_types: self.global_ns.reference_types[name] = reftype = ReferenceType( name=name) db.session.add(reftype) self.print_success(name) db.session.commit()
def __init__(self, *args, **kwargs): self.reference_class = kwargs.pop("reference_class") self.fields = [ {"id": "type", "caption": _("Type"), "type": "select", "required": True}, {"id": "value", "caption": _("Value"), "type": "text", "required": True}, ] self.choices = {"type": {unicode(r.id): r.name for r in ReferenceType.find_all()}} super(ReferencesField, self).__init__(*args, uuid_field="id", uuid_field_opaque=True, **kwargs)
def __init__(self, *args, **kwargs): self.reference_class = kwargs.pop('reference_class') self.fields = [{ 'id': 'type', 'caption': _("Type"), 'type': 'select', 'required': True }, { 'id': 'value', 'caption': _("Value"), 'type': 'text', 'required': True }] self.choices = { 'type': {unicode(r.id): r.name for r in ReferenceType.find_all()} } super(ReferencesField, self).__init__(*args, uuid_field='id', uuid_field_opaque=True, **kwargs)
def _process_args(self): self.reference_value = request.form['value'] reference_type_name = request.form['type'] self.reference_type = ReferenceType.find_one( db.func.lower(ReferenceType.name) == reference_type_name.lower())
def _process_args(self): RHAdminBase._process_args(self) self.reference_type = ReferenceType.find_one(id=request.view_args['reference_type_id'])
def _process_args(self): RHAdminBase._process_args(self) self.reference_type = ReferenceType.find_one( id=request.view_args['reference_type_id'])
def __init__(self, *args, **kwargs): self.reference_class = kwargs.pop('reference_class') self.fields = [{'id': 'type', 'caption': _("Type"), 'type': 'select', 'required': True}, {'id': 'value', 'caption': _("Value"), 'type': 'text', 'required': True}] self.choices = {'type': {unicode(r.id): r.name for r in ReferenceType.find_all()}} super(ReferencesField, self).__init__(*args, uuid_field='id', uuid_field_opaque=True, **kwargs)
def _process_args(self): self.reference_value = request.form['value'] reference_type_name = request.form['type'] self.reference_type = ReferenceType.find_one(db.func.lower(ReferenceType.name) == reference_type_name.lower())
def validate_name(self, field): query = ReferenceType.find(db.func.lower(ReferenceType.name) == field.data.lower()) if self.reference_type: query = query.filter(ReferenceType.id != self.reference_type.id) if query.count(): raise ValidationError(_("This name is already in use."))
def _checkParams(self, params): RHAdminBase._checkParams(self, params) self.reference_type = ReferenceType.find_one( id=request.view_args['reference_type_id'])
def _checkParams(self, params): RHAdminBase._checkParams(self, params) self.reference_type = ReferenceType.find_one(id=request.view_args['reference_type_id'])