예제 #1
0
 def populate_obj(self, obj, name):
     if self.data:
         try:
             if getattr(obj, name) is None:
                 setattr(obj, name, self.form.Meta.model())
         except AttributeError:
             pass
     FormField.populate_obj(self, obj, name)
예제 #2
0
 def __init__(self, label=None, validators=None, separator='-', **kwargs):
     FormField.__init__(
         self,
         DateTimeForm,
         label=label,
         validators=validators,
         separator=separator,
         **kwargs
     )
예제 #3
0
 def __init__(self, label=None, validators=None, separator='-', **kwargs):
     FormField.__init__(
         self,
         datetime_form(kwargs.pop('datetime_form', {})),
         label=label,
         validators=validators,
         separator=separator,
         **kwargs
     )
예제 #4
0
 def process(self, formdata, data=_unset_value):
     if data is _unset_value:
         try:
             data = self.default()
         except TypeError:
             data = self.default
     if data:
         obj = Date()
         obj.date = data.date()
         obj.time = data.time()
     else:
         obj = None
     FormField.process(self, formdata, data=obj)
예제 #5
0
    def populate_obj(self, obj, name):
        if has_identity(obj):
            sess = session(obj)
            item = getattr(obj, name, None)
            if item:
                # only delete persistent objects
                if has_identity(item):
                    sess.delete(item)
                elif item in sess:
                    sess.expunge(item)
                setattr(obj, name, None)

        if self.data:
            setattr(obj, name, self.form.Meta.model())

        FormField.populate_obj(self, obj, name)
예제 #6
0
파일: forms.py 프로젝트: pyeu/maps4all
class DetermineOptionsForm(Form):
    navigation = FormField(NavigationForm)
예제 #7
0
        class EventForm(ModelForm):
            class Meta:
                model = self.Event

            locations = ModelFieldList(FormField(LocationForm),
                                       population_strategy='update')
예제 #8
0
파일: forms.py 프로젝트: pyeu/maps4all
class RequiredOptionDescriptorMissingForm(Form):
    resources = FieldList(SelectMultipleField(validators=[InputRequired()]))
    navigation = FormField(NavigationForm)
예제 #9
0
 class TemplateForm(AddTemplateForm):
     body = FormField(TemplateBodyFieldForm)
     base_template = SelectField('Base Template',
                                 choices=fix_choices(
                                     BaseConfig.BASE_TEMPLATE_FILES))
예제 #10
0
 class StaticBlockForm(form):
     content = FormField(TextEditorFieldForm, '_')
예제 #11
0
파일: forms.py 프로젝트: raylite/auto_label
class PublicationsForm(FlaskForm):
    title = StringField('Publications', render_kw={'readonly': True})
    articles = FieldList(FormField(ArticleForm))  #
예제 #12
0
파일: form.py 프로젝트: ccianos/wazo-ui
class GroupForm(BaseForm):
    name = StringField(l_('Name'), validators=[InputRequired()])
    members = FormField(MembersForm)
    tenant_uuid = SelectField(l_('Tenant'), choices=[])
    tenant = FormField(TenantUuidForm)
    submit = SubmitField()
예제 #13
0
 class ListForm(SubForm):
     entry = FieldList(FormField(MapForm),
                       min_entries=min_entries,
                       max_entries=max_entries)
     upload = FileField(upload_label)
예제 #14
0
class QuestionForm(Form):
    prompts = FieldList(FormField(PromptForm),
                        label='Questions',
                        min_entries=1)
    submit = SubmitField('Submit')
예제 #15
0
class MembersForm(BaseForm):
    user_uuids = SelectMultipleField(l_('Members'), choices=[])
    users = FieldList(FormField(UserForm))
예제 #16
0
class Laborator(ModelFormMeta):
    class Meta:
        model = LaboratorForm

    Students = ModelFieldList(FormField(StudentForm))
