コード例 #1
0
class ConfirmationForm(wtf.Form):
    participation_level = wtf.RadioField("Participation Level",
                                         choices=[
                                             ('badges', 'Badges'),
                                             ('instructor-cert',
                                              'Instructor Certified'),
                                             ('for-credit', 'For Credit'),
                                         ])
    accept_terms = wtf.BooleanField("Terms of Use",
                                    validators=[wtf.validators.Required()])
    page = wtf.HiddenField(default="conf")
    book_option = wtf.RadioField(
        "Book Option",
        validators=[wtf.validators.Optional()],
        choices=[
            ('paperback-7th',
             '7th edition paperback (2014, currently $93 new at Amazon, $110 at Pearson)'
             ),
            ('coursesmart',
             '''7th edition e-text from CourseSmart (currently 180-day rental with options to print, $42).
                    International Students, please use <a href=
                    "http://www.coursesmart.co.uk/classroom-assessment-what-teachers-need-to/w-james-popham/dp/9780133492514"
                    target="_blank">CourseSmart UK</a>.'''),
            ('paperback-6th',
             '6th edition paperback (2010, currently $14 used on Amazon)'),
            ('no-book', 'No book (this will make the course very difficult!)'),
        ])
    book_other = wtf.TextField()
    accept_location = wtf.BooleanField("Location", default=True)
コード例 #2
0
ファイル: __init__.py プロジェクト: gsgoncalves/flock
class TopicForm(FlaskForm):
    title = wtf.StringField('Title', [validators.Required()])
    description = wtf.TextAreaField('Description')
    narrative = wtf.TextAreaField('Narrative')

    difficulty = wtf.RadioField(
        'How easy was it to develop this topic?',
        [validators.Optional()],
        choices=[('easy', 'Easy'), ('moderate', 'Moderate'),
                 ('difficult', 'Difficult')],
    )
    familiarity = wtf.RadioField(
        'How familiar are you with the topic?',
        [validators.Optional()],
        choices=[
            ('VIN',
             'Familiar, I was checking a specific piece of information.'),
            ('CIN',
             'Familiar, but I was interested in gaining new knowledge about the topic.'
             ),
            ('MIN',
             'Unfamiliar, the search was in more or less unknown knowledge area.'
             ),
        ],
    )
    inspiration = wtf.StringField('What was the inspiration for this topic?')
    notes = wtf.TextAreaField('General comment.')

    topic_id = wtf.HiddenField()
コード例 #3
0
ファイル: battle.py プロジェクト: adhameer/tcod-asb
class BattleCloseForm(asb.forms.CSRFTokenForm):
    """A form for closing a battle and distributing prizes.

    Use the battle_close_form method below to build one of these with choices
    for who_won and a subform for info about the Pokémon that participated.
    """

    who_won = wtforms.RadioField('Who won?', [wtforms.validators.Required()],
        coerce=int)

    length = wtforms.RadioField(
        'How did it end?',
        [wtforms.validators.Required()],
        choices=list(length_labels.items())
    )

    submit = wtforms.SubmitField('Close battle')

    def pokemon_by_squad(self):
        """Return this battle's Pokémon, grouped by trainer, with their
        subforms.

        n.b. The squads are grouped with itertools.groupby, so remember that
        each squad becomes unavailable after you advance to the next.
        """

        # self.pokemon is added by the battle_close_form method
        squads = zip(self.db_pokemon, self.pokemon)
        squads = itertools.groupby(squads, lambda squad: squad[0].trainer)
        return squads
