fluxscoreboard.forms

Form classes exist to define, render and validate form submission. See Displaying and Using Forms for details.

Custom Forms

class fluxscoreboard.forms.CSRFForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Todo

Document.

fluxscreoboard.forms.front

Frontend Forms

This module contains all forms for the frontend. Backend forms can be found in fluxscoreboard.forms.admin. The forms here and there are described as they should behave, e.g. “Save the challenge”, however, this behaviour has to be implemented by the developer and is not done automatically by it. However, validatation restrictions (e.g. length) are enforced. But alone, without a database to persist them, they are mostly useless.

class fluxscoreboard.forms.front.RegisterForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Registration form for new teams.

Attrs:

name: The name of the team, required and must have a length between 1 and 255.

email: The teams E-Mail address, required, must be the same as email_repeat, must have a length between 5 and 255. It is also checked that this email is not registered yet.

email_repeat: Must have the same value as email.

password: The team’s password, must be between 8 and 1024 characters long.

password_repeat: Must have the same value as password.

country: A list of available countries in the database to choose from.

timezone: The timezone to apply for the team. When not selected, UTC is used, otherwise this localizes times displayed on the frontpage.

submit: The submit button.

class fluxscoreboard.forms.front.LoginForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Login form for teams that are activated.

Attrs:

email: Login email address.

password: Login password.

login: Submit button.

class fluxscoreboard.forms.front.ForgotPasswordForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to get an email for a forgotten password.

class fluxscoreboard.forms.front.ResetPasswordForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to finish a started reset process.

class fluxscoreboard.forms.front.ProfileForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to edit a team’s profile.

Attrs:

email: The email address. Required

old_password: The old password, needed only for a password change.

password: The password. Optional, only needed if wanting to change.

password_repeat: Repeat the new password.

avatar: Display an avatar and upload a new one.

country: Change location. Required.

timezone: Change timezone. Required.

submit: Save changes

cancel: Abort

class fluxscoreboard.forms.front.SolutionSubmitForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to submit a solution for a challenge on a single challenge view. This form does not keep track of which challenge this is.

Attrs:

solution: The proposed solution for the challenge. Required.

submit: Submit the solution.

class fluxscoreboard.forms.front.SolutionSubmitListForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to submit a solution for any challenge selected from a list. Keeps track of which challenge the solution was submitted for. Subclass of SolutionSubmitForm and derives all attributes from it. New attributes defined here:

challenge: A list of challenges to choose from. Required.
class fluxscoreboard.forms.front.FeedbackForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

fluxscoreboard.forms.admin

class fluxscoreboard.forms.admin.NewsForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to add or edit an announcement.

Attrs:

message: The announcement message. Required.

published: Whether the announcement should be published. Required.

challenge: A list of challenges to choose from, alternatively a blank field with text “– General Announcement –” to not assign it to a specific challenge.

id: Hidden field keeps track of challenge.

submit: Save the announcement to the database.

cancel: Do not save the announcement.

class fluxscoreboard.forms.admin.ChallengeForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to add or edit a challenge.

Attrs:

title: Title of the challenge. Required.

text: Description of the challenge. Required.

solution: Solution. Required.

base_points: How many base points is this challenge worth? Only required if the challenge is not manual, otherwise not allowed to be anything other than 0 or empty.

online: If the challenge is online.

manual: If the points for this challenge are given manually.

id: Track the id of the challenge.

submit: Save challenge.

cancel: Abort saving.

class fluxscoreboard.forms.admin.CategoryForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to add or edit a category.

Attrs:

name: Title of the category. Required.

id: Track the id of the category.

submit: Save category.

cancel: Abort saving.

class fluxscoreboard.forms.admin.TeamForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to add or edit a team. The same restrictions as on fluxscoreboard.forms.front.RegisterForm apply.

Attrs:

name: The name of the name of the team. Required.

password: The team’s password. Only required if the team is new.

email: E-Mail address. Required.

country: Location of team. Required.

active: If the team is active, i.e. able to log in.

local: If the team is local or remote.

id: Tracks the id of the team.

submit: Save the team.

cancel: Don’t save.

class fluxscoreboard.forms.admin.IPSearchForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to search for an IP address and find the resulting team(s).

class fluxscoreboard.forms.admin.SubmissionForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

Form to add or edit a submission of a team.

Attrs:

challenge: The fluxscoreboard.models.challenge.Challenge to be chosen from a list. Required.

team: The fluxscoreboard.models.team.Team to be chosem from a list. Required.

bonus: How many bonus points the team gets. Defaults to 0.

submit: Save.

cancel: Abort.

class fluxscoreboard.forms.admin.MassMailForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

A form to send a massmail to all users.

Attrs:

from_: The sending address. Recommended to set it to settings["default_sender"], e.g.:

if not form.from_.data:
    settings = self.request.registry.settings
    form.from_.data = settings["mail.default_sender"]

subject: A subject for the E-Mail.

message: A body for the E-Mail.

submit: Send the mail.

cancel: Don’t send.

class fluxscoreboard.forms.admin.ButtonForm(formdata=None, obj=None, prefix=u'', csrf_context=None, title=None, **kwargs)[source]

