Ejemplo n.º 1
0
class OtherForm(Form):
    other_document_type = StringField(validators=[InputRequired()])
    other_title = StringField(validators=[InputRequired()])
    other_author_first_name = FieldList(
        StringField(), min_entries=1
    )
    other_author_last_name = FieldList(
        StringField(), min_entries=1
    )
    other_publication_day = IntegerField(validators=[validators.optional()])
    other_publication_month = SelectField(choices=[
        ('', ''), ('January', 'January'), ('February', 'February'),
        ('March', 'March'), ('April', 'April'), ('May', 'May'),
        ('June', 'June'), ('July', 'July'), ('August', 'August'),
        ('September', 'September'), ('October', 'October'),
        ('November', 'November'), ('December', 'December')
    ])
    other_source = StringField(validators=[InputRequired()])
    other_publication_year = IntegerField(validators=[InputRequired()])
    other_description = TextAreaField(validators=[InputRequired()])
    other_tags = SelectMultipleField(choices=[('', '')])
    other_link = StringField()
    other_file_urls = FileUploadField()
    save_other = SubmitField()
    submit_other = SubmitField()

    def __init__(self, **kwargs):
        super(OtherForm, self).__init__(**kwargs)
        self.other_tags.choices = [(str(t.id), t.tag) for t in Tag.query.all()]
        self.other_tags.default = kwargs.get('other_tags')
Ejemplo n.º 2
0
class ScheduleForm(BaseForm):
    name = StringField(l_('Name'), validators=[InputRequired()])
    timezone = SelectField(l_('Timezone'), choices=list_timezones())
    closed_destination = DestinationField()
    exceptional_periods = FieldList(FormField(ScheduleExceptionalPeriodForm))
    open_periods = FieldList(FormField(ScheduleOpenPeriodForm))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 3
0
class UserForm(BaseForm):
    subscription_type = SelectField(l_('Subscription Type'), choices=[
        (0, l_('Voice')),
        (1, l_('Unified Communication')),
        (2, l_('Collaboration')),
        (3, l_('Customer Relationship')),
    ], validators=[InputRequired()])
    firstname = StringField(l_('Firstname'), [InputRequired(), Length(max=128)])
    lastname = StringField(l_('Lastname'), [Length(max=128)])
    username = StringField(l_('Username'), [InputRequired(), Length(min=2, max=254)])
    password = StringField(l_('Password'), [Length(min=4, max=64)])
    email = EmailField(l_('Email'), [InputRequired(), Length(max=254)])
    auth_enabled = BooleanField(l_('Enable authentication'))
    caller_id = StringField(l_('Caller ID'), [Length(max=80)])
    mobile_phone_number = StringField(l_('Phone mobile'), [Length(max=80)])
    ring_seconds = IntegerField(l_('Ring seconds'), [NumberRange(min=0, max=60)])
    music_on_hold = SelectField(l_('Music On Hold'), choices=[])
    preprocess_subroutine = StringField(l_('Subroutine'), [Length(max=39)])
    outgoing_caller_id = SelectField(l_('Outgoing caller ID'))
    simultaneous_calls = IntegerField(l_('Simultaneous calls'), [NumberRange(min=1, max=20)])
    timezone = StringField(l_('Timezone'), [Length(max=254)])
    userfield = StringField(l_('User Field'), [Length(max=128)])
    description = StringField(l_('Description'))
    fallbacks = FormField(FallbacksForm)
    forwards = FormField(UserForwardForm)
    services = FormField(UserServiceForm)
    lines = FieldList(FormField(LineForm))
    group_ids = SelectMultipleField(l_('Groups'), choices=[])
    groups = FieldList(FormField(GroupForm))
    funckeys = FieldList(FormField(FuncKeyTemplateKeysForm))
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    voicemail = FormField(VoicemailForm)
    call_permission_ids = SelectMultipleField(l_('Call Permissions'), choices=[])
    call_permissions = FieldList(FormField(CallPermissionForm))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 4
0
    def populate_obj(self, obj, name):
        model = self.unbound_field.args[0].Meta.model
        state = obj._sa_instance_state

        if not state.identity or self.population_strategy == 'replace':
            setattr(obj, name, [])
            for counter in xrange(len(self.entries)):
                try:
                    self.pre_append_object(obj, name, counter)
                    try:
                        getattr(obj, name).append(model())
                    except AttributeError:
                        pass
                except SkipOperation:
                    pass
        else:

            for index, entry in enumerate(self.entries):
                data = entry.data
                try:
                    if not has_entity(obj, name, model, data):
                        getattr(obj, name).insert(index, model())
                except UnknownIdentityException:
                    # we should skip all entries which are not part of obj
                    # collection
                    self.entries.pop(index)

        FieldList.populate_obj(self, obj, name)