コード例 #4
0
ファイル: app.py プロジェクト: waabiMkwa/realm-generator
class GenerateForm(flask_wtf.FlaskForm):
    great_families = wtforms.IntegerField(
        'Great Noble Families',
        validators=[wtforms.validators.DataRequired()],
        default=GREAT_FAMILIES)
    minor_families = wtforms.IntegerField(
        'Minor Noble Families',
        validators=[wtforms.validators.DataRequired()],
        default=MINOR_FAMILIES)
    knights = wtforms.IntegerField(
        'Landed Knight Families',
        validators=[wtforms.validators.DataRequired()],
        default=LANDED_FAMILIES)

    powerful_factions = wtforms.IntegerField(
        'Powerful Factions',
        validators=[wtforms.validators.DataRequired()],
        default=POWERFUL_FACTIONS)
    weak_factions = wtforms.IntegerField(
        'Weak Factions',
        validators=[wtforms.validators.DataRequired()],
        default=WEAK_FACTIONS)

    start_noble_events = wtforms.IntegerField(
        'Events for Nobles',
        validators=[wtforms.validators.DataRequired()],
        default=START_NOBLE_EVENTS)
    start_courtier_events = wtforms.IntegerField(
        'Events for Courtiers',
        validators=[wtforms.validators.DataRequired()],
        default=START_COURTIER_EVENTS)
    start_family_events = wtforms.IntegerField(
        'Events for Noble Families',
        validators=[wtforms.validators.DataRequired()],
        default=START_FAMILY_EVENTS)

    titles = wtforms.RadioField(
        'Title Stylings',
        choices=[('british', 'British (King, Lord, Sir)'),
                 ('roman', 'Roman (Emperor, Dominus, Consulus)'),
                 ('byzantine', 'Byzantine (Basileus, Despot, Sebastor)'),
                 ('russian', 'Russian (Tsar, Count, Baron)'),
                 ('sanskrit', 'Sanskrit (Maharaja, Amir, Sardar)'),
                 ('persian', 'Persian (Shah, Marzban, Istandar)')],
        default='british')

    realms = wtforms.RadioField(
        'Family Realm Names',
        choices=[('House', 'House (i.e. The Great House of Whatever)'),
                 ('Hearth', 'Hearth (i.e. The Great Hearth of Whatever)'),
                 ('Domain', 'Domain (i.e. The Great Domain of Whatever)'),
                 ('Clan', 'Clan (i.e. The Great Clan of Whatever)'),
                 ('Tribe', 'Tribe (i.e. The Great Tribe of Whatever)'),
                 ('Dynasty', 'Dynasty (i.e. The Great Dynasty of Whatever)'),
                 ('Fastness', 'Fastness (i.e. The Great Fastness of Whatever)')
                 ],
        default='House')

    submit = wtforms.SubmitField('Generate A Realm Now!')
コード例 #5
0
class DonorForm(wtforms.Form):
    user_email = wtforms.TextField(label='User email',
                                   validators=[wtforms.validators.Optional()])
    confirmation = wtforms.TextField(
        label='Confirmation', validators=[wtforms.validators.Optional()])
    amount_choice = wtforms.RadioField(
        label='Donation amount',
        validators=[wtforms.validators.Optional()],
        coerce=int,
        choices=AMOUNT_CHOICES)
    customize_amount = wtforms.IntegerField(
        label='Customize your donation amount',
        validators=[
            wtforms.validators.Optional(),
            wtforms.validators.NumberRange(1, 1000000)
        ])
    first_name = wtforms.TextField(label='Name',
                                   validators=[wtforms.validators.Required()])
    last_name = wtforms.TextField(label='Name',
                                  validators=[wtforms.validators.Optional()])
    address = wtforms.TextField(label='Address',
                                validators=[
                                    wtforms.validators.Required(),
                                    wtforms.validators.Length(max=500)
                                ],
                                default=u'')
    city = wtforms.TextField(label='City',
                             validators=[wtforms.validators.Required()])
    state = wtforms.SelectField(
        label='Please select any one state in the list', choices=STATES)
    pin = wtforms.TextField(label='Pin Code',
                            validators=[wtforms.validators.Required()])
    phone_number = wtforms.TextField(
        label='Phone Number', validators=[wtforms.validators.Required()])
    email = wtforms.TextField(label='Email',
                              validators=[wtforms.validators.Required()])

    pan_number = wtforms.TextField(label='Pan Number',
                                   validators=[wtforms.validators.Required()])
    tax_exemption_certificate = wtforms.RadioField(
        label='Would you like us to send you a Tax Exemption Certificate?',
        default='False',
        choices=[('True', 'Yes'), ('False', 'No')])
    ann_choice = wtforms.RadioField(label='Would you like to be anonymous?',
                                    default='False',
                                    choices=[('True', 'Yes'), ('False', 'No')])

    def set_data(self, user):
        self.first_name.data = user.first_name
        self.last_name.data = user.last_name
        self.address.data = user.address
        self.state.data = user.state
        self.city.data = user.city
        self.pin.data = user.pin
        self.phone_number.data = user.contact_number
        self.email.data = user.email
        self.pan_number.data = user.pan_number