A form that gives a button and an ID. Useful for having a simple action that is identified in the forms action attribute. This provides CSRF support and the ability to POST submit commands such as edit or delete.

class fluxscoreboard.forms.admin.SubmissionButtonForm(formdata=None, obj=None, prefix=u'', csrf_context=None, title=None, **kwargs)[source]

Special variant of ButtonForm that is tailored for the composite primary key table submission. Instead of having one id field it has one field challenge_id identifying the challenge and a field team_id identifiying the team.

class fluxscoreboard.forms.admin.TeamCleanupForm(formdata=None, obj=None, prefix=u'', csrf_context=None, title=None, **kwargs)[source]
class fluxscoreboard.forms.admin.SettingsForm(formdata=None, obj=None, prefix=u'', csrf_context=None, **kwargs)[source]

fluxscoreboard.forms._validators

Contains validators for forms with custom messages. Some validators are based on the original present validators, others are own creations with extended functionality.

fluxscoreboard.forms._validators.email_unique_validator(form, field)[source]

A validator to make sure the entered email is unique and does not exist yet.

fluxscoreboard.forms._validators.name_unique_validator(form, field)[source]

A validator to make sure the entered team name is unique and does not exist yet.

fluxscoreboard.forms._validators.greater_zero_if_set(form, field)[source]
fluxscoreboard.forms._validators.password_length_validator_conditional(form, field)[source]

A validator that only checks the length of the password if one was provided and otherwise just returns True. Used so an item can be edited without entering the password for the team.

fluxscoreboard.forms._validators.password_required_if_new(form, field)[source]

A validator that only requires a password if the team is newly created, i.e. its id is None.

fluxscoreboard.forms._validators.password_required_and_valid_if_pw_change(form, field)[source]

A validator that only requires a field to be set if a password change is intended, i.e. if the password field is set. It also checks that the entered password is correct.

fluxscoreboard.forms._validators.password_max_length_if_set_validator(form, field)[source]

Only apply the password_max_length_validator if the field is set at all.

fluxscoreboard.forms._validators.password_min_length_if_set_validator(form, field)[source]

Only apply the password_min_length_validator if the field is set at all.

fluxscoreboard.forms._validators.required_or_not_allowed(field_list, validator=<wtforms.validators.Required object at 0x7f8ad50c1d90>)[source]

Enforces that a field is required _only_ if none of the fields in field_list are set. Pass in an alternative validator to allow for passing of validaton control down to another validator.

fluxscoreboard.forms._validators.required_except(field_list)[source]

Enforces a required constraint only if none of the fields in field_list are set. The fields in field_list must be strings with names from other form fields.

fluxscoreboard.forms._validators.not_dynamic(form, field)[source]

Checks that the “dynamic” checkbox is not checked.

fluxscoreboard.forms._validators.only_if_dynamic(form, field)[source]

Enforces that this field is only allowed if the challenge is dynamic (and in that case it must be set).

fluxscoreboard.forms._validators.dynamic_check_multiple_allowed(form, field)[source]

Checks if multiple fields are allowed and if they are not and there already is a challenge with this dynamic type, then fail.

class fluxscoreboard.forms._validators.AvatarSize(max_size, unit=u'MB', message=None)[source]

A validator class for the size of a file. Pass it a max_size to set the value of maximum size. The unit is determined by the unit parameter and defaults to ‘MB’. Supported units are ‘B’, ‘KB’ and ‘GB’. Optionally, you can pass in a custom message which has access to the max_size and unit parameters: "Maximum size: %(max_size)d%(unit)s".

class fluxscoreboard.forms._validators.RecaptchaValidator[source]

Validates captcha by using reCaptcha API

fluxscoreboard.forms._fields

This module contains some custom fields and widgets.

class fluxscoreboard.forms._fields.AvatarWidget[source]

A widget that renders the current avatar above the form to upload a new one.

class fluxscoreboard.forms._fields.AvatarField(label=None, validators=None, filters=(), description=u'', id=None, default=None, widget=None, _form=None, _name=None, _prefix=u'', _translations=None)[source]

An avatar upload field with a display of an existing avatar.

class fluxscoreboard.forms._fields.ButtonWidget(*args, **kwargs)[source]

Todo

Document

class fluxscoreboard.forms._fields.IntegerOrEvaluatedField(label=None, validators=None, **kwargs)[source]

A field that is basically an integer but with the added exception that, if the challenge is manual, it will contain the value "evaulauted" which is also valid. May also be empty.

class fluxscoreboard.forms._fields.IntegerOrNoneField(label=None, validators=None, **kwargs)[source]
class fluxscoreboard.forms._fields.BootstrapWidget(input_type=None, group_before=None, group_after=None, default_classes=None)[source]
fluxscoreboard.forms._fields.team_size_field()[source]
class fluxscoreboard.forms._fields.RecaptchaWidget[source]

RecaptchaValidator widget that displays HTML depending on security status.

class fluxscoreboard.forms._fields.RecaptchaField(label=u'', validators=None, public_key=None, private_key=None, secure=False, http_proxy=None, **kwargs)[source]

Handles captcha field display and validation via reCaptcha

class fluxscoreboard.forms._fields.TZDateTimeField(label=None, validators=None, format=u'%Y-%m-%d %H:%M:%S', **kwargs)[source]