Ejemplo n.º 5
0
class GroupForm(BaseForm):
    name = StringField(l_('Name'), [InputRequired(), Length(max=128)])
    extensions = FieldList(FormField(ExtensionForm), min_entries=1)
    caller_id_mode = SelectField(l_('Callerid mode'),
                                 choices=[('', l_('None')),
                                          ('prepend', l_('Prepend')),
                                          ('overwrite', l_('Overwrite')),
                                          ('append', l_('Append'))])
    caller_id_name = StringField('Callerid name', [Length(max=80)])
    enabled = BooleanField(l_('Enabled'))
    music_on_hold = SelectField('Music On Hold', [Length(max=128)], choices=[])
    preprocess_subroutine = StringField(l_('Subroutine'), [Length(max=39)])
    retry_delay = IntegerField('Retry delay', [NumberRange(min=0)])
    ring_in_use = BooleanField('Ring in use')
    ring_strategy = SelectField('Ring strategy',
                                choices=[('all', l_('All')),
                                         ('random', l_('Random')),
                                         ('least_recent', l_('Least recent')),
                                         ('linear', l_('Linear')),
                                         ('fewest_calls', l_('Fewest calls')),
                                         ('memorized_round_robin',
                                          l_('Memorized round robin')),
                                         ('weight_random', l_('Weight random'))
                                         ])
    timeout = IntegerField(l_('Timeout'), [NumberRange(min=0)])
    user_timeout = IntegerField(l_('User timeout'), [NumberRange(min=0)])
    members = FormField(MembersForm)
    fallbacks = FormField(FallbacksForm)
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    call_permission_ids = SelectMultipleField(l_('Call Permissions'),
                                              choices=[])
    call_permissions = FieldList(FormField(CallPermissionForm))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 6
0
class MentorForm(Form):
    firebase_uid = StringField(validators=[InputRequired()])
    name = StringField(validators=[InputRequired()])
    professional_title = StringField(validators=[InputRequired()])
    languages = FieldList(StringField(), validators=[validators.required()])
    specializations = FieldList(StringField(),
                                validators=[validators.required()])
Ejemplo n.º 7
0
class MembersForm(BaseForm):
    user_uuids = SelectMultipleField(l_('Members'), choices=[])
    users = FieldList(FormField(UserUuidForm))
    group_uuids = SelectMultipleField(l_('Groups'), choices=[])
    groups = FieldList(FormField(GroupUuidForm))
    policy_uuids = SelectMultipleField(l_('Policies'), choices=[])
    policies = FieldList(FormField(PolicyUuidForm))
Ejemplo n.º 8
0
    def populate_obj(self, obj, name):
        model = self.unbound_field.args[0].Meta.model
        state = obj._sa_instance_state

        if not state.identity or self.population_strategy == 'replace':
            setattr(obj, name, [])
            for counter in xrange(len(self.entries)):
                try:
                    self.pre_append_object(obj, name, counter)
                    try:
                        getattr(obj, name).append(model())
                    except AttributeError:
                        pass
                except SkipOperation:
                    pass
        else:

            for index, entry in enumerate(self.entries):
                data = entry.data
                try:
                    if not has_entity(obj, name, model, data):
                        getattr(obj, name).insert(index, model())
                except UnknownIdentityException:
                    # we should skip all entries which are not part of obj
                    # collection
                    self.entries.pop(index)

        FieldList.populate_obj(self, obj, name)
