Exemple #1
0
class EventForm(ContentForm):
    start_datetime = DateTimeField(u"Start date/time", validators=[wtf.Required()])
    end_datetime = DateTimeField(u"End date/time", validators=[wtf.Required()])
    timezone = wtf.SelectField(u"Timezone", choices=timezone_list, validators=[wtf.Required()])
    location_name = wtf.TextField(u"Location name", validators=[wtf.Required()])
    location_address = wtf.TextField(u"Address", validators=[wtf.Required()])
    map = wtf.QuerySelectField(u"Map", get_label='title', allow_blank=True)
    mapmarker = wtf.TextField(u"Map marker")
    capacity = wtf.IntegerField(u"Capacity", validators=[wtf.Required()])
    allow_waitlisting = wtf.BooleanField(u"Allow wait-listing if over capacity", default=False)
    allow_maybe = wtf.BooleanField(u"Allow “Maybe” responses", default=True)
    participant_list = wtf.QuerySelectField(u"Participant list", get_label='title', allow_blank=True)
    properties = DictField(u"Properties")
Exemple #2
0
class ExpenseForm(Form):
    """
    Create or edit an expense line item.
    """
    id = wtf.IntegerField(u"Id", validators=[wtf.Optional()])
    date = wtf.DateField(u"Date", validators=[wtf.Required()])
    category = wtf.QuerySelectField(u"Category",
                                    validators=[wtf.Required()],
                                    query_factory=sorted_categories,
                                    get_label='title',
                                    allow_blank=True)
    description = wtf.TextField(u"Description", validators=[wtf.Required()])
    amount = wtf.DecimalField(
        u"Amount", validators=[wtf.Required(),
                               wtf.NumberRange(min=0)])

    def validate_id(self, field):
        # Check if user is authorized to edit this expense.
        if field.data:
            expense = Expense.query.get(field.data)
            if not expense:
                raise wtf.ValidationError("Unknown expense")
            if expense.report.user != g.user:
                raise wtf.ValidationError(
                    "You are not authorized to edit this expense")

    def validate_amount(self, field):
        if field.data < Decimal('0.01'):
            raise wtf.ValidationError("Amount should be non-zero")
Exemple #3
0
class EventForm(Form):
    title = wtf.TextField(
        "Title",
        description="Name of the Event",
        validators=[wtf.Required(), wtf.NoneOf(values=["new"])])
    name = wtf.TextField(
        "URL name",
        validators=[
            wtf.Optional(),
            ValidName(),
            AvailableName(u"There’s another event with the same name")
        ],
        description="URL identifier, leave blank to autogenerate")
    blurb = wtf.TextField(
        "Blurb", description="Single line blurb introducing the event")
    description = RichTextField(
        "Description",
        description="Detailed description of the event",
        content_css="/static/css/editor.css")
    venue = wtf.QuerySelectField(
        "Venue",
        description=Markup(
            'Venue for this event (<a href="/venue/new">make new</a>)'),
        query_factory=lambda: Venue.query,
        get_label='title',
    )
    start_datetime = DateTimeField(
        "Start date/time",
        description="The date and time at which this event begins",
        validators=[wtf.Required()])
    end_datetime = DateTimeField(
        "End date/time",
        description="The date and time at which this event ends",
        validators=[wtf.Required()])
    ticket_price = wtf.TextField(
        "Ticket price",
        description="Entry fee, if any, to be paid at the venue")
    total_participants = wtf.IntegerField(
        "Venue capacity",
        description=
        "The number of people this venue can accommodate. Registrations will be closed after that. Use 0 to indicate unlimited capacity",
        default=50,
        validators=[wtf.Required()])
    website = wtf.TextField("Website",
                            description="Related Website (Optional)",
                            validators=[wtf.Optional()])

    def validate_end_datetime(self, field):
        if field.data < self.start_datetime.data:
            raise wtf.ValidationError(
                u"Your event can’t end before it starts.")
Exemple #4
0
class ProposalForm(wtf.Form):
    email = wtf.html5.EmailField('Your email address', validators=[wtf.Required()],
        description="An email address we can contact you at. "\
            "Not displayed anywhere")
    phone = wtf.TextField('Phone number', validators=[wtf.Required()],
        description="A phone number we can call you at to discuss your proposal, if required. "
            "Will not be displayed")
    speaking = wtf.RadioField("Are you speaking?", coerce=int,
        choices=[(1, u"I will be speaking"),
                 (0, u"I’m proposing a topic for someone to speak on")])
    title = wtf.TextField('Title', validators=[wtf.Required()],
        description="The title of your session")
    section = wtf.QuerySelectField('Section', get_label='title', validators=[wtf.Required()],
        widget=wtf.ListWidget(prefix_label=False), option_widget=wtf.RadioInput())
    objective = wtf.TextAreaField('Objective', validators=[wtf.Required()],
        description="What is the expected benefit for someone attending this?")
    session_type = wtf.RadioField('Session type', validators=[wtf.Required()], choices=[
        ('Lecture', 'Lecture'),
        ('Demo', 'Demo'),
        ('Tutorial', 'Tutorial'),
        ('Workshop', 'Workshop'),
        ('Discussion', 'Discussion'),
        ('Panel', 'Panel'),
        ])
    technical_level = wtf.RadioField('Technical level', validators=[wtf.Required()], choices=[
        ('Beginner', 'Beginner'),
        ('Intermediate', 'Intermediate'),
        ('Advanced', 'Advanced'),
        ])
    description = wtf.TextAreaField('Description', validators=[wtf.Required()],
        description="A detailed description of the session")
    requirements = wtf.TextAreaField('Requirements',
        description="For workshops, what must participants bring to the session?")
    slides = wtf.html5.URLField('Slides', validators=[wtf.Optional(), wtf.URL()],
        description="Link to your slides. These can be just an outline initially. "\
            "If you provide a Slideshare link, we'll embed slides in the page")
    links = wtf.TextAreaField('Links',
        description="Other links, one per line. Provide links to your profile and "\
            "slides and videos from your previous sessions; anything that'll help "\
            "folks decide if they want to attend your session")
    bio = wtf.TextAreaField('Speaker bio', validators=[wtf.Required()],
        description="Tell us why you are the best person to be taking this session")
Exemple #5
0
class ExpenseReportForm(Form):
    """
    Create or edit an expense report.
    """
    title = wtf.TextField(u"Title",
                          validators=[wtf.Required()],
                          description=u"What are these expenses for?")
    budget = wtf.QuerySelectField(
        u"Budget",
        validators=[wtf.Optional()],
        query_factory=sorted_budgets,
        get_label='title',
        allow_blank=True,
        description=u"The budget source for these expenses")
    currency = wtf.SelectField(
        u"Currency",
        validators=[wtf.Required()],
        description=u"Currency for expenses in this report",
        choices=CURRENCIES)
    description = RichTextField(u"Description",
                                validators=[wtf.Optional()],
                                description=u"Notes on the expenses")