コード例 #6
0
ファイル: exit_survey.py プロジェクト: twiffy/eabooc
class ExitSurvey1Form(wtf.Form):
    first_hear = wtf.RadioField(
        "Where did you first hear about this course?<br>Select one.",
        choices=(
            ('facebook', 'Facebook'),
            ('twitter', 'Twitter'),
            ('linkedin', 'LinkedIn'),
            ('google-ads', 'Google Ads'),
            ('hastac', 'HASTAC'),
            ('word-of-mouth', 'Word of Mouth (please explain)'),
            ('other', 'Other (please explain)'),
        ),
        validators=(wtf.validators.required(), ))
    first_hear_explain = wtf.StringField(
        validators=[wtf.validators.optional()])

    other_courses = wtf.RadioField(
        "Before enrolling in this course, had you enrolled in another online course?",
        choices=(
            ('yes', 'Yes'),
            ('no', 'No'),
        ),
        validators=[wtf.validators.required()])
    other_courses_how_many = wtf.SelectField(
        "If so, how many?",
        choices=([(str(n), str(n))
                  for n in range(1, 11)] + [('11+', '11 or more')]),
        validators=[wtf.validators.optional()])
    other_courses_what = wtf.TextAreaField(
        "If so, what courses and where?",
        validators=[wtf.validators.optional()])

    enroll_motivation = wtf.RadioField(
        "What factor most motivated you to <i>enroll</i> in this course?<br>Select one.",
        choices=(
            ('expert-badges', 'Earning assessment expert & expertise badges'),
            ('leader-badges', 'Earning assessment leader badges'),
            ('certificate', 'Earning the instructor verified certificate'),
            ('required', 'I was required to by my job'),
            ('peers', 'Interacting with peers about assessment'),
            ('instructor', u'The instructor’s reputation '),
            ('learning', 'Learning about assessment   '),
            ('taking-mooc', 'Taking an open online course'),
            ('other', 'Other (please specify)'),
        ),
        validators=[wtf.validators.required()])
    enroll_motivation_other = wtf.StringField(
        validators=[wtf.validators.optional()])

    complete_motivation = wtf.RadioField(
        "What factor most motivated you to <i>complete</i> this course?<br>Select one.",
        choices=enroll_motivation.kwargs['choices'],
        validators=[wtf.validators.required()])
    complete_motivation_other = wtf.StringField(
        validators=[wtf.validators.optional()])
コード例 #7
0
ファイル: app.py プロジェクト: goodfed/flask2
class RequestForm(FlaskForm):
    goal = wtforms.RadioField('Какая цель занятий?', choices=goals_select, default=goals_select[0][0])
    time = wtforms.RadioField('Сколько времени есть?', choices=[
        ('1-2', '1-2 часа в неделю'),
        ('3-5', '3-5 часов в неделю'),
        ('5-7', '5-7 часов в неделю'),
        ('7-10', '7-10 часов в неделю')
    ], default='1-2')
    clientName = wtforms.StringField('Вас зовут', validators=[wtforms.validators.InputRequired()])
    clientPhone = wtforms.StringField('Ваш телефон', validators=[wtforms.validators.InputRequired()])
    submit = wtforms.SubmitField('Найдите мне преподавателя')
