Exemplo n.º 1
0
class IndexForm(FlaskForm):
    game_name = StringField(validators=[DataRequired()], render_kw={"placeholder": "Give your game a name"})
    game_mode = SelectField(validators=[DataRequired(), AnyOf(app.config['GAME_MODES'])], choices=app.game_modes)
    start_game = SubmitField('Start or join game!')
Exemplo n.º 2
0
class VenueForm(Form):
    name = StringField(
        'name', validators=[DataRequired()]
    )
    city = StringField(
        'city', validators=[DataRequired()]
    )
    state = SelectField(
        'state', validators=[DataRequired()],
        choices=[
            ('AL', 'AL'),
            ('AK', 'AK'),
            ('AZ', 'AZ'),
            ('AR', 'AR'),
            ('CA', 'CA'),
            ('CO', 'CO'),
            ('CT', 'CT'),
            ('DE', 'DE'),
            ('DC', 'DC'),
            ('FL', 'FL'),
            ('GA', 'GA'),
            ('HI', 'HI'),
            ('ID', 'ID'),
            ('IL', 'IL'),
            ('IN', 'IN'),
            ('IA', 'IA'),
            ('KS', 'KS'),
            ('KY', 'KY'),
            ('LA', 'LA'),
            ('ME', 'ME'),
            ('MT', 'MT'),
            ('NE', 'NE'),
            ('NV', 'NV'),
            ('NH', 'NH'),
            ('NJ', 'NJ'),
            ('NM', 'NM'),
            ('NY', 'NY'),
            ('NC', 'NC'),
            ('ND', 'ND'),
            ('OH', 'OH'),
            ('OK', 'OK'),
            ('OR', 'OR'),
            ('MD', 'MD'),
            ('MA', 'MA'),
            ('MI', 'MI'),
            ('MN', 'MN'),
            ('MS', 'MS'),
            ('MO', 'MO'),
            ('PA', 'PA'),
            ('RI', 'RI'),
            ('SC', 'SC'),
            ('SD', 'SD'),
            ('TN', 'TN'),
            ('TX', 'TX'),
            ('UT', 'UT'),
            ('VT', 'VT'),
            ('VA', 'VA'),
            ('WA', 'WA'),
            ('WV', 'WV'),
            ('WI', 'WI'),
            ('WY', 'WY'),
        ]
    )
    address = StringField(
        'address', validators=[DataRequired()]
    )
    phone = StringField(
        'phone'
    )
    image_link = StringField(
        'image_link'
    )
    genres = SelectMultipleField(
        # Done - TODO implement enum restriction
        'genres', validators=[DataRequired(),
        AnyOf( [ (choice.value) for choice in Genre ] )],
        choices=Genre.choices()
    )
    facebook_link = StringField(
        'facebook_link', validators=[URL()]
    )
Exemplo n.º 3
0
class FinanceIndexForm(SplitPageForm):
    status = StringField(
        validators=[AnyOf(['-2', '-1', '0', '1'], message='订单状态值不正确')],
        default='-2')
Exemplo n.º 4
0
class QuestionForm(Form):
    category = StringField("分类", validators=[AnyOf(values=["技术问答", "技术分享"])])
    title = StringField("标题", validators=[DataRequired(message="请输入标题")])
    content = TextAreaField("简介", validators=[DataRequired(message="请输入简介")])
Exemplo n.º 5
0
class ArticleFlagForm(Form):
    id = StringField(validators=[], default='')
    flag = StringField(validators=[AnyOf(['1', '0'])], default='')
Exemplo n.º 6
0
class CampaignStatusForm(FlaskForm):
    status_code = RadioField(
        _("Status"), [AnyOf([str(val) for val in CAMPAIGN_STATUS.keys()])],
        choices=[(str(val), label) for val, label in CAMPAIGN_STATUS.items()])
    submit = SubmitField(_('Save'))