Ejemplo n.º 9
0
class ProfileForm(Form):
    company_name = StringField("name", validators=[Length(min=2, max=100)])
    physical_address = StringField(validators=[Length(min=1, max=100)])
    postal_address = StringField(validators=[Length(min=1, max=100)])
    association_membership = StringField(validators=[Length(min=0, max=100)])
    bank_name = StringField(validators=[Length(min=0, max=100)])
    bank_account = StringField(validators=[Length(min=0, max=100)])
    swift_code = StringField(validators=[Length(min=0, max=100)])
    director = StringField(validators=[Length(min=0, max=100)])
    director_phone = StringField(validators=[Length(min=0, max=100)])
    director_email = StringField(validators=[Length(min=0, max=100)])
    overview = TextAreaField(validators=[Length(min=2, max=2000)])
    phones = FieldList(FormField(PhoneForm), min_entries=1)
    emails = FieldList(FormField(EmailForm), min_entries=1)
    locations = FieldList(FormField(LocationForm), min_entries=1)
    terms_of_use = BooleanField(validators=[DataRequired()], id="terms_of_use")
    operator_licence = FileField(
        validators=[
            FileAllowed(photos, u"Image Only!"),
            FileRequired(u"Choose a file!"),
        ]
    )
    reg_certificate = FileField(
        validators=[
            FileAllowed(photos, u"Image Only!"),
            FileRequired(u"Choose a file!"),
        ]
    )
    tax_registration = FileField(
        validators=[
            FileAllowed(photos, u"Image Only!"),
            FileRequired(u"Choose a file!"),
        ]
    )
Ejemplo n.º 10
0
class UserForm(BaseForm):
    firstname = StringField(l_('Firstname'), [InputRequired(), Length(max=128)])
    lastname = StringField(l_('Lastname'), [Length(max=128)])
    username = StringField(l_('Username'), [InputRequired(), Length(min=2, max=254)])
    password = StringField(l_('Password'), [Length(min=4, max=64)])
    email = EmailField(l_('Email'), [Length(max=254)])
    caller_id = StringField(l_('Caller ID'), [Length(max=80)])
    mobile_phone_number = StringField(l_('Phone mobile'), [Length(max=80)])
    ring_seconds = IntegerField(l_('Ring seconds'), [NumberRange(min=0, max=60)])
    music_on_hold = SelectField(l_('Music On Hold'), choices=[])
    preprocess_subroutine = StringField(l_('Subroutine'), [Length(max=39)])
    simultaneous_calls = IntegerField(l_('Simultaneous calls'), [NumberRange(min=1, max=20)])
    timezone = StringField(l_('Timezone'), [Length(max=254)])
    userfield = StringField(l_('User Field'), [Length(max=128)])
    description = StringField(l_('Description'))
    fallbacks = FormField(FallbacksForm)
    forwards = FormField(UserForwardForm)
    services = FormField(UserServiceForm)
    lines = FieldList(FormField(LineForm))
    cti_profile = FormField(CtiProfileForm)
    group_ids = SelectMultipleField(l_('Groups'), choices=[])
    groups = FieldList(FormField(GroupForm))
    funckeys = FieldList(FormField(FuncKeyTemplateKeysForm))
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    voicemail = FormField(VoicemailForm)
    call_permission_ids = SelectMultipleField(l_('Call Permissions'), choices=[])
    call_permissions = FieldList(FormField(CallPermissionForm))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 11
0
class JournalArticleForm(Form):
    journal_title = StringField(validators=[InputRequired()])
    journal_author_first_name = FieldList(
        StringField(validators=[InputRequired()]), min_entries=1
    )
    journal_author_last_name = FieldList(
        StringField(validators=[InputRequired()]), min_entries=1
    )
    journal_publication = StringField(validators=[InputRequired()])
    journal_volume = StringField()
    journal_issue = StringField()
    journal_start_page = StringField()
    journal_end_page = StringField()
    journal_publication_day = IntegerField(validators=[validators.optional()])
    journal_publication_month = SelectField(choices=[
        ('', ''), ('January', 'January'), ('February', 'February'),
        ('March', 'March'), ('April', 'April'), ('May', 'May'),
        ('June', 'June'), ('July', 'July'), ('August', 'August'),
        ('September', 'September'), ('October', 'October'),
        ('November', 'November'), ('December', 'December')
    ])
    journal_publication_year = IntegerField(validators=[InputRequired()])
    journal_description = TextAreaField(validators=[InputRequired()])
    journal_tags = SelectMultipleField(choices=[('', '')])
    journal_link = StringField()
    journal_file_urls = FileUploadField()
    save_journal = SubmitField()
    submit_journal = SubmitField()

    def __init__(self, **kwargs):
        super(JournalArticleForm, self).__init__(**kwargs)
        self.journal_tags.choices = [
            (str(t.id), t.tag) for t in Tag.query.all()
        ]
        self.journal_tags.default = kwargs.get('journal_tags')