コード例 #8
0
ファイル: forms.py プロジェクト: svwk/tutorp
class RequestForm(FlaskForm):
    clientName = wtforms.StringField("Вас зовут", [validators.InputRequired(message="Необходимо ввести имя")])
    clientPhone = wtforms.StringField("Ваш телефон",
                                      [validators.InputRequired(message="Необходимо ввести телефон"),
                                       validators.regexp(
                                           TEL_REG,
                                           message="Телефон должен содержать от 6 до 11 цифр")])
    clientGoal = wtforms.RadioField('Какая цель занятий?', default="travel",
                                    choices=[("travel", "Для путешествий"), ("study", "Для учебы"),
                                             ("work", "Для работы"), ("relocate", "Для переезда"),
                                             ("coding", "для программирования")])
    clientTime = wtforms.RadioField('Сколько времени есть?', default="1-2",
                                    choices=[("1-2", "1-2 часа в неделю"), ("3-5", "3-5 часов в неделю"),
                                             ("5-7", "5-7 часов в неделю"), ("7-10", "7-10 часов в неделю")])
コード例 #9
0
ファイル: forms.py プロジェクト: honzamach/mydojo
class AdminUserAccountForm(BaseUserAccountForm):
    """
    Class representing base user account form for admins.
    """
    enabled = wtforms.RadioField(lazy_gettext('State:'),
                                 validators=[
                                     wtforms.validators.InputRequired(),
                                 ],
                                 choices=[(True, lazy_gettext('Enabled')),
                                          (False, lazy_gettext('Disabled'))],
                                 filters=[mydojo.forms.str_to_bool],
                                 coerce=mydojo.forms.str_to_bool)
    roles = wtforms.SelectMultipleField(
        lazy_gettext('Roles:'), validators=[wtforms.validators.Optional()])
    memberships = QuerySelectMultipleField(lazy_gettext('Group memberships:'),
                                           query_factory=get_available_groups)
    managements = QuerySelectMultipleField(lazy_gettext('Group managements:'),
                                           query_factory=get_available_groups)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        #
        # Handle additional custom keywords.
        #

        # The list of choices for 'roles' attribute comes from outside of the
        # form to provide as loose tie as possible to the outer application.
        # Another approach would be to load available choices here with:
        #
        #   roles = flask.current_app.config['ROLES']
        #
        # That would mean direct dependency on flask.Flask application.
        self.roles.choices = kwargs['choices_roles']
コード例 #10
0
ファイル: utils.py プロジェクト: twiffy/eabooc
 class SurveyForm(wtf.Form):
     how_found_out = wtf.RadioField(
             'How did you initially find out about the Assessment BOOC?',
             choices=[
                 ('facebook', 'Facebook'),
                 ('twitter', 'Twitter'),
                 ('google-ads', 'Google Ads'),
                 ('assess-blog', 'Remediating Assessment Blog'),
                 ('word-of-mouth', 'Word of Mouth (please elaborate below...'),
                 ('print', 'Print Advertisements'),
                 ('other', 'Other (please elaborate below...)'),
                 ],
             validators=[wtf.validators.Required()])
     how_found_out_other = wtf.TextField(
             '''If you selected "Word of Mouth," whom did you hear from?<br>
             If you selected "Other," how did you hear about the course?''',
             validators=[wtf.validators.Optional()])
     difficulty = wtf.TextAreaField(
             'Did the course meet your expectations in terms of the difficulty of the tasks?',
             validators=[wtf.validators.Required('Please give us at least a word...')])
     communication = wtf.TextAreaField(
             'Did you feel that course expectations were well-communicated?',
             validators=[wtf.validators.Required('Please give us at least a word...')])
     better_communication = wtf.TextAreaField(
             'What might we have done differently to communicate the course expectations?',
             validators=[wtf.validators.Required('Please give us at least a word...')])
     other_comments = wtf.TextAreaField(
             'Do you have any other comments or suggestions?',
             validators=[wtf.validators.Optional()])
コード例 #11
0
    def from_model(cls, question: model.Question, fill: model.FilledQuiz,
                   *args, **kwargs):
        class Form(QuestionForm):
            pass

        if question.show_choices:
            if question.multiple:
                Form.answer = QuerySelectMultipleField(
                    '',
                    query_factory=choices(question),
                    get_pk=lambda x: x.id,
                    get_label=lambda x: x.value)
                Form.submit = wtf.SubmitField(_l('Save'))
            else:
                Form.answer = wtf.RadioField('',
                                             choices=[
                                                 (x.id, x.value)
                                                 for x in choices(question)()
                                             ],
                                             coerce=int)
                Form.submit = wtf.SubmitField(_l('Save'))
        else:
            Form.answer = wtf.StringField(
                '', validators=[wtf.validators.Length(max=255)])
            Form.submit = wtf.SubmitField(_l('Save'))

        form = Form(fill, question, *args, **kwargs)
        return form