예제 #17
0
class IvrForm(BaseForm):
    name = StringField(l_('Name'),
                       validators=[InputRequired(),
                                   Length(max=128)])
    abort_destination = DestinationField(
        destination_label=l_('Abort destination'),
        description=l_(
            'The destination to redirect the caller to when the maximum number of tries is reached.\
                        If not set, the call will be hanged up after playing the abort sound (if set)'
        ))
    abort_sound = SelectField(
        l_('Abort sound'),
        choices=[],
        validators=[Length(max=255)],
        description=l_(
            'The sound played when the caller reach the maximum number of tries.\
                        Not used if an abort destination is set'))
    choices = FieldList(FormField(IvrChoiceForm))
    description = StringField(l_('Description'))
    greeting_sound = SelectField(
        l_('Greeting sound'),
        choices=[],
        validators=[Length(max=255)],
        description=l_('The sound played to greet the caller'))
    invalid_destination = DestinationField(
        destination_label=l_('Invalid destination'),
        description=l_(
            'The destination to redirect the caller to when he choose an invalid option.\
                        If not set, the menu will be replayed'))
    invalid_sound = SelectField(
        l_('Invalid Sound'),
        choices=[],
        validators=[Length(max=255)],
        description=l_(
            'The sound played when the caller choose an invalid option.\
                        Not used if an invalid destination is set'))
    max_tries = IntegerField(
        l_('Max tries'),
        default=3,
        validators=[NumberRange(min=1)],
        description=l_('The maximum number of tries before aborting the call.\
                        Both a timeout and an invalid choice counts toward the number of tries integer Default:3'
                       ))
    menu_sound = SelectField(
        l_('Menu Sound'),
        choices=[],
        validators=[Length(max=255)],
        description=l_('The sound played to prompt the caller for input'))
    timeout = IntegerField(
        l_('Timeout'),
        default=5,
        validators=[NumberRange(min=0)],
        description=l_(
            'Number of seconds to wait after the menu sound is played before either replaying the menu,\
                        redirecting the call to the timeout destination (if set) or aborting the call\
                        (if the maximum number of tries has been reached) integer Default:5'
        ))
    timeout_destination = DestinationField(
        destination_label=l_('Timeout destination'),
        description=l_(
            'The destination to redirect the caller to on timeout. If not set, the menu will be replayed'
        ))
    submit = SubmitField(l_('Submit'))

    def to_dict(self):
        data = super().to_dict()

        for field in [
                'abort_destination', 'invalid_destination',
                'timeout_destination'
        ]:
            if data.get(field, {}).get('type') == 'none':
                data[field] = None
        return data
예제 #18
0
class ConfigurationForm(BaseForm):
    general_config = FormField(GeneralConfigurationForm)
    network_config = FormField(NetworkConfigurationForm)
    submit = SubmitField(l_('Submit'))
예제 #19
0
        class EventForm(ModelForm):
            class Meta:
                model = self.Event

            locations = ModelFieldList(FormField(LocationForm))
예제 #20
0
 class Outside(Form):
     subforms = FieldList(FormField(Inside, separator="_"), min_entries=1)
예제 #21
0
 def setUp(self):
     F = make_form(
         a=StringField(validators=[validators.DataRequired()]), b=StringField()
     )
     self.F1 = make_form("F1", a=FormField(F))
     self.F2 = make_form("F2", a=FormField(F, separator="::"))
예제 #22
0
 class Outside(Form):
     subforms = FieldList(FormField(Inside), min_entries=1)
예제 #23
0
 class A(Form):
     a = FormField(self.F1, validators=[validators.DataRequired()])
예제 #24
0
class ShippingForm(FlaskForm):
    name = TextField('Name', [InputRequired()])
    email = EmailField('Email', [InputRequired(), Email()])
    address = FormField(AddressForm)
예제 #25
0
class UserForwardForm(BaseForm):
    busy = FormField(BusyForwardForm)
    noanswer = FormField(NoAnswerForwardForm)
    unconditional = FormField(UnconditionalForwardForm)
예제 #26
0
파일: form.py 프로젝트: ccianos/wazo-ui
class TenantForm(BaseForm):
    name = StringField(l_('Name'), validators=[InputRequired()])
    members = FormField(MembersForm)
    submit = SubmitField()
예제 #27
0
class AddResource(ModelForm):
    class Meta:
        model = Resource
        #recaptcha = RecaptchaField()
    tags = TextField(FormField(AddTag))
예제 #28
0
 class TemplateForm(form):
     body = FormField(TemplateBodyFieldForm, separator='_')
