Beispiel #1
0
class FragmentForm(Form):
    """
    A fragment form is like a content form but without a summary or template.
    """
    previous_id = wtf.HiddenField(u"Previous revision")
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    name = wtf.TextField(u"URL name", validators=[wtf.Required(), valid_name])
    content = RichTextField(u"Page content",
                            linkify=False,
                            tinymce_options=tinymce_options,
                            sanitize_tags=richtext_sanitize_tags,
                            sanitize_attributes=richtext_sanitize_attributes)
    properties = DictField(u"Properties")

    def validate_previous_id(self, field):
        if not field.data:
            field.data = None
        else:
            try:
                field.data = int(field.data)
            except ValueError:
                raise wtf.ValidationError(u"Unknown previous revision")

    def validate_name(self, field):
        # TODO
        pass
Beispiel #2
0
class ContentForm(Form):
    previous_id = wtf.HiddenField(u"Previous revision")
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    name = wtf.TextField(u"URL name", validators=[wtf.Optional(), valid_name])
    description = wtf.TextAreaField(u"Summary",
                                    description=u"Summary of this page")
    content = RichTextField(u"Page content",
                            linkify=False,
                            buttons1=richtext_buttons1,
                            valid_elements=richtext_valid_elements,
                            sanitize_tags=richtext_sanitize_tags,
                            sanitize_attributes=richtext_sanitize_attributes)
    template = wtf.TextField(
        "Template",
        validators=[wtf.Required()],
        default='page.html',
        description=u"Template with which this page will be rendered.")
    properties = DictField(u"Properties")

    def validate_previous_id(self, field):
        if not field.data:
            field.data = None
        else:
            try:
                field.data = int(field.data)
            except ValueError:
                raise wtf.ValidationError("Unknown previous revision")

    def validate_name(self, field):
        # TODO
        pass
Beispiel #3
0
class RedirectForm(Form):
    name = wtf.TextField(u"URL name", validators=[wtf.Optional(), valid_name])
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    redirect_url = wtf.TextField(u"Redirect URL", validators=[wtf.Required()])
    properties = DictField(u"Properties")

    def validate_name(self, field):
        # TODO
        pass
Beispiel #4
0
class MapForm(Form):
    name = wtf.TextField(u"URL name", validators=[wtf.Required(), valid_name])
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    list = wtf.TextAreaField(
        'Map markers',
        validators=[wtf.Required()],
        description=u'Enter each row as a JSON object with name, title, url, '
        u'latitude, longitude, zoomlevel and marker. '
        u'The URL, zoomlevel and marker can be null, others cannot.')
    properties = DictField(u"Properties")
Beispiel #5
0
class ListForm(Form):
    name = wtf.TextField(u"URL name", validators=[wtf.Required(), valid_name])
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    list = wtf.TextAreaField(
        'Items',
        validators=[wtf.Required()],
        description=
        u'Enter each row as a JSON array with ["name", title", "url", "folder/node"]. '
        u'For nodes in the root folder, use "/node". To not include a node, use "".'
    )
    properties = DictField(u"Properties")
Beispiel #6
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")
Beispiel #7
0
class DataForm(Form):
    name = wtf.TextField(u"URL name", validators=[wtf.Required(), valid_name])
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    data = wtf.TextAreaField(u"Data",
                             validators=[wtf.Required()],
                             description=u"Enter JSON data")
    properties = DictField(u"Properties")

    def validate_data(self, field):
        # Check for exceptions when loading data
        parsed = simplejson.loads(field.data, use_decimal=True)
        if not isinstance(parsed, dict):
            raise wtf.ValidationError(
                u'This is not a valid JSON object. Use {"key": value, ...}')
Beispiel #8
0
class ParticipantListForm(ContentForm):
    source = wtf.SelectField(
        u"Data Source",
        choices=[('', ''), ('doattend', 'DoAttend')],
        description=u"Source from which the participant list will be retrieved."
    )
    sourceid = wtf.TextField(
        u"Event id",
        description=u"Id of this event at the selected data source.")
    api_key = wtf.TextField(
        u"API Key",
        description=u"API key to retrieve data from the selected data source.")
    participant_template = wtf.TextField(
        "Participant template",
        validators=[wtf.Required()],
        default='participant.html',
        description=
        u"Template with which a participant’s directory entry will be rendered."
    )
    properties = DictField(u"Properties")
Beispiel #9
0
class FunnelLinkForm(ContentForm):
    funnel_name = wtf.TextField(
        u"Funnel name",
        validators=[wtf.Required()],
        description=u"URL name of the event in the HasGeek funnel")
    properties = DictField(u"Properties")