コード例 #12
0
class NewUser(FlaskForm):

    email = EmailField(
        label="Email",
        validators=[
            wtf.validators.DataRequired(message="This field is required"),
            wtf.validators.Email(message="Wrong email format")
        ])
    password = wtf.PasswordField(
        label="Password",
        validators=[
            wtf.validators.DataRequired(message="This field is required"),
            wtf.validators.EqualTo("re_password",
                                   message="The passwords must match")
        ])
    re_password = wtf.PasswordField(
        label="Repeat password",
        validators=[
            wtf.validators.DataRequired(message="This field is required")
        ])
    admin_choices = [(1, 'True'), (0, 'False')]
    admin = wtf.RadioField(
        label="Administrator",
        validators=[
            wtf.validators.InputRequired(message="This field is required")
        ],
        choices=admin_choices,
        coerce=int)
    submit_button = wtf.SubmitField(label="Save")
コード例 #13
0
ファイル: forms.py プロジェクト: softwerks/chateau
class NPSForm(flask_wtf.FlaskForm):
    nps = wtforms.RadioField(
        label=
        "How likely is it that you would recommend the Backgammon Network to a friend?",
        choices=[
            (1, "1"),
            (2, "2"),
            (3, "3"),
            (4, "4"),
            (5, "5"),
            (6, "6"),
            (7, "7"),
            (8, "8"),
            (9, "9"),
            (10, "10"),
        ],
        coerce=int,
        validators=[
            wtforms.validators.DataRequired(),
            wtforms.validators.NumberRange(1, 10),
        ],
    )
    comments = wtforms.TextAreaField(
        label="Any other feedback? (Optional)",
        validators=[
            wtforms.validators.Optional(),
            wtforms.validators.Length(max=511)
        ],
    )
コード例 #14
0
ファイル: student_csv.py プロジェクト: twiffy/eabooc
 class NavForm(wtf.Form):
     query = wtf.RadioField('Analytics query',
                            choices=[(k, k)
                                     for k in analytics_queries.keys()],
                            id='AHquery')
     view = wtf.RadioField('View',
                           choices=[('csv', 'csv'), ('table', 'table'),
                                    ('debug', 'debug')],
                           id='AHview',
                           default='table')
     unit = wtf.IntegerField('Unit Number (for unit queries)',
                             [wtf.validators.Optional()],
                             id='AHunit')
     student = wtf.StringField('Student email (for edit history query)',
                               [wtf.validators.Optional()],
                               id='AHstudent')
コード例 #15
0
ファイル: student_csv.py プロジェクト: twiffy/eabooc
 class NavForm(wtf.Form):
     query = wtf.RadioField('Analytics query',
                            choices=[(k, k) for k in mapper_queries.keys()],
                            id='MTquery')
     unit = wtf.IntegerField('Unit Number (for unit queries)',
                             validators=[wtf.validators.Optional()],
                             id='MTunit')
コード例 #16
0
ファイル: exit_survey.py プロジェクト: twiffy/eabooc
class ExitSurvey3Form(wtf.Form):
    hours_per_week = wtf.SelectField(
        "On average, how many hours per week did you spend on this course?",
        choices=[(str(n), str(n)) for n in range(1, 31)],
        validators=[wtf.validators.required()])

    most_favorite = wtf.TextAreaField(
        "What was your most favorite part about the course?",
        validators=[wtf.validators.required()])

    least_favorite = wtf.TextAreaField(
        "What was your least favorite part about the course?",
        validators=[wtf.validators.required()])

    suggestions = wtf.TextAreaField(
        "What suggestions do you have for improving the course?",
        validators=[wtf.validators.required()])

    would_recommend = wtf.RadioField(
        """Would you recommend this course to a colleague?""",
        choices=(
            ('yes', 'Yes'),
            ('no', 'No'),
        ),
        widget=HorizontalWidget('div'),
        validators=[wtf.validators.required()])
