예제 #1
0
파일: forms.py 프로젝트: chintal/tendril
 def validate_target_cardname(form, field):
     cardname = field.data.strip()
     if form.sno.data and not cardname:
         raise ValidationError("Specify target Indent.")
     if form.orig_cardname.data and not cardname:
         raise ValidationError("Specify target Indent.")
     if not cardname:
         return
     if cardname not in cards.keys():
         raise ValidationError("Ident not recognized.")
     if form.orig_cardname.data.strip() == cardname:
         raise ValidationError("No change?")
예제 #2
0
파일: forms.py 프로젝트: chintal/tendril
 def validate_target_cardname(form, field):
     cardname = field.data.strip()
     if form.sno.data and not cardname:
         raise ValidationError("Specify target Indent.")
     if form.orig_cardname.data and not cardname:
         raise ValidationError("Specify target Indent.")
     if not cardname:
         return
     if cardname not in cards.keys():
         raise ValidationError("Ident not recognized.")
     if form.orig_cardname.data.strip() == cardname:
         raise ValidationError("No change?")
예제 #3
0
파일: forms.py 프로젝트: chintal/tendril
 def validate_orig_cardname(form, field):
     cardname = field.data.strip()
     if form.sno.data and not cardname:
         raise ValidationError("Specify original Indent.")
     if form.target_cardname.data and not cardname:
         raise ValidationError("Specify original Indent.")
     if not cardname:
         return
     if cardname:
         if cardname not in cards.keys():
             raise ValidationError("Ident not recognized.")
     try:
         efield = serialnos.get_serialno_efield(sno=form.sno.data.strip())
         if cardname != efield:
             raise ValidationError("S.No. seems to be {0}.".format(efield))
     except SerialNoNotFound:
         pass
예제 #4
0
파일: forms.py 프로젝트: chintal/tendril
 def validate_orig_cardname(form, field):
     cardname = field.data.strip()
     if form.sno.data and not cardname:
         raise ValidationError("Specify original Indent.")
     if form.target_cardname.data and not cardname:
         raise ValidationError("Specify original Indent.")
     if not cardname:
         return
     if cardname:
         if cardname not in cards.keys():
             raise ValidationError("Ident not recognized.")
     try:
         efield = serialnos.get_serialno_efield(sno=form.sno.data.strip())
         if cardname != efield:
             raise ValidationError("S.No. seems to be {0}.".format(efield))
     except SerialNoNotFound:
         pass
예제 #5
0
파일: forms.py 프로젝트: chintal/tendril
class ModuleQtyForm(Form):
    # TODO add customization field
    ident = StringField(label='Module',
                        validators=[
                            Optional(),
                            AnyOf(cards.keys(),
                                  message="Module not recognized.")
                        ])
    qty = StringField(label='Qty', validators=[])

    def validate_qty(form, field):
        if form.ident.data:
            try:
                qty = int(field.data.strip())
                if qty <= 0:
                    raise ValidationError("Invalid Qty.")
            except:
                raise ValidationError("Invalid Qty.")
        else:
            if field.data:
                raise ValidationError("Detached Qty.")