Exemplo n.º 7
0
class QuestionAdmin(BaseAdminView):
    # def is_visible(self):
    #     return False

    column_list = ['id', 'type', 'lod', 'topic', 'tags']

    column_searchable_list = ['type', 'lod', 'topic']
    column_filters = ['type', 'lod', 'topic', 'tags']
    column_editable_list = ['type']

    form_edit_rules = [
        'type', 'lod', 'topic', 'tags', 'points_correct', 'points_wrong',
        'sections', 'tita_answer', 'html', 'rc_passage', 'choices',
        'coding_cases', 'allowed_languages', 'logic'
    ]

    form_ajax_refs = {
        'sections':
        QueryAjaxModelLoader('sections',
                             db.session,
                             Section,
                             fields=['name'],
                             page_size=10),
        'tags':
        QueryAjaxModelLoader('tags',
                             db.session,
                             Tag,
                             fields=['name'],
                             page_size=10)
    }

    form_create_rules = form_edit_rules

    form_overrides = dict(html=CKTextAreaField,
                          rc_passage=CKTextAreaField,
                          logic=CKTextAreaField)
    inline_models = (ChoicesInlineForm(Choice),
                     CodingCasesInlineForm(CodingCase))

    form_choices = {
        'type': [('RC', 'RC'), ('MCQ', 'MCQ'), ('TITA', 'TITA'),
                 ('CODING', 'CODING'), ('SUBJECTIVE', 'SUBJECTIVE')],
        'lod': [('Easy', 'Easy'), ('Medium', 'Medium'),
                ('Difficult', 'Difficult')],
        'topic': [("Simplifications", "Simplifications"),
                  ("Compound & Simple Interest", "Compound & Simple Interest"),
                  ("Ratio and Proportion", "Ratio and Proportion"),
                  ("Probability", "Probability"),
                  ("Time,Speed,Distance & Work", "Time,Speed,Distance & Work"),
                  ("Number System", "Number System"), ("Algebra", "Algebra"),
                  ("Geometry", "Geometry"), ("Mensuration", "Mensuration"),
                  ("Percentage", "Percentage"),
                  ("Quadratic Equation", "Quadratic Equation"),
                  ("Profit/Loss/Discount", "Profit/Loss/Discount"),
                  ("Mixtures and Alligation", "Mixtures and Alligation"),
                  ("Inequalities", "Inequalities"),
                  ("Permutation & Combination", "Permutation & Combination"),
                  ("Logarithms", "Logarithms"), ("Ages", "Ages"),
                  ("Investments andShares", "Investments andShares"),
                  ("Bar Graph", "Bar Graph"), ("Line Graph", "Line Graph"),
                  ("Tables", "Tables"), ("PieChart", "PieChart"),
                  ("Number Series", "Number Series"),
                  ("Seating Arrangement", "Seating Arrangement"),
                  ("Puzzles", "Puzzles"), ("Input Output", "Input Output"),
                  (" Coding Decoding", " Coding Decoding"),
                  ("Visual Puzzle", "Visual Puzzle"),
                  ("Reading Comprehension", "Reading Comprehension"),
                  ("Parajumbles", "Parajumbles"),
                  ("Para  Completion", "Para  Completion"),
                  ("Summary Based Question", "Summary Based Question"),
                  ("Sentence error correction", "Sentence error correction"),
                  ("Verbal Ability", "Verbal Ability"),
                  ("Cloze Test", "Cloze Test"), ("Syllogisms", "Syllogisms"),
                  ("Fill in the blanks", "Fill in the blanks"),
                  ("Odd one out", "Odd one out"),
                  ("Verbal Reasoning", "Verbal Reasoning"),
                  ("Synoyms", "Synoyms"), ("Antonyms", "Antonyms"),
                  ("Operating Systems", "Operating Systems"),
                  ("C Programming", "C Programming"), ("Array", "Array"),
                  ("Linkedlist", "Linkedlist"),
                  ("Data Structures", "Data Structures"), ("DBMS", "DBMS"),
                  ("Output", "Output")]
    }
    form_args = {
        'type': {
            'validators': [
                InputRequired(),
                AnyOf(['RC', 'MCQ', 'TITA', "CODING", "SUBJECTIVE"])
            ]
        },
        'points_correct': {
            'validators': [InputRequired(), DecimalField]
        },
        'points_wrong': {
            'validators': [InputRequired(), DecimalField]
        },
        'lod': {
            'validators':
            [InputRequired(),
             AnyOf(["Easy", "Medium", "Difficult"])]
        }
    }
Exemplo n.º 8
0
class ChangeEntity(Form):
    form_id = HiddenField(default='entity')
    id_ = HiddenField()
    name = StringField()
    permission = HiddenField(validators=[AnyOf(list(PermissionType.values()))])
    action = HiddenField(validators=[AnyOf(('add', 'delete'))])