Ejemplo n.º 12
0
class JobNewForm(Form):

    platform = StringField("Platform", [validators.Length(min=2, max=64)])

    title = StringField("Title", [validators.Length(min=2, max=256)])
    body = TextField("Body", [validators.Length(min=2)])
    body_markup = SelectField("Body Markup",
                              choices=MARKUP_CHOICES,
                              validators=[validators.optional()],
                              default="text")

    url = StringField("URL", [validators.Length(min=6)])
    sid = StringField("Source ID", [validators.Length(min=2, max=128)])

    price = IntegerField("Price")
    status = StringField("Status", [validators.Length(max=64)])

    city = FieldList(StringField("City List"))
    category = FieldList(
        StringField("Category List", [validators.Length(max=128)]))
    role = FieldList(StringField("Role List", [validators.Length(max=128)]))
    skill = FieldList(StringField("Skill List", [validators.Length(max=128)]))

    # TODO: 校验 UTC string
    release_date = StringField(_("Release Date"), [validators.Required()])
    expire_date = StringField(_("Expire Date"))
Ejemplo n.º 13
0
class ListingForms(Form):
    location = SelectField(validators=[DataRequired()], choices=[], id="list-location")
    price_type_id = SelectField(
        validators=[DataRequired()], choices=[], coerce=int, id="list-package"
    )
    package = SelectField(
        validators=[DataRequired()],
        choices=[("Budget", "Budget"), ("Luxury", "Luxury")],
    )
    duration = StringField("duration", validators=[Length(min=2, max=80)])
    availability_from = DateField("availability_from", format="%d/%m/%Y")
    availability_to = DateField("availability_to", format="%d/%m/%Y")
    categories = SelectMultipleField(
        validators=[DataRequired()], choices=[], coerce=int
    )
    long_description = TextAreaField(
        "long description", validators=[Length(min=20, max=2000)]
    )
    activities = FieldList(FormField(ActivityForm), min_entries=1)
    places = FieldList(FormField(PlaceForm), min_entries=1)
    days = FieldList(FormField(DayForm), min_entries=1)
    images = FieldList(FormField(ImageForm), min_entries=1)
    physical_condition = StringField(
        "physical condition", validators=[Length(min=2, max=80)]
    )
    connectivity = StringField("Connectivity", validators=[Length(min=2, max=80)])
    add_ons = TextAreaField("long description", validators=[Length(min=0, max=2000)])
    policy = TextAreaField("policy", validators=[Length(min=2, max=2000)])
    submit = SubmitField("save")
Ejemplo n.º 14
0
 def process(self, formdata, data=unset_value):
     if not(data is unset_value or not data):
         res = []
         for lang in self.langs:
             res.append(data.get_lang(lang))
         FieldList.process(self, formdata, data=res)
     else:
         FieldList.process(self, formdata, data=data)
Ejemplo n.º 15
0
class CsvForm(BaseForm):
    first_matched_columns = FieldList(FormField(ColumnsForm))
    format_columns = FieldList(FormField(ValueColumnsForm))
    searched_columns = FieldList(FormField(ColumnsForm))
    # `separator` can't be used an a field for wtforms ...
    delimiter = StringField(l_('Delimiter'))
    file = StringField(l_('File'), validators=[InputRequired()])
    unique_column = StringField(l_('Unique column'))
class OdooForm(BaseForm):
    first_matched_columns = FieldList(FormField(ColumnsForm))
    format_columns = FieldList(FormField(ValueColumnsForm))
    searched_columns = FieldList(FormField(ColumnsForm))
    server = StringField(l_('Server'))
    port = StringField(l_('Port'))
    userid = StringField(l_('UserID'))
    password = StringField(l_('Password'))
    database = StringField(l_('Database'))
Ejemplo n.º 17
0
class TargetsForm(BaseForm):
    user_uuids = SelectMultipleField(l_('Target Users'),
                                     choices=[],
                                     default=[])
    users = FieldList(FormField(UserForm))
    group_ids = SelectMultipleField(l_('Target Groups'),
                                    choices=[],
                                    default=[])
    groups = FieldList(FormField(GroupForm))
Ejemplo n.º 18
0
class InterceptorsForm(BaseForm):
    user_uuids = SelectMultipleField(l_('Interceptor Users'),
                                     choices=[],
                                     default=[])
    users = FieldList(FormField(UserForm))
    group_ids = SelectMultipleField(l_('Interceptor Groups'),
                                    choices=[],
                                    default=[])
    groups = FieldList(FormField(GroupForm))