コード例 #17
0
class EditPokemonForm(asb.forms.CSRFTokenForm):
    """A form for editing a Pokémon."""

    name = wtforms.TextField('Name', [asb.forms.name_validator])
    form = wtforms.SelectField(coerce=int)
    color = wtforms.RadioField(
        'Color',
        choices=[('normal', 'Normal'), ('shiny', 'Shiny')],
        coerce=lambda x: x  # Leave None as is
    )
    save = wtforms.SubmitField('Save')

    def add_form_choices(self, pokemon):
        """Figure out what forms this Pokémon can switch between, and add choices
        to the "form" dropdown accordingly, or delete it if it's unnecessary.
        """

        if pokemon.species.can_switch_forms or pokemon.form_uncertain:
            self.form.choices = [(form.id, form.form_name)
                                 for form in pokemon.species.forms
                                 if check_form_condition(pokemon, form)]

            if self.form.data is None:
                self.form.data = pokemon.pokemon_form_id

        if self.form.choices is None or len(self.form.choices) <= 1:
            del self.form
コード例 #18
0
ファイル: web.py プロジェクト: christianbrb/raiden-wizard
class FundingOptionsForm(Form):
    funding_option = wtforms.RadioField(
        choices=[
            ("no-action", "User will deposit RDN"),
            ("run-swap", "Wizard will swap ETH <-> RDN"),
        ]
    )
コード例 #19
0
class ProjectTimeForm(wtf.Form):
    date_range = utils.DateRangeField(
        u'Date range',
        validators=[validators.Required()],
        format='%d-%m-%Y',
        default=lambda: h.start_end_month(datetime.date.today()),
    )
    projects = wtf.SelectMultipleField(
        _(u'Projects'),
        choices=ProjectChoices(skip_inactive=True),
        validators=[])
    group_by_client = wtf.BooleanField(_(u'Group by client'), default=True)
    group_by_project = wtf.BooleanField(_(u'Group by project'), default=True)
    group_by_bugs = wtf.BooleanField(_(u'Group by bugs'), default=True)
    group_by_user = wtf.BooleanField(_(u'Group by employee'), default=True)
    ticket_choice = wtf.RadioField(_('Tickets'),
                                   choices=[
                                       ('all', 'All'),
                                       ('without_bug_only',
                                        'Without bugs only'),
                                       ('meetings_only', 'Meetings only'),
                                   ],
                                   default='all')
    bigger_than = wtf.IntegerField(_('Bigger than'), default=0)

    def __init__(self, *args, **kwargs):
        super(ProjectTimeForm, self).__init__(*args, **kwargs)
        client = kwargs.pop('client', None)
        self.projects.choices = ProjectChoices(client=client,
                                               skip_inactive=True)
コード例 #20
0
ファイル: forms.py プロジェクト: Tubbz-alt/elections
def get_simple_voting_form(candidates, fasusers):
    class SimpleVoting(FlaskForm):
        action = wtforms.HiddenField()

    titles = []
    for candidate in candidates:
        title = candidate.fas_name or candidate.name
        if fasusers:  # pragma: no cover
            # We can't cover FAS integration
            try:
                if APP.config.get('FASJSON'):
                    user = ACCOUNTS.get_user(
                        username=candidate.name).result
                    title = f'{user['givenname']} {user['surname']}'
                else:
                    title = ACCOUNTS.person_by_username(
                        candidate.name)['human_name']
            except (KeyError, AuthError, APIError) as err:
                APP.logger.debug(err)
        if candidate.url:
            title = '%s <a href="%s" target="_blank" rel="noopener noreferrer">[Info]</a>' % (title, candidate.url)
        titles.append((str(candidate.id), title))
    field = wtforms.RadioField(
        'Candidates',
        choices=titles
    )
    setattr(SimpleVoting, 'candidate', field)

    return SimpleVoting()