Exemplo n.º 9
0
class BurnsDepressionTestForm(FlaskForm):
    q0 = SelectField(questions[0], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q1 = SelectField(questions[1], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q2 = SelectField(questions[2], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q3 = SelectField(questions[3], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q4 = SelectField(questions[4], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q5 = SelectField(questions[5], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q6 = SelectField(questions[6], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q7 = SelectField(questions[7], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q8 = SelectField(questions[8], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q9 = SelectField(questions[9], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q10 = SelectField(questions[10], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q11 = SelectField(questions[11], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q12 = SelectField(questions[12], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q13 = SelectField(questions[13], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q14 = SelectField(questions[14], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q15 = SelectField(questions[15], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q16 = SelectField(questions[16], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q17 = SelectField(questions[17], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q18 = SelectField(questions[18], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q19 = SelectField(questions[19], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q20 = SelectField(questions[20], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q21 = SelectField(questions[21], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q22 = SelectField(questions[22], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q23 = SelectField(questions[23], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    q24 = SelectField(questions[24], choices=choices, coerce=int, default=None, validators=[AnyOf([0,1,2,3,4], message="Please select a value")])
    submit = SubmitField('Submit')
Exemplo n.º 10
0
class CreateIndentForm(Form):
    user = StringField(label='Requested By',
                       validators=[InputRequired(), user_auth_check])
    rdate = DateInputField(label='Date')
    indent_title = StringField(label='Title',
                               validators=[InputRequired(), Length(max=50)])
    prod_order_sno = StringField(
        label='Production Order',
        validators=[Optional(),
                    AnyOf(dxproduction.get_all_prodution_order_snos_strings(),
                          message="Not a valid Production Order.")]
    )
    root_order_sno = StringField(
        label='Root Order',
        validators=[Optional()]
    )
    parent_indent_sno = StringField(
        label='Parent Indent',
        validators=[Optional(),
                    AnyOf(dxindent.get_all_indent_sno_strings(),
                          message="Not a valid Indent")]
    )
    indent_sno = FormField(NewSerialNumberForm)
    indent_desc = StringField(label='Indent For',
                              validators=[InputRequired()])
    indent_type = SelectField(
            label='Type', validators=[InputRequired()],
            choices=[("production", "Production"),
                     ("prototype", "Prototype"),
                     ("testing", "Testing"),
                     ("support", "Support"),
                     ("rd", "Research & Development")],
    )

    components = FieldList(FormField(ComponentQtyForm), min_entries=1)

    def __init__(self, auth_roles=None, admin_roles=None,
                 parent_indent_sno=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']
        if parent_indent_sno is not None:
            parent_indent = InventoryIndent(parent_indent_sno)
            self.parent_indent_sno_str = parent_indent.root_indent_sno
        else:
            self.parent_indent_sno_str = None
        super(CreateIndentForm, self).__init__(*args, **kwargs)
        self._setup_secure_fields()
        self._setup_for_supplementary()
        self._setup_sno_fields()

    def _setup_sno_fields(self):
        sno_validator = self.indent_sno.sno.validators[0]
        sno_validator.series = 'IDT'
        sno_validator.new = True
        if self.is_supplementary:
            sno_validator.parent = self.parent_indent_sno_str
        if not current_user.has_roles(tuple(self.admin_roles)):
            read_only(self.indent_sno.sno_generate)
            read_only(self.indent_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)

    def _setup_for_supplementary(self):
        if self.parent_indent_sno_str is None:
            self.is_supplementary = False
        else:
            self.is_supplementary = True
            parent_indent = InventoryIndent(self.parent_indent_sno_str)
            prod_ord_sno_str = parent_indent.prod_order_sno
            if len(parent_indent.root_order_snos):
                root_ord_sno_str = parent_indent.root_order_snos[0]
            else:
                root_ord_sno_str = None

            parent_indent_title = parent_indent.title

            self.indent_title.data = "Supplement to " + \
                                     self.parent_indent_sno_str

            if not self.prod_order_sno.data:
                self.prod_order_sno.data = prod_ord_sno_str
            read_only(self.prod_order_sno)

            if not self.root_order_sno.data:
                self.root_order_sno.data = root_ord_sno_str
            read_only(self.root_order_sno)

            if not self.parent_indent_sno.data:
                self.parent_indent_sno.data = self.parent_indent_sno_str

        read_only(self.parent_indent_sno)

    def get_supplementary_sno_default(self):
        parent_indent = InventoryIndent(self.parent_indent_sno_str)
        sindents = parent_indent.supplementary_indent_snos
        if len(sindents):
            sidx = str(max([int(x.split('.')[1]) for x in sindents]) + 1)
        else:
            sidx = '1'
        serialno_str = '.'.join([self.parent_indent_sno_str, sidx])
        return serialno_str
Exemplo n.º 11
0
class HeadersInputs(Inputs):
    headers = {
        'Authorization': [
            AnyOf(['9787B9FF6DDCB'], message='Invalid API key.')
        ]
    }
Exemplo n.º 12
0
class GoalForm(FlaskForm):
    """
    Represents a user goal
    """
    title = StringField('Goal title *',
                        validators=[DataRequired(),
                                    Length(min=1, max=30)])
    motivation = TextAreaField('My motivation for this goal is:',
                               validators=[Length(min=0, max=200)],
                               render_kw={
                                   "rows": 3,
                                   "cols": 11
                               })
    acceptance_criteria = TextAreaField('I will have met this goal when:',
                                        validators=[Length(min=0, max=200)],
                                        render_kw={
                                            "rows": 3,
                                            "cols": 11
                                        })
    reward = TextAreaField('I will reward myself:',
                           validators=[Length(min=0, max=200)],
                           render_kw={
                               "rows": 3,
                               "cols": 11
                           })
    frequency = IntegerField('Frequency',
                             validators=[Optional(),
                                         NumberRange(0, 7)],
                             render_kw={"size": 2})
    duration = IntegerField(
        'Duration (mins)',
        validators=[
            Optional(),
            NumberRange(0,
                        999,
                        message="Please enter a number between 0 and 999")
        ],
        render_kw={"size": 3})
    distance = IntegerField(
        'Distance (km)',
        validators=[
            Optional(),
            NumberRange(0,
                        999,
                        message="Please enter a number between 0 and 999")
        ],
        render_kw={"size": 3})
    frequency_activity_type = SelectField(
        'Type',
        choices=[('-1', 'Any exercise')] + SELECT_ACTIVITIES,
        validators=[Optional(), AnyOf(['-1'] + VALID_ACTIVITIES)])
    duration_activity_type = SelectField(
        'Type',
        choices=[('-1', 'Any exercise')] + SELECT_ACTIVITIES,
        validators=[Optional(), AnyOf(['-1'] + VALID_ACTIVITIES)])
    distance_activity_type = SelectField(
        'Type',
        choices=[('-1', 'Any exercise')] + SELECT_ACTIVITIES,
        validators=[Optional(), AnyOf(['-1'] + VALID_ACTIVITIES)])
    valid_goal = HiddenField('Valid Goal')
    submit = SubmitField('Set Goal')

    def validate_valid_goal(self, field):
        # need to enter at least one value in one of these fields
        if not self.duration.data and not self.distance.data and not self.frequency.data:
            raise ValidationError(
                "Please enter a frequency, duration or distance")
Exemplo n.º 13
0
 def test_any_of(self):
     self.assertEqual(AnyOf(['a', 'b', 'c'])(self.form, DummyField('b')), None)
     self.assertRaises(ValueError, AnyOf(['a', 'b', 'c']), self.form, DummyField(None))
Exemplo n.º 14
0
class CommunityGroupForm(Form):
    name = StringField("名称", validators=[DataRequired("请输入小组名称")])
    category = StringField(
        "类别", validators=[AnyOf(values=["教育同盟", "同城交易", "程序设计", "生活兴趣"])])
    desc = TextAreaField("简介", validators=[DataRequired(message="请输入简介")])
    notice = TextAreaField("简介", validators=[DataRequired(message="请输入公告")])
Exemplo n.º 15
0
class ProviderSuggestionForm(FlaskForm):
    """Form to add new provider.

    Fields:
        name (str): name of business
        is_not_active (bool): indicates that business is no longer active
        sector (select): macro sector that business belongs to
        category_updated (bool): indicates change to category/sector
        category (select): categories (w/in sector) that business belongs to
        contact_info_updated (bool): indicates change to contact information
        email (str): optional, email address of business
        website (str): optional, website of business
        telephone (str): telephone number of business
        address_updated (bool): indicates change to address
        line1 (str): 1st address line
        line2 (str): optional, 2nd address line
        city (str): city name
        state (select): address state, select is combination of id,name
        zip (str): zip/postal code
        coordinate_error (bool): whether map coordinates match actual
        location
        other (str): additional comments

    Methods:
        validate_name: validator, checks that provider does not already exist
        by checking to see if another provider exists with same name and
        address

    """
    id = IntegerField(
        "Business ID",
        validators=[InputRequired(message="Business ID is required.")])
    name = StringField(
        "Business Name",
        validators=[InputRequired(message="Business name is required.")])
    is_not_active = BooleanField("Is Not Active",
                                 validators=[AnyOf([True, False])],
                                 default=False,
                                 false_values=[None, False, 'false', 0, '0'])
    category_updated = BooleanField(
        "Category Updated",
        default=False,
        validators=[AnyOf([True, False])],
        false_values=[None, False, 'false', 0, '0'])
    sector = SelectField("Sector",
                         choices=Sector.list(),
                         coerce=int,
                         id="suggestion_sector",
                         validators=[requiredIf('category_updated')])
    category = SelectMultipleField("Category",
                                   choices=Category.list(None),
                                   coerce=int,
                                   validators=[requiredIf('category_updated')],
                                   id="suggestion_category")
    contact_info_updated = BooleanField(
        "Contact Info Update",
        validators=[AnyOf([True, False])],
        default=False,
        false_values=[None, False, 'false', 0, '0'])
    email = StringField(
        "Email Address",
        validators=[Email(),
                    Optional(),
                    requiredIf('contact_info_updated')])
    website = StringField(
        "Website",
        validators=[validate_website,
                    requiredIf('contact_info_updated')])
    telephone = StringField(
        "Telephone",
        validators=[
            Regexp("[(]?[0-9]{3}[)-]{0,2}\s*[0-9]{3}[-]?[0-9]{4}"),
            requiredIf('contact_info_updated')
        ])
    address_updated = BooleanField("Address Updated",
                                   validators=[AnyOf([True, False])],
                                   default=False,
                                   false_values=[None, False, 'false', 0, '0'])
    line1 = StringField("Street Address",
                        validators=[requiredIf('address_updated')])
    line2 = StringField("Address Line 2", validators=[Optional()])
    city = StringField("City", validators=[requiredIf('address_updated')])
    state = SelectField("State",
                        choices=State.list(),
                        coerce=int,
                        validators=[requiredIf('address_updated')])
    zip = StringField("Zip Code",
                      validators=[validate_zip,
                                  requiredIf('address_updated')])
    coordinate_error = BooleanField(
        "Coordinate_Error",
        validators=[Optional()],
        default=False,
        false_values=[None, False, 'false', 0, '0'])
    other = StringField("other", validators=[Optional()])

    def validate_address_updated(self, address_updated):
        current = Provider.query.filter_by(id=self.id.data).first().address
        if address_updated:
            check = (self.line1.data == current.line1
                     and self.line2.data == current.line2
                     and self.city.data == current.city
                     and self.state.data == current.state_id
                     and self.zip.data == current.zip
                     and self.coordinate_error.data is False)
            if check:
                raise ValidationError(
                    "Address updated selected without any changes to address.")

    def validate_contact_info_updated(self, contact_info_updated):
        provider = Provider.query.filter_by(id=self.id.data).first()
        if contact_info_updated:
            if (self.telephone.data == provider.telephone
                    and self.website.data == provider.website
                    and self.email.data == provider.email):
                raise ValidationError(
                    "Contact info updated selected without any changes to"
                    " email, telephone or website.")

    def validate_category_updated(self, category_updated):
        provider = Provider.query.filter_by(id=self.id.data).first()
        cat_ids = [cat.id for cat in provider.categories]
        if category_updated and self.category.data == cat_ids:
            raise ValidationError(
                "Category updated selected without any changes to category or"
                " sector.")

    def populate_choices(self, sector=None):
        """Populate choices for sector and category drop downs."""
        self.sector.choices = Sector.list()
        self.category.choices = Category.list(sector)
        self.state.choices = State.list()
        return self
Exemplo n.º 16
0
class APIKeyForm(Form):
    action = HiddenField(validators=[AnyOf(['add', 'delete'])])
    key_id = HiddenField()
Exemplo n.º 17
0
class DysfunctionalAttitudeScaleForm(FlaskForm):
    q0 = SelectField(questions[0], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q1 = SelectField(questions[1], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q2 = SelectField(questions[2], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q3 = SelectField(questions[3], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q4 = SelectField(questions[4], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q5 = SelectField(questions[5], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q6 = SelectField(questions[6], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q7 = SelectField(questions[7], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q8 = SelectField(questions[8], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q9 = SelectField(questions[9], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q10 = SelectField(questions[10], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q11 = SelectField(questions[11], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q12 = SelectField(questions[12], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q13 = SelectField(questions[13], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q14 = SelectField(questions[14], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q15 = SelectField(questions[15], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q16 = SelectField(questions[16], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q17 = SelectField(questions[17], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q18 = SelectField(questions[18], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q19 = SelectField(questions[19], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q20 = SelectField(questions[20], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q21 = SelectField(questions[21], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q22 = SelectField(questions[22], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q23 = SelectField(questions[23], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q24 = SelectField(questions[24], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q25 = SelectField(questions[25], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q26 = SelectField(questions[26], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q27 = SelectField(questions[27], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q28 = SelectField(questions[28], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q29 = SelectField(questions[29], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q30 = SelectField(questions[30], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q31 = SelectField(questions[31], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q32 = SelectField(questions[32], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q33 = SelectField(questions[33], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    q34 = SelectField(questions[34], choices=choices, coerce=int, default=None, validators=[AnyOf([-2,-1,0,1,2], message="Please select a value")])
    submit = SubmitField('Submit')
Exemplo n.º 18
0
 def __init__(self, current_user, target_permission_id, *args, **kwargs):
     """Create instance."""
     super(EditForm, self).__init__(current_user, *args, **kwargs)
     self.target_permission_id = target_permission_id
     self.permission_id.validators = [AnyOf([target_permission_id])]
Exemplo n.º 19
0
class TransferChangeCurrencyForm(Form):
    currency = HiddenField('New currency', [Required(), AnyOf(['EUR', 'GBP'])])
    change = SubmitField('Change currency')
Exemplo n.º 20
0
class ProfileForm(Form):
    nick_name = StringField("昵称", validators=[DataRequired(message="请输入昵称")])
    gender = StringField("性别", validators=[AnyOf(values=["female", "male"])])
    address = StringField("地址", validators=[DataRequired(message="请输入地址")])
    desc = StringField("个人简介")
Exemplo n.º 21
0
class VenueForm(Form):
    name = StringField('name', validators=[DataRequired()])
    city = StringField('city', validators=[DataRequired()])
    state = SelectField('state',
                        validators=[DataRequired()],
                        choices=[
                            ('AL', 'AL'),
                            ('AK', 'AK'),
                            ('AZ', 'AZ'),
                            ('AR', 'AR'),
                            ('CA', 'CA'),
                            ('CO', 'CO'),
                            ('CT', 'CT'),
                            ('DE', 'DE'),
                            ('DC', 'DC'),
                            ('FL', 'FL'),
                            ('GA', 'GA'),
                            ('HI', 'HI'),
                            ('ID', 'ID'),
                            ('IL', 'IL'),
                            ('IN', 'IN'),
                            ('IA', 'IA'),
                            ('KS', 'KS'),
                            ('KY', 'KY'),
                            ('LA', 'LA'),
                            ('ME', 'ME'),
                            ('MT', 'MT'),
                            ('NE', 'NE'),
                            ('NV', 'NV'),
                            ('NH', 'NH'),
                            ('NJ', 'NJ'),
                            ('NM', 'NM'),
                            ('NY', 'NY'),
                            ('NC', 'NC'),
                            ('ND', 'ND'),
                            ('OH', 'OH'),
                            ('OK', 'OK'),
                            ('OR', 'OR'),
                            ('MD', 'MD'),
                            ('MA', 'MA'),
                            ('MI', 'MI'),
                            ('MN', 'MN'),
                            ('MS', 'MS'),
                            ('MO', 'MO'),
                            ('PA', 'PA'),
                            ('RI', 'RI'),
                            ('SC', 'SC'),
                            ('SD', 'SD'),
                            ('TN', 'TN'),
                            ('TX', 'TX'),
                            ('UT', 'UT'),
                            ('VT', 'VT'),
                            ('VA', 'VA'),
                            ('WA', 'WA'),
                            ('WV', 'WV'),
                            ('WI', 'WI'),
                            ('WY', 'WY'),
                        ])
    address = StringField('address', validators=[DataRequired()])
    phone = StringField('phone', validators=[DataRequired()])
    image_link = StringField('image_link', validators=[URL()])
    genres = SelectMultipleField(
        # TODO implement enum restriction
        'genres',
        validators=[DataRequired()],
        choices=[
            ('Alternative', 'Alternative'),
            ('Blues', 'Blues'),
            ('Classical', 'Classical'),
            ('Country', 'Country'),
            ('Electronic', 'Electronic'),
            ('Folk', 'Folk'),
            ('Funk', 'Funk'),
            ('Hip-Hop', 'Hip-Hop'),
            ('Heavy Metal', 'Heavy Metal'),
            ('Instrumental', 'Instrumental'),
            ('Jazz', 'Jazz'),
            ('Musical Theatre', 'Musical Theatre'),
            ('Pop', 'Pop'),
            ('Punk', 'Punk'),
            ('R&B', 'R&B'),
            ('Reggae', 'Reggae'),
            ('Rock n Roll', 'Rock n Roll'),
            ('Soul', 'Soul'),
            ('Other', 'Other'),
        ])
    facebook_link = StringField('facebook_link', validators=[URL()])
    website = StringField('website', validators=[URL()])
    seeking_description = StringField('seeking_description',
                                      validators=[DataRequired()])
    seeking_talent = SelectField('seeking_talent',
                                 validators=[AnyOf([True, False])],
                                 choices=[
                                     (True, True),
                                     (False, False),
                                 ])
Exemplo n.º 22
0
class LoginForm(FlaskForm):
    username = StringField('username', validators=[InputRequired('A username is required!'), Length(min=5, max=10, message='Must be between 5 and 10 characters.')])
    password = PasswordField('password', validators=[InputRequired('Password is required!'), AnyOf(values=['password', 'secret'])])
Exemplo n.º 23
0
def admin():
    role_form = RoleForm()
    users = User.query.all()
    usernames = [u.username for u in users]
    role_form.username.validators.append(
        AnyOf(usernames, message="Username not found."))
    if role_form.validate_on_submit():
        form = role_form
        user = User.query.filter(User.username == form.username.data).one()

        try:
            role = Role.query.filter(Role.name == form.role.data).one()
        except NoResultFound:
            role = Role(name=form.role.data)
            db.session.add(role)

        if form.action.data == "add":
            if role not in user.roles:
                user.roles.append(role)
                db.session.add(user)
        elif form.action.data == "remove":
            if role in user.roles:
                user.roles.remove(role)
                db.session.add(user)

        db.session.commit()
        return redirect(url_for("horti.admin"))

    group_form = GroupForm()
    if group_form.validate_on_submit():
        form = group_form
        name = form.name.data
        if form.action.data == "add":
            tweety.post_groups(name=name)
        elif form.action.data == "remove":
            tweety.delete_group(name)
        groups = cache(tweety.get_groups, force_refresh=True)
        return redirect(url_for("horti.admin"))

    # display groups
    have_groups = False
    while not have_groups:
        groups = cache(tweety.get_groups)
        if not isinstance(groups, Response):
            have_groups = True
            groups.sort()
        sleep(0.2)

    # display roles
    roles = {}
    for user in users:
        roles[user.username] = ", ".join(sorted([r.name for r in user.roles]))

    template_data = {
        "role_form": role_form,
        "users": users,
        "roles": roles,
        "groups": groups,
        "group_form": group_form
    }
    return render_template("admin.html",
                           title=make_title("Admin"),
                           **template_data)
Exemplo n.º 24
0
class LoginForm(FlaskForm):
    username = StringField('Username', validators=[InputRequired(), Email(message="Debe enviar un email")])
    password = PasswordField('Password', validators=[InputRequired(), Length(min=5, max=10), AnyOf({"secret","password"}, message="No es un pass admitido")])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')
Exemplo n.º 25
0
def newStudent(name):
	#adding field for each question in form
	paper = Paper.query.get(name)
	class StudentForm(SubmitButton):
		pass
	no_of_questions = paper.no_of_questions
	setattr(StudentForm, "name", StringField('Name of student', validators = [DataRequired(), NoneOf(list(map(lambda x: x.name, paper.students)))]))
	for i in range(1, paper.no_of_questions+1):
		setattr(StudentForm, str(i), StringField("Q{}".format(i), validators =[Length(max=1), AnyOf(merger(paper.choices.lower(), paper.choices.upper()) + [''])]))
	form = StudentForm()
	if form.validate_on_submit():
		#reconversion of student's answers into integer value for storage
		db.session.add(Student(name = form.name.data, paper_id = name, answers = {key: getattr(form,str(i)).data.upper() if getattr(form,str(i)).data.upper() != '' else '0' for key in range(1, no_of_questions+1)}))
		db.session.commit()
		return redirect(url_for('paperView', name = name))
	return render_template('createStudent.html', form = form, questions = list(map(lambda x: str(x),range(1, no_of_questions+1))), getattr = getattr, name = paper.name)
Exemplo n.º 26
0
class ArtistForm(BaseForm):
    name = StringField('name', validators=[DataRequired()])
    city = StringField('city', validators=[DataRequired()])
    state = SelectField(
        'state',
        validators=[
            DataRequired(),
            AnyOf([
                'AL',
                'AK',
                'AZ',
                'AR',
                'CA',
                'CO',
                'CT',
                'DE',
                'DC',
                'FL',
                'GA',
                'HI',
                'ID',
                'IL',
                'IN',
                'IA',
                'KS',
                'KY',
                'LA',
                'ME',
                'MT',
                'NE',
                'NV',
                'NH',
                'NJ',
                'NM',
                'NY',
                'NC',
                'ND',
                'OH',
                'OK',
                'OR',
                'MD',
                'MA',
                'MI',
                'MN',
                'MS',
                'MO',
                'PA',
                'RI',
                'SC',
                'SD',
                'TN',
                'TX',
                'UT',
                'VT',
                'VA',
                'WA',
                'WV',
                'WI',
                'WY',
            ],
                  message=u'Invalid value, must be one of: %(values)s')
        ],
        choices=[
            ('AL', 'AL'),
            ('AK', 'AK'),
            ('AZ', 'AZ'),
            ('AR', 'AR'),
            ('CA', 'CA'),
            ('CO', 'CO'),
            ('CT', 'CT'),
            ('DE', 'DE'),
            ('DC', 'DC'),
            ('FL', 'FL'),
            ('GA', 'GA'),
            ('HI', 'HI'),
            ('ID', 'ID'),
            ('IL', 'IL'),
            ('IN', 'IN'),
            ('IA', 'IA'),
            ('KS', 'KS'),
            ('KY', 'KY'),
            ('LA', 'LA'),
            ('ME', 'ME'),
            ('MT', 'MT'),
            ('NE', 'NE'),
            ('NV', 'NV'),
            ('NH', 'NH'),
            ('NJ', 'NJ'),
            ('NM', 'NM'),
            ('NY', 'NY'),
            ('NC', 'NC'),
            ('ND', 'ND'),
            ('OH', 'OH'),
            ('OK', 'OK'),
            ('OR', 'OR'),
            ('MD', 'MD'),
            ('MA', 'MA'),
            ('MI', 'MI'),
            ('MN', 'MN'),
            ('MS', 'MS'),
            ('MO', 'MO'),
            ('PA', 'PA'),
            ('RI', 'RI'),
            ('SC', 'SC'),
            ('SD', 'SD'),
            ('TN', 'TN'),
            ('TX', 'TX'),
            ('UT', 'UT'),
            ('VT', 'VT'),
            ('VA', 'VA'),
            ('WA', 'WA'),
            ('WV', 'WV'),
            ('WI', 'WI'),
            ('WY', 'WY'),
        ])
    phone = StringField('phone')
    website = StringField('website', validators=[URL()])
    image_link = StringField('image_link', validators=[URL()])
    genres = SelectMultipleField('genres',
                                 validators=[
                                     DataRequired(),
                                     AnyOf([
                                         'Alternative',
                                         'Blues',
                                         'Classical',
                                         'Country',
                                         'Electronic',
                                         'Folk',
                                         'Funk',
                                         'Hip-Hop',
                                         'Heavy Metal',
                                         'Instrumental',
                                         'Jazz',
                                         'Musical Theatre',
                                         'Pop',
                                         'Punk',
                                         'R&B',
                                         'Reggae',
                                         'Rock n Roll',
                                         'Soul',
                                         'Other',
                                     ])
                                 ],
                                 choices=[
                                     ('Alternative', 'Alternative'),
                                     ('Blues', 'Blues'),
                                     ('Classical', 'Classical'),
                                     ('Country', 'Country'),
                                     ('Electronic', 'Electronic'),
                                     ('Folk', 'Folk'),
                                     ('Funk', 'Funk'),
                                     ('Hip-Hop', 'Hip-Hop'),
                                     ('Heavy Metal', 'Heavy Metal'),
                                     ('Instrumental', 'Instrumental'),
                                     ('Jazz', 'Jazz'),
                                     ('Musical Theatre', 'Musical Theatre'),
                                     ('Pop', 'Pop'),
                                     ('Punk', 'Punk'),
                                     ('R&B', 'R&B'),
                                     ('Reggae', 'Reggae'),
                                     ('Rock n Roll', 'Rock n Roll'),
                                     ('Soul', 'Soul'),
                                     ('Other', 'Other'),
                                 ])
    facebook_link = StringField('facebook_link', validators=[URL()])
Exemplo n.º 27
0
class FinanceOpsForm(OpsForm):
    act = StringField(validators=[
        DataRequired(message='缺少操作标识'),
        AnyOf(['deliver'], message='无效操作')
    ])
Exemplo n.º 28
0
class ArtistForm(Form):
    name = StringField(
        'name', validators=[DataRequired()]
    )
    city = StringField(
        'city', validators=[DataRequired()]
    )
    state = SelectField(
        'state', validators=[DataRequired(), AnyOf(message='choose from the provided states', values=valid_states)],
        choices = [
            ('AL', 'AL'),
            ('AK', 'AK'),
            ('AZ', 'AZ'),
            ('AR', 'AR'),
            ('CA', 'CA'),
            ('CO', 'CO'),
            ('CT', 'CT'),
            ('DE', 'DE'),
            ('DC', 'DC'),
            ('FL', 'FL'),
            ('GA', 'GA'),
            ('HI', 'HI'),
            ('ID', 'ID'),
            ('IL', 'IL'),
            ('IN', 'IN'),
            ('IA', 'IA'),
            ('KS', 'KS'),
            ('KY', 'KY'),
            ('LA', 'LA'),
            ('ME', 'ME'),
            ('MT', 'MT'),
            ('NE', 'NE'),
            ('NV', 'NV'),
            ('NH', 'NH'),
            ('NJ', 'NJ'),
            ('NM', 'NM'),
            ('NY', 'NY'),
            ('NC', 'NC'),
            ('ND', 'ND'),
            ('OH', 'OH'),
            ('OK', 'OK'),
            ('OR', 'OR'),
            ('MD', 'MD'),
            ('MA', 'MA'),
            ('MI', 'MI'),
            ('MN', 'MN'),
            ('MS', 'MS'),
            ('MO', 'MO'),
            ('PA', 'PA'),
            ('RI', 'RI'),
            ('SC', 'SC'),
            ('SD', 'SD'),
            ('TN', 'TN'),
            ('TX', 'TX'),
            ('UT', 'UT'),
            ('VT', 'VT'),
            ('VA', 'VA'),
            ('WA', 'WA'),
            ('WV', 'WV'),
            ('WI', 'WI'),
            ('WY', 'WY'),
        ]
    )
    phone = StringField(
        # TODO implement validation logic for state
        'phone'
    )
    image_link = StringField(
        'image_link'
    )
    genres = SelectMultipleField(
        # TODO implement enum restriction
        'genres', validators=[DataRequired(), genreValidation],
        choices = [
            ('Alternative', 'Alternative'),
            ('Blues', 'Blues'),
            ('Classical', 'Classical'),
            ('Country', 'Country'),
            ('Electronic', 'Electronic'),
            ('Folk', 'Folk'),
            ('Funk', 'Funk'),
            ('Hip-Hop', 'Hip-Hop'),
            ('Heavy Metal', 'Heavy Metal'),
            ('Instrumental', 'Instrumental'),
            ('Jazz', 'Jazz'),
            ('Musical Theatre', 'Musical Theatre'),
            ('Pop', 'Pop'),
            ('Punk', 'Punk'),
            ('R&B', 'R&B'),
            ('Reggae', 'Reggae'),
            ('Rock n Roll', 'Rock n Roll'),
            ('Soul', 'Soul'),
            ('Other', 'Other'),
        ]
    )
    facebook_link = StringField(
        # TODO implement enum restriction
        'facebook_link', validators=[URL()]
    )
    website = StringField(
        'website', validators=[URL()]
    )
    seeking_venue = StringField(
        'seeking_venue', validators=[InputRequired()],        
    )
    seeking_description = StringField(
        'seeking_description'
    )
Exemplo n.º 29
0
class AddOfficerForm(Form):
    department = QuerySelectField('Department',
                                  validators=[DataRequired()],
                                  query_factory=dept_choices,
                                  get_label='name')
    first_name = StringField(
        'First name',
        default='',
        validators=[Regexp(r'\w*'), Length(max=50),
                    Optional()])
    last_name = StringField(
        'Last name',
        default='',
        validators=[Regexp(r'\w*'),
                    Length(max=50),
                    DataRequired()])
    middle_initial = StringField(
        'Middle initial',
        default='',
        validators=[Regexp(r'\w*'), Length(max=50),
                    Optional()])
    suffix = SelectField('Suffix',
                         default='',
                         choices=SUFFIX_CHOICES,
                         validators=[AnyOf(allowed_values(SUFFIX_CHOICES))])
    race = SelectField('Race',
                       default='WHITE',
                       choices=RACE_CHOICES,
                       validators=[AnyOf(allowed_values(RACE_CHOICES))])
    gender = SelectField('Gender',
                         choices=GENDER_CHOICES,
                         coerce=lambda x: None if x == 'Not Sure' else x,
                         validators=[AnyOf(allowed_values(db_genders))])
    star_no = StringField('Badge Number',
                          default='',
                          validators=[Regexp(r'\w*'),
                                      Length(max=50)])
    unique_internal_identifier = StringField(
        'Unique Internal Identifier',
        default='',
        validators=[Regexp(r'\w*'), Length(max=50)])
    job_id = StringField('Job ID')  # Gets rewritten by Javascript
    unit = QuerySelectField('Unit',
                            validators=[Optional()],
                            query_factory=unit_choices,
                            get_label='descrip',
                            allow_blank=True,
                            blank_text=u'None')
    employment_date = DateField('Employment Date', validators=[Optional()])
    birth_year = IntegerField('Birth Year', validators=[Optional()])
    links = FieldList(
        FormField(LinkForm, widget=FormFieldWidget()),
        description='Links to articles about or videos of the incident.',
        min_entries=1,
        widget=BootstrapListWidget())
    notes = FieldList(
        FormField(BaseTextForm, widget=FormFieldWidget()),
        description=
        'This note about the officer will be attributed to your username.',
        min_entries=1,
        widget=BootstrapListWidget())
    descriptions = FieldList(
        FormField(BaseTextForm, widget=FormFieldWidget()),
        description=
        'This description of the officer will be attributed to your username.',
        min_entries=1,
        widget=BootstrapListWidget())
    salaries = FieldList(FormField(SalaryForm, widget=FormFieldWidget()),
                         description='Officer salaries',
                         min_entries=1,
                         widget=BootstrapListWidget())

    submit = SubmitField(label='Add')
Exemplo n.º 30
0
class GameForm(FlaskForm):
    game_mode = SelectField(validators=[AnyOf(app.config['GAME_MODES'])], choices=app.game_modes)
    new_round = SubmitField('New Round')