Ejemplo n.º 19
0
class DeployForm(FlaskForm):
    name = StringField('App Name', validators=[InputRequired(), validate_name])
    image = StringField('Image', validators=[InputRequired()])
    ports = FieldList(FormField(_PortForm))
    volumes = FieldList(FormField(_VolumeForm))
    env = FieldList(FormField(_EnvForm))
    sysctls = FieldList(FormField(_SysctlsForm), min_entries=1)
    restart_policy = StringField('Restart Policy')
    submit = SubmitField('Deploy App')
Ejemplo n.º 20
0
class QueueForm(BaseForm):
    name = StringField(l_('Name'), [InputRequired(), Length(max=128)])
    label = StringField(l_('Label'), [InputRequired(), Length(max=128)])

    announce_hold_time_on_entry = BooleanField(
        l_('Announce hold time on entry'), default=False)
    music_on_hold = SelectField(l_('Music On Hold'), [Length(max=128)],
                                choices=[])
    data_quality = BooleanField(l_('Data quality'), default=False)
    caller_id_mode = SelectField(l_('Caller ID mode'),
                                 choices=[('', l_('None')),
                                          ('prepend', l_('Prepend')),
                                          ('overwrite', l_('Overwrite')),
                                          ('append', l_('Append'))])
    caller_id_name = StringField(l_('Caller ID name'), [Length(max=80)])

    dtmf_hangup_callee_enabled = BooleanField(l_('DTMF hangup callee enabled'),
                                              default=False)
    dtmf_hangup_caller_enabled = BooleanField(l_('DTMF hangup caller enabled'),
                                              default=False)
    dtmf_record_callee_enabled = BooleanField(l_('DTMF record callee enabled'),
                                              default=False)
    dtmf_record_caller_enabled = BooleanField(l_('DTMF record caller enabled'),
                                              default=False)
    dtmf_transfer_callee_enabled = BooleanField(
        l_('DTMF transfer callee enabled'), default=False)
    dtmf_transfer_caller_enabled = BooleanField(
        l_('DTMF transfer caller enabled'), default=False)

    ignore_forward = BooleanField(l_('Ignore forward'), default=False)
    preprocess_subroutine = StringField(l_('Subroutine'), [Length(max=39)])
    retry_on_timeout = BooleanField(l_('Retry on timeout'), default=False)
    ring_on_hold = BooleanField(l_('Ring on hold'), default=False)
    timeout = IntegerField(l_('Timeout'), [NumberRange(min=0)])

    wait_ratio_destination = DestinationField(
        destination_label=l_('Wait ratio destination'))
    wait_ratio_threshold = FloatField(l_('Wait ratio threshold'),
                                      [NumberRange(min=0)])
    wait_time_destination = DestinationField(
        destination_label=l_('Wait time destination'))
    wait_time_threshold = IntegerField(l_('Wait time threshold'),
                                       [NumberRange(min=0)])

    extensions = FieldList(FormField(ExtensionForm), min_entries=1)
    fallbacks = FormField(FallbacksForm)
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    options = FieldList(FormField(OptionsForm))

    enabled = BooleanField(l_('Enabled'), default=False)
    members = FormField(MembersForm)
    mark_answered_elsewhere = BooleanField(
        l_('Mark all calls as answered elsewhere when cancelled'),
        default=False)

    submit = SubmitField(l_('Submit'))
Ejemplo n.º 21
0
class ExtrasForm(Form):
    long_description = TextAreaField(
        "long description", validators=[Length(min=20, max=2000)]
    )
    activities = FieldList(
        FormField(ActivityForm, default=lambda: Activity()), min_entries=1
    )
    places = FieldList(FormField(PlaceForm, default=lambda: Place()), min_entries=1)
    days = FieldList(FormField(DayForm, default=lambda: Day()), min_entries=1)
    add_ons = TextAreaField("long description", validators=[Length(min=0, max=2000)])
Ejemplo n.º 22
0
class CsvWsForm(BaseForm):
    first_matched_columns = FieldList(FormField(ColumnsForm))
    format_columns = FieldList(FormField(ValueColumnsForm))
    searched_columns = FieldList(FormField(ColumnsForm))
    # `separator` can't be used an a field for wtforms ...
    delimiter = StringField(l_('Delimiter'))
    list_url = StringField(l_('List URL'))
    lookup_url = StringField(l_('Lookup URL'), validators=[InputRequired()])
    timeout = FloatField(l_('Timeout'))
    unique_column = StringField(l_('Unique column'))