コード例 #21
0
    def get_option_field(self, field_type, gf_field, validators):
        choices = []
        for gf_choice in gf_field["choices"]:
            choices.append((gf_choice["value"], gf_choice["text"]))

        if field_type == "radio":
            return wtforms.RadioField(
                gf_field["label"],
                choices=choices,
                validators=validators,
                description=self.get_field_description(gf_field))
        elif field_type == "checkbox":
            return MultiCheckboxField(
                gf_field["label"],
                choices=choices,
                validators=validators,
                description=self.get_field_description(gf_field))
        else:
            choices.insert(0, ('', ''))
            is_required = "isRequired" in gf_field and gf_field["isRequired"]
            if is_required:
                validators.append(
                    wtforms.validators.NoneOf(
                        [''], message=u"This field is required"))
            return wtforms.SelectField(gf_field["label"],
                                       choices=choices,
                                       validators=validators)
コード例 #22
0
ファイル: evolve.py プロジェクト: adhameer/tcod-asb
class PokemonEvolutionForm(asb.forms.CSRFTokenForm):
    """A form for evolving a Pokémon.

    The choices for the evolution field must be added dynamically.
    """

    evolution = wtforms.RadioField(coerce=int)
    submit = wtforms.SubmitField('Confirm')
コード例 #23
0
ファイル: models.py プロジェクト: aivuk/trombone
 class QuestionForm(wtforms.Form):
     dissertative_1 = wtforms.TextAreaField(self.dissertative_1)
     dissertative_2 = wtforms.TextAreaField(self.dissertative_2)
     alternative = wtforms.RadioField(default='3',
                                      choices=[('1', '1'), ('2', '2'),
                                               ('3', '3'), ('4', '4'),
                                               ('5', '5')])
     go_back = wtforms.HiddenField("go_back")
コード例 #24
0
class EmployeeForm(Form):
    name = wtforms.StringField('姓名')
    gender = wtforms.RadioField('性别', choices=[('男', '男'), ('女', '女')])
    job = wtforms.StringField('职位')
    birthdate = wtforms.DateField('生日')
    idcard = wtforms.StringField('身份证')
    address = wtforms.StringField('地址')
    salary = wtforms.DecimalField('工资')
    department_id = wtforms.SelectField('部门')
コード例 #25
0
class NewWeightEntry(FlaskForm):
    # nouvelle_entree_poids.html
    titre = lazy_gettext("Nouvelle mesure de poids")
    # date_heure = DateTimeLocalField("Date et heure", default=datetime.datetime.now())
    masse = wtforms.IntegerField(lazy_gettext("Masse : "), validators=[DataRequired(
        lazy_gettext("Ce champ est obligatoire."))])
    unite_masse = sex = wtforms.RadioField(lazy_gettext("Unité de masse"), validators=[], choices=[
        (UniteMasse.kg.name, UniteMasse.kg.name, ),
    ], default=UniteMasse.kg.name)
    enregistrement_poids = wtforms.SubmitField(lazy_gettext("Enregistrer poids"))
コード例 #26
0
class ProjectForm(Form):
    title = wtforms.TextField("Title", description="Title of the project", validators=[wtforms.validators.Required("A title is required"), wtforms.validators.length(max=250)])
    blurb = wtforms.TextField("Blurb", description="A single-line summary of the project",
        validators=[wtforms.validators.Required("A blurb is required"), wtforms.validators.length(max=250)])
    description = RichTextField(u"Description",
        description="Detailed description of your project",
        content_css="/static/css/editor.css")
    participating = wtforms.RadioField("Will you be participating?", default=1, coerce=getbool,
        choices=[(1, u"I will be working on this project"),
                 (0, u"I’m proposing an idea for others to take up")])
コード例 #27
0
class ProfileForm(BaseForm):
    nickname = wtforms.TextField(_l("Display name"), )

    avatar = wtforms.FileField(_l("Avatar"))

    profile_access_model = wtforms.RadioField(
        _l("Profile visibility"),
        choices=_ACCESS_MODEL_CHOICES,
    )

    action_save = wtforms.SubmitField(_l("Update profile"), )
