Changeset - 9b37bb918b8a
[Not reviewed]
default
0 2 0
Dennis Fink - 3 years ago 2022-01-19 23:35:16
dennis.fink@c3l.lu
Reformat
2 files changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
c3l_membership/__init__.py
Show inline comments
 
@@ -9,28 +9,29 @@ from flask.cli import AppGroup
 
from flask_babel import Babel
 
from flask_qrcode import QRcode
 

	
 
qrcode = QRcode()
 
babel = Babel()
 
babel_cli = AppGroup("babel")
 

	
 

	
 
def create_app():
 

	
 
    app = Flask(__name__)
 

	
 
    if app.debug:
 
        config_file = os.path.abspath("config.json")
 
    else:
 
        config_file = os.path.abspath("/etc/membership.json")
 
    config_file = (
 
        os.path.abspath("config.json")
 
        if app.debug
 
        else os.path.abspath("/etc/membership.json")
 
    )
 

	
 
    try:
 
        app.config.from_file(config_file, load=json.load)
 
    except FileNotFoundError:
 
        pass
 

	
 
    qrcode.init_app(app)
 
    babel.init_app(app)
 

	
 
    _default_secret_key = base64.b64encode(secrets.token_bytes()).decode("utf-8")
 
    app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", _default_secret_key)
 
    app.config["LANGUAGES"] = ["en", "de", "fr", "lb"]
c3l_membership/forms.py
Show inline comments
 
from datetime import date
 

	
 
from flask_babel import lazy_gettext
 
from flask_wtf import FlaskForm
 
from wtforms import (
 
    BooleanField,
 
    DateField,
 
    RadioField,
 
    StringField,
 
    SubmitField,
 
    ValidationError,
 
)
 
from wtforms.validators import Email, InputRequired, Length, Optional
 

	
 
@@ -51,28 +49,30 @@ class NotEqualTo:
 
        raise ValidationError(message % d)
 

	
 

	
 
class MembershipForm(FlaskForm):
 

	
 
    username = StringField(
 
        lazy_gettext("Username"),
 
        validators=[
 
            InputRequired(lazy_gettext("This field is required!")),
 
            Length(max=255),
 
        ],
 
    )
 

	
 
    email = StringField(
 
        lazy_gettext("E-Mail"),
 
        validators=[InputRequired(lazy_gettext("This field is required!")), Email()],
 
    )
 

	
 
    fullname = StringField(
 
        lazy_gettext("Full Name"),
 
        validators=[
 
            InputRequired(lazy_gettext("This field is required!")),
 
            Length(max=65536),
 
        ],
 
    )
 

	
 
    membership = RadioField(
 
        lazy_gettext("Membership Plan"),
 
        validators=[InputRequired(lazy_gettext("Please select one of the options!"))],
 
        choices=[
 
@@ -114,24 +114,25 @@ class MembershipForm(FlaskForm):
 

	
 
    payment = RadioField(
 
        lazy_gettext("Payment Options"),
 
        validators=[InputRequired(lazy_gettext("Please select one of the options!"))],
 
    )
 

	
 
    birthday = DateField(lazy_gettext("Birthday"), validators=[Optional()])
 

	
 
    street = StringField(
 
        lazy_gettext("Nr., Street"),
 
        validators=[Optional(), Length(max=4000)],
 
    )
 

	
 
    zip = StringField(
 
        lazy_gettext("Postal Code"),
 
        validators=[Optional(), Length(max=30)],
 
    )
 

	
 
    city = StringField(
 
        lazy_gettext("City/Town"),
 
        validators=[Optional(), Length(max=500)],
 
    )
 

	
 
    state = StringField(
 
        lazy_gettext("State/County/Province"),
0 comments (0 inline, 0 general)