Ejemplo n.º 23
0
 def __init__(self, unbound_field, label=None, validators=None, min_entries=0,
              max_entries=None, default=tuple(), **kwargs):
     self.langs = current_app.config.get("SHELF_I18N_COUNTRIES", ("en", "fr"))
     if "allow_blank" in kwargs:
         del kwargs["allow_blank"]
     FieldList.__init__(self, unbound_field, label, validators, 
             len(self.langs), 
             len(self.langs), 
             default, 
             **kwargs)
Ejemplo n.º 24
0
class LdapForm(BaseForm):
    first_matched_columns = FieldList(FormField(ColumnsForm))
    format_columns = FieldList(FormField(ValueColumnsForm))
    ldap_base_dn = StringField(l_('Base DN'), validators=[InputRequired()], default='ou=people,dc=example,dc=com')
    custom_filter = StringField(l_('Custom filter'))
    ldap_password = StringField(l_('Password'), widget=PasswordInput(hide_value=False))
    ldap_uri = StringField(l_('Uri'), validators=[InputRequired()])
    ldap_username = StringField(l_('Username'), validators=[InputRequired()], default='cn=admin,dc=example,dc=org')
    searched_columns = FieldList(FormField(ColumnsForm))
    unique_column = StringField(l_('Unique column'))
    unique_column_format = SelectField('Unique column format', choices=column_formats)
Ejemplo n.º 25
0
class MultiCharpyTestsForm(FlaskForm):
    class Meta:
        csrf = False

    title = "Charpy Test Data"
    test_code = FieldList(StringField("Testing Standard"), min_entries=1)
    charpy_tests = FieldList(FormField(CharpyDataForm), min_entries=1)
    charpy_units = RadioField("Charpy Energy Units",
                              choices=[("J", "J"), ("ftlbs", "ft-lbs")],
                              validators=[DataRequired()])
    temp_units = RadioField("Temperature Units",
                            choices=[("C", "°C"), ("F", "°F")],
                            validators=[Optional()])
Ejemplo n.º 26
0
class IncallForm(BaseForm):
    extensions = FieldList(FormField(ExtensionForm), min_entries=1)
    destination = DestinationField()
    preprocess_subroutine = StringField(l_('Preprocess Subroutine'), [Length(max=39)])
    caller_id_mode = SelectField(l_('Caller ID mode'), choices=[
        ('', l_('None')),
        ('prepend', l_('Prepend')),
        ('overwrite', l_('Overwrite')),
        ('append', l_('Append'))
    ])
    caller_id_name = StringField(l_('Caller ID name'), [Length(max=80)])
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 27
0
    def populate_obj(self, obj, name):
        self.delete_existing(obj, name)

        model = self.unbound_field.args[0].Meta.model
        for counter in xrange(len(self.entries)):
            try:
                self.pre_append_object(obj, name, counter)
                try:
                    getattr(obj, name).append(model())
                except AttributeError:
                    pass
            except SkipOperation:
                pass
        FieldList.populate_obj(self, obj, name)
Ejemplo n.º 28
0
class CallPermissionForm(BaseForm):
    name = StringField(l_('Name'), validators=[InputRequired()])
    password = StringField(l_('Password'))
    extensions = FieldList(FormField(ExtensionsForm))
    mode = SelectField(l_('Mode'), choices=[(k, v) for k, v in mode_map.items()])
    user_uuids = SelectMultipleField(l_('Users'), choices=[])
    users = FieldList(FormField(UserForm))
    group_ids = SelectMultipleField(l_('Groups'), choices=[])
    groups = FieldList(FormField(GroupForm))
    outcall_ids = SelectMultipleField(l_('Outcalls'), choices=[])
    outcalls = FieldList(FormField(OutcallForm))
    description = StringField(l_('Description'))
    enabled = BooleanField(l_('Enabled'))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 29