예제 #29
0
파일: forms.py 프로젝트: pyeu/maps4all
class DetermineRequiredOptionDescriptorForm(Form):
    required_option_descriptor = SelectField('Required Option Descriptor',
                                             validators=[InputRequired()])
    navigation = FormField(NavigationForm)
예제 #30
0
class UploadEntriesForm(FlaskForm):

    upload_entries = FieldList(FormField(UploadForm),
                               min_entries=0,
                               max_entries=3)
예제 #31
0
class UserServiceForm(BaseForm):
    dnd = FormField(DNDServiceForm)
    incallfilter = FormField(IncallFilterServiceForm)
예제 #32
0
 class B(Form):
     a = FormField(self.F1, filters=[lambda x: x])
예제 #33
0
class EnquiryAddForm(FlaskForm):
    uid = SelectField(_('enquiry user'),
                      validators=[
                          DataRequired(),
                      ],
                      coerce=int,
                      description=_('enquiry user'),
                      render_kw={
                          'rel': 'tooltip',
                          'title': _('enquiry user'),
                      })
    supplier_cid = IntegerField(_('supplier company id'),
                                validators=[
                                    DataRequired(),
                                ],
                                default=0,
                                description=_('supplier company id'),
                                render_kw={
                                    'rel': 'tooltip',
                                    'title': _('supplier company id'),
                                    'placeholder': _('supplier company id'),
                                    'autocomplete': 'off',
                                    'type': 'hidden',
                                })
    supplier_company_name = StringField(_('supplier company name'),
                                        validators=[],
                                        description=_('supplier company name'),
                                        render_kw={
                                            'placeholder':
                                            _('supplier company name'),
                                            'rel':
                                            'tooltip',
                                            'title':
                                            _('supplier company name'),
                                        })
    supplier_contact_id = IntegerField(_('supplier contact id'),
                                       validators=[
                                           DataRequired(),
                                       ],
                                       default=0,
                                       description=_('supplier contact id'),
                                       render_kw={
                                           'rel': 'tooltip',
                                           'title': _('supplier contact id'),
                                           'type': 'hidden',
                                       })
    supplier_contact_name = StringField(_('supplier contact name'),
                                        validators=[],
                                        description=_('supplier contact name'),
                                        render_kw={
                                            'placeholder':
                                            _('supplier contact name'),
                                            'rel':
                                            'tooltip',
                                            'title':
                                            _('supplier contact name'),
                                        })
    delivery_way = StringField(_('delivery way'),
                               validators=[],
                               description=_('delivery way'),
                               render_kw={
                                   'placeholder': _('delivery way'),
                                   'rel': 'tooltip',
                                   'title': _('delivery way'),
                               })
    note = StringField(_('enquiry note'),
                       validators=[],
                       description=_('enquiry note'),
                       render_kw={
                           'placeholder': _('enquiry note'),
                           'rel': 'tooltip',
                           'title': _('enquiry note'),
                       })
    status_order = SelectField(_('order status'),
                               validators=[
                                   InputRequired(),
                               ],
                               coerce=int,
                               description=_('order status'),
                               render_kw={
                                   'rel': 'tooltip',
                                   'title': _('order status'),
                               })
    amount_enquiry = DecimalField(_('amount enquiry'),
                                  validators=[AmountEnquiryValidate()],
                                  description=_('amount enquiry'),
                                  render_kw={
                                      'placeholder': _('amount enquiry'),
                                      'rel': 'tooltip',
                                      'title': _('amount enquiry'),
                                      'type': 'number',
                                      'disabled': 'disabled',
                                  })
    data_line_add = IntegerField(
        '数据行新增',
        validators=[],
    )
    data_line_del = IntegerField(
        '数据行删除',
        validators=[],
    )
    enquiry_items = FieldList(
        FormField(EnquiryItemAddForm),
        label='报价明细',
        min_entries=1,
        max_entries=12,
    )
예제 #34
0
        class C(Form):
            a = FormField(self.F1)

            def validate_a(self, field):
                pass
예제 #35
0
class CpdActivityEntriesForm(FlaskForm):

    cpd_activity_entries = FieldList(FormField(CpdActivityEntryForm),
                                     min_entries=0)