コード例 #28
0
ファイル: client.py プロジェクト: gantir/lastuser
class PermissionForm(Form):
    """
    Create or edit a permission
    """
    name = wtforms.TextField('Permission name', validators=[wtforms.validators.Required()],
        description='Name of the permission as a single word in lower case. '
            'This is passed to the application when a user logs in. '
            'Changing the name will not automatically update it everywhere. '
            'You must reassign the permission to users who had it with the old name')
    title = wtforms.TextField('Title', validators=[wtforms.validators.Required()],
        description='Permission title that is displayed to users')
    description = wtforms.TextAreaField('Description',
        description='An optional description of what the permission is for')
    context = wtforms.RadioField('Context', validators=[wtforms.validators.Required()],
        description='Context where this permission is available')

    def validate(self):
        rv = super(PermissionForm, self).validate()
        if not rv:
            return False

        if not valid_username(self.name.data):
            self.name.errors.append("Name contains invalid characters")
            return False

        existing = Permission.query.filter_by(name=self.name.data, allusers=True).first()
        if existing and existing.id != self.edit_id:
            self.name.errors.append("A global permission with that name already exists")
            return False

        if self.context.data == g.user.userid:
            existing = Permission.query.filter_by(name=self.name.data, user=g.user).first()
        else:
            org = Organization.query.filter_by(userid=self.context.data).first()
            if org:
                existing = Permission.query.filter_by(name=self.name.data, org=org).first()
            else:
                existing = None
        if existing and existing.id != self.edit_id:
            self.name.errors.append("You have another permission with the same name")
            return False

        return True

    def validate_context(self, field):
        if field.data == g.user.userid:
            self.user = g.user
            self.org = None
        else:
            orgs = [org for org in g.user.organizations_owned() if org.userid == field.data]
            if len(orgs) != 1:
                raise wtforms.ValidationError("Invalid context")
            self.user = None
            self.org = orgs[0]
コード例 #29
0
class EmployeeForm(Form):
    name = wtforms.StringField('姓名', [validators.DataRequired('用户名必填')])
    gender = wtforms.RadioField('性别',
                                choices=[('男', '男'), ('女', '女')],
                                default='男')
    job = wtforms.StringField('职位', default='工程师')
    birthdate = wtforms.DateField('生日')
    idcard = wtforms.StringField('身份证号')
    address = wtforms.StringField('地址')
    salary = wtforms.FloatField('工资')

    department_id = wtforms.SelectField('部门')
コード例 #30
0
ファイル: form.py プロジェクト: Neo-python/cc
class OrderForm(FlaskForm):
    province = wtforms.IntegerField(
        '省', validators=[DataRequired(message='省信息未选择')])
    city = wtforms.IntegerField('市',
                                validators=[DataRequired(message='市信息未选择')])
    area = wtforms.IntegerField('区')
    user = wtforms.StringField('收货人',
                               validators=[DataRequired(message='收货人信息未填写')])
    phone = wtforms.StringField(
        '手机',
        validators=[Regexp(regex='^\d{8}$|^\d{11}$', message='号码内容有误,请检查')])
    userunit = wtforms.StringField('收货单位')
    telephone = wtforms.StringField('电话',
                                    validators=[
                                        Regexp(regex='^\d{8}$|^\d{11}$',
                                               message='号码有误,请检查'),
                                        Optional()
                                    ])
    payment = wtforms.RadioField('付款方式',
                                 choices=[('1', '提付'), ('0', "现付")],
                                 validators=[Optional()],
                                 default=1)
    receipt = wtforms.RadioField('提货方式',
                                 choices=[('0', "自提"), ('1', '送货')],
                                 validators=[Optional()],
                                 default=0)
    client = wtforms.StringField('发货单位',
                                 validators=[
                                     Regexp(regex='^\d{8}$|^\d{11}$',
                                            message='号码有误,请检查'),
                                     Optional()
                                 ])
    clientphone = wtforms.StringField('电话',
                                      validators=[
                                          Regexp(regex='^\d{8}$|^\d{11}$',
                                                 message='号码有误,请检查'),
                                          Optional()
                                      ])
    price = wtforms.IntegerField('价格', validators=[Optional()])
    remarks = wtforms.StringField('备注')