0
class CreateProductionOrderForm(Form):
    user = StringField(label='Ordered By',
                       validators=[InputRequired(), user_auth_check])
    rdate = DateInputField(label='Date')
    prod_order_title = StringField(
        label='Title', validators=[InputRequired(),
                                   Length(max=50)])
    desc = StringField(label='Description', validators=[InputRequired()])
    root_order_sno = StringField(label='Root Order', validators=[Optional()])
    prod_order_sno = FormField(NewSerialNumberForm)

    production_type = SelectField(
        label='Type',
        validators=[InputRequired()],
        choices=[("production", "Production"), ("prototype", "Prototype"),
                 ("testing", "Testing"), ("support", "Support"),
                 ("rd", "Research & Development")],
    )

    modules = FieldList(FormField(ModuleQtyForm), min_entries=1)
    deltas = FieldList(FormField(DeltaOrderForm), min_entries=1)
    indents = FormField(IndentGenerationForm)

    def __init__(self, auth_roles=None, admin_roles=None, *args, **kwargs):
        if auth_roles is not None:
            self.auth_roles = auth_roles
        else:
            self.auth_roles = ['exec']
        if admin_roles is not None:
            self.admin_roles = admin_roles
        else:
            self.admin_roles = ['inventory_admin']
        super(CreateProductionOrderForm, self).__init__(*args, **kwargs)
        self._setup_sno_fields()
        self._setup_secure_fields()

    def _setup_sno_fields(self):
        sno_validator = self.prod_order_sno.sno.validators[0]
        sno_validator.series = 'PROD'
        sno_validator.new = True
        if not current_user.has_roles(tuple(self.admin_roles)):
            read_only(self.prod_order_sno.sno_generate)
        read_only(self.prod_order_sno.sno)

    def _setup_secure_fields(self):
        if not self.user.data:
            self.user.data = current_user.full_name
        if not current_user.has_roles(tuple(self.admin_roles)):
            read_only(self.user)
            read_only(self.rdate)
Ejemplo n.º 30
0
class OutcallForm(BaseForm):
    name = StringField(l_('Name'), [InputRequired(), Length(max=128)])
    description = StringField(l_('Description'))
    extensions = FieldList(FormField(OutcallExtensionForm))
    trunks_id = SelectMultipleField(l_('Trunks'), choices=[])
    trunks = FieldList(FormField(TrunkForm))
    preprocess_subroutine = StringField(l_('Preprocess Subroutine'))
    internal_caller_id = BooleanField(l_('Internal Caller ID'))
    ring_time = IntegerField(l_('Ring time'), [NumberRange(min=0)])
    schedules = FieldList(FormField(ScheduleForm), min_entries=1)
    call_permission_ids = SelectMultipleField(l_('Call Permissions'),
                                              choices=[])
    call_permissions = FieldList(FormField(CallPermissionForm))
    submit = SubmitField(l_('Submit'))
Ejemplo n.º 31
0
class SettingsForm(FlaskForm):
    targets = SelectField(label="Select target", choices=[])
    skip_tree = BooleanField(
        label=(
            "Skip the core gene alignment and tree for visualization "
            "and troubleshooting"),
        default=False)
    work_offline = BooleanField(
            "Work offline with local genome assemblies", default=False)
    skip_download = BooleanField(
            "Skip the download of Genomes from NCBI", default=False)
    assemblylevel = SelectMultipleField(
        "Assembly level", choices=[
            ('all', "All"),
            ('complete', 'Complete'), ('chromosome', 'Chromosome'),
            ('scaffold', 'Scaffold'), ('contig', 'Contig')],
        validators=[DataRequired()])
    customdb = StringField(
            "Specify the path to a custom BLAST database", default=None)

    nolist = BooleanField(
            label=(
                "Species list is not used and only sequences without blast "
                "hits are used for primer design "),
            default=False)

    blastseqs = SelectField(
            "Maximal number of sequences per BLAST search", coerce=int,
            choices=[
                (100, "100"), (500, "500"), (1000, "1000"),
                (2000, "2000"), (5000, "5000")],
            default=1000)
    qc_gene = SelectMultipleField(
            "Gene(s) for BLAST search in the initial quality control step",
            choices=[
                ('rRNA', "16S rRNA"), ('tuf', "tuf"),
                ('recA', "recA"), ('dnaK', "dnaK"), ('pheS', "pheS")],
            validators=[DataRequired()])
    exception = FieldList(StringField(""), min_entries=1)
    minsize = IntegerField("Minimal Amplicon size", default=70)
    maxsize = IntegerField("Maximal Amplicon size", default=200)
    designprobe = BooleanField("Pick internal hybridization oligo")
    mfold = FloatField(
            "ΔG threshold for secondary structures in PCR products"
            " at 60°C calculated by mfold", default=-3.0)
    mpprimer = FloatField(
            "ΔG  threshold for 3'-end primer dimer binding", default=-3.5)
    mfeprimer_threshold = SelectField(
        "MFEprimer threshold for nontarget sequence PPC", coerce=int,
        choices=[
            (80, "80"), (85, "85"), (90, "90"), (95, "95"), (100, "100")],
        default=90)
    ignore_qc = BooleanField(
            "Include genomes that did not pass quality control")
    blastdbv5 = BooleanField("BLAST DB Version 5")
    intermediate = BooleanField("Do not delete intermediate files")
    change_wd = StringField(
            "Change path of the working directory", default="/primerdesign")
    submit = SubmitField("Submit settings")
    reset = SubmitField("Reset page")
