class SearchRoomsForm(IndicoForm): location = QuerySelectField(_(u'Location'), get_label=lambda x: x.name, query_factory=Location.find, allow_blank=True) details = StringField() available = RadioField(_(u'Availability'), coerce=int, default=-1, widget=ConcatWidget(prefix_label=False), choices=[(1, _(u'Available')), (0, _(u'Booked')), (-1, _(u"Don't care"))]) capacity = IntegerField(_(u'Capacity'), validators=[Optional(), NumberRange(min=0)]) available_equipment = IndicoQuerySelectMultipleCheckboxField( _(u'Equipment'), get_label=_get_equipment_label, modify_object_list=_group_equipment, query_factory=lambda: EquipmentType.find().order_by(EquipmentType.name )) is_only_public = BooleanField(_(u'Only public rooms'), default=True) is_auto_confirm = BooleanField(_(u'Only rooms not requiring confirmation'), default=True) is_only_active = BooleanField(_(u'Only active rooms'), default=True) is_only_my_rooms = BooleanField(_(u'Only my rooms')) # Period details when searching for (un-)availability start_dt = DateTimeField(_(u'Start date'), validators=[Optional()], parse_kwargs={'dayfirst': True}, display_format='%d/%m/%Y %H:%M', widget=HiddenInput()) end_dt = DateTimeField(_(u'End date'), validators=[Optional()], parse_kwargs={'dayfirst': True}, display_format='%d/%m/%Y %H:%M', widget=HiddenInput()) repeatability = StringField( ) # TODO: use repeat_frequency/interval with new UI include_pending_blockings = BooleanField( _(u'Check conflicts against pending blockings'), default=True) include_pre_bookings = BooleanField( _(u'Check conflicts against pre-bookings'), default=True)
def __init__(self, hide_to_id: bool = False, players: List[Tuple[int, str]] = [], *args, **kwargs): super(MessagePlayerForm, self).__init__(*args, **kwargs) if hide_to_id: self.to_id.widget = HiddenInput() # Not an error self.to_id.choices += players
class CreateMatchesForm(FlaskForm): team_size = SelectField("Team Size", choices=[ (TeamSize.one_vs_one.value, "1 vs. 1"), (TeamSize.two_vs_two.value, "2 vs. 2"), (TeamSize.three_vs_three.value, "3 vs. 3"), ]) is_ranked = BooleanField("Is ranked?", default=True) make_teams_fair = BooleanField("Teams fair?", default=True) player_ids = FieldList(IntegerField("Player ID", widget=HiddenInput()))
class MessagePlayerForm(FlaskForm): campaign_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) from_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) message = StringField() submit = SubmitField('Send...') to_id = SelectField('To', choices=[ ('', 'All'), ], validate_choice=False) def __init__(self, hide_to_id: bool = False, players: List[Tuple[int, str]] = [], *args, **kwargs): super(MessagePlayerForm, self).__init__(*args, **kwargs) if hide_to_id: self.to_id.widget = HiddenInput() # Not an error self.to_id.choices += players
class HandoutForm(FlaskForm): campaign_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) title = StringField('Title', validators=[DataRequired()]) content = StringField('Content', widget=TextArea()) status = EnumField('Status', choices=[(e.name, e.value) for e in HandoutStatus], default=HandoutStatus.draft) group_id = SelectField('Group', choices=[ ('', '(none)'), ], default='', validate_choice=False) submit = SubmitField('Save handout')
class LoginForm(Form): username = StringField( label='Username', validators=[DataRequired()], ) password = PasswordField( label='Password', validators=[DataRequired()], ) key = IntegerField( label='Value', validators=[DataRequired()], widget=HiddenInput(), ) answer = IntegerField( label='Answer to the function', validators=[DataRequired()], )
class NewBookingPeriodForm(NewBookingFormBase): room_id = IntegerField('Room', [DataRequired()], widget=HiddenInput())
class HandoutGroupForm(FlaskForm): campaign_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) name = StringField('Name', validators=[DataRequired()]) submit = SubmitField('Add group')
class RemovePlayerForm(FlaskForm): id = IntegerField(widget=HiddenInput()) player = IntegerField(widget=HiddenInput()) submit = SubmitField('Remove player')
class RemoveCharacterForm(FlaskForm): id = IntegerField(widget=HiddenInput()) character = IntegerField(widget=HiddenInput()) submit = SubmitField('Remove character')
class EditForm(CreateForm): id = IntegerField(widget=HiddenInput()) description = StringField('Description', widget=TextArea()) submit = SubmitField('Save')
class NPCTransferForm(FlaskForm): npc_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) player = SelectField(validate_choice=False) submit = SubmitField('Transfer NPC')
class RevealHandout(FlaskForm): campaign_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) players = QuerySelectMultipleField('Show to', get_label=lambda x: x.user.username)
class DeleteHandoutForm(FlaskForm): campaign_id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) id = IntegerField(widget=HiddenInput(), validators=[DataRequired()]) submit = SubmitField('Delete handout')
def test_hidden_input(self, basic_widget_dummy_field): assert 'type="hidden"' in HiddenInput()(basic_widget_dummy_field) assert "hidden" in HiddenInput().field_flags
class DeleteInviteForm(FlaskForm): id = StringField(widget=HiddenInput()) submit = SubmitField('Delete share')
class UnsubscribeForm(Form): channel_id = IntegerField('channel_id', validators=[DataRequired()], widget=HiddenInput()) return_to = StringField('return_to', validators=[DataRequired()], widget=HiddenInput())
class SubscribeForm(Form): channel_id = IntegerField('channel_id', validators=[DataRequired()], widget=HiddenInput())
class HiddenInteger(IntegerField): widget = HiddenInput()