Exemplo n.º 1
0
class AnonymousContactForm(FlaskForm):
    email = StrippedStringField(
        label=lazy_gettext("Deine E-Mail-Adresse"),
        validators=[
            Email(lazy_gettext("E-Mail ist nicht "
                               "in gültigem Format!"))
        ],
    )
    name = StringField(
        label=lazy_gettext("Dein Name"),
        validators=[DataRequired(lazy_gettext("Bitte gib einen Namen an!"))],
    )
    dormitory = SelectField(
        label=lazy_gettext("Wohnheim"),
        choices=LocalProxy(lambda: backends.dormitories_short),
        default=LocalProxy(lambda: backends.preferred_dormitory_name()),
    )
    subject = StrippedStringField(
        label=lazy_gettext("Betreff"),
        validators=[
            DataRequired(lazy_gettext("Betreff muss angegeben werden!"))
        ])
    message = TextAreaField(
        label=lazy_gettext("Nachricht"),
        validators=[DataRequired(lazy_gettext("Nachricht fehlt!"))])
Exemplo n.º 2
0
def show(category_id, article_id):
    """Display a flatpage and parse dynamic content if available

    If available, a `<name>.<locale>.json` json_file is parsed and used to
    display A section on the webpage where users can select their
    dormitory and see _specific_ information like financial data.
    """
    article = current_app.cf_pages.get_or_404(category_id, article_id)

    try:
        restricted = article.restricted
    except AttributeError:
        restricted = False
    if restricted and not current_user.is_authenticated:
        return current_app.login_manager.unauthorized()

    box_filename = os.path.join(
        os.path.abspath(current_app.config['FLATPAGES_ROOT']),
        "{}.json".format(article.localized_page.path))

    dynamic_data = load_dynamic_json(box_filename)

    if not dynamic_data:
        return render_template('template.html', article=article, dynamic=False)

    return render_template(
        'template.html',
        article=article,
        default_dormitory=backends.preferred_dormitory_name(),
        dynamic=True,
        **dynamic_data)
Exemplo n.º 3
0
class LoginForm(FlaskForm):
    dormitory = SelectField(
        lazy_gettext("Wohnheim"),
        choices=LocalProxy(lambda: backends.dormitories_short),
        default=LocalProxy(lambda: backends.preferred_dormitory_name()),
        validators=[
            LocalProxy(
                lambda: AnyOf([dorm.name for dorm in backends.dormitories],
                              message=lazy_gettext("Kein gültiges Wohnheim!")))
        ])
    username = StrippedStringField(
        label=lazy_gettext("Nutzername"),
        validators=[
            DataRequired(lazy_gettext("Nutzername muss angegeben werden!")),
            Regexp(
                "^[^,+\"\\<>;#]+$",
                message=lazy_gettext("Nutzername enthält ungültige Zeichen!")),
        ],
    )
    password = PasswordField(
        label=lazy_gettext("Passwort"),
        validators=[DataRequired(lazy_gettext("Kein Passwort eingegeben!"))])
    remember = BooleanField(default=lazy_gettext("Anmeldung merken"))
Exemplo n.º 4
0
def show(category_id, article_id):
    """Display a flatpage and parse dynamic content if available

    If available, a `<name>.<locale>.json` json_file is parsed and used to
    display A section on the webpage where users can select their
    dormitory and see _specific_ information like financial data.
    """
    article = cf_pages.get_or_404(category_id, article_id)

    box_filename = os.path.join(
        os.path.abspath(current_app.config['FLATPAGES_ROOT']),
        "{}.json".format(article.localized_page.path)
    )

    dynamic_data = load_dynamic_json(box_filename)

    if not dynamic_data:
        return render_template('template.html', article=article,
                               dynamic=False)

    return render_template('template.html', article=article,
                           default_dormitory=backends.preferred_dormitory_name(),
                           dynamic=True, **dynamic_data)