Ejemplo n.º 32
0
class NewFlowForm(FlaskForm):
    '''Form for creating new flows

    Attributes:
        flow_name: Name of the flow
        stage_order: A list of
            :py:class:`~purchasing.conductor.forms.DynamicStageSelectField`
            fields that represent different stages

    Arguments:
        stages: A list of (id, name) values used to build choices
        *args: List of arguments passed to the form's superclass
        **kwargs: List of keyword arguments passed to the form's
            superclass
    '''
    flow_name = TextField(validators=[DataRequired(), validate_unique_name])
    stage_order = FieldList(DynamicStageSelectField(),
                            min_entries=1,
                            validators=[validate_different])

    def __init__(self, stages=[], *args, **kwargs):
        super(NewFlowForm, self).__init__(*args, **kwargs)
        self.stages = stages
        for i in self.stage_order.entries:
            i.choices = self.stages
Ejemplo n.º 33
0
    def test_validators(self):
        def validator(form, field):
            if field.data and field.data[0] == "fail":
                raise ValueError("fail")
            elif len(field.data) > 2:
                raise ValueError("too many")

        F = make_form(a=FieldList(self.t, validators=[validator]))

        # Case 1: length checking validators work as expected.
        fdata = DummyPostData({
            "a-0": ["hello"],
            "a-1": ["bye"],
            "a-2": ["test3"]
        })
        form = F(fdata)
        assert not form.validate()
        assert form.a.errors == ["too many"]

        # Case 2: checking a value within.
        fdata["a-0"] = ["fail"]
        form = F(fdata)
        assert not form.validate()
        assert form.a.errors == ["fail"]

        # Case 3: normal field validator still works
        form = F(DummyPostData({"a-0": [""]}))
        assert not form.validate()
        assert form.a.errors == [["This field is required."]]
Ejemplo n.º 34
0
    def test_form(self):
        F = make_form(a=FieldList(self.t))
        data = ["foo", "hi", "rawr"]
        a = F(a=data).a
        assert a.entries[1].data == "hi"
        assert a.entries[1].name == "a-1"
        assert a.data == data
        assert len(a.entries) == 3

        pdata = DummyPostData({
            "a-0": ["bleh"],
            "a-3": ["yarg"],
            "a-4": [""],
            "a-7": ["mmm"]
        })
        form = F(pdata)
        assert len(form.a.entries) == 4
        assert form.a.data == ["bleh", "yarg", "", "mmm"]
        assert not form.validate()

        form = F(pdata, a=data)
        assert form.a.data == ["bleh", "yarg", "", "mmm"]
        assert not form.validate()

        # Test for formdata precedence
        pdata = DummyPostData({"a-0": ["a"], "a-1": ["b"]})
        form = F(pdata, a=data)
        assert len(form.a.entries) == 2
        assert form.a.data == ["a", "b"]
        assert list(iter(form.a)) == list(form.a.entries)
Ejemplo n.º 35
0
    def populate_obj(self, obj, name):
        state = obj._sa_instance_state

        if not state.identity or self.population_strategy == 'replace':
            setattr(obj, name, [])
            for counter in six.moves.range(len(self.entries)):
                try:
                    getattr(obj, name).append(self.model())
                except AttributeError:
                    pass
        else:
            for index, entry in enumerate(self.entries):
                data = entry.data
                coll = getattr(obj, name)
                if find_entity(coll, self.model, data) is None:
                    coll.insert(index, self.model())
        FieldList.populate_obj(self, obj, name)
Ejemplo n.º 36
0
 def __init__(self, *args, **kwargs):
     FieldList.__init__(self, self._unbound_field, *args, min_entries=2,
         **kwargs)
Ejemplo n.º 37
0
 def _add_entry(self, formdata=None, data=unset_value, index=None):
     return FieldList._add_entry(self, formdata=formdata, data=data, index=index)