Changeset - dbf7ee7956eb
[Not reviewed]
default
0 1 0
Dennis Fink - 3 years ago 2022-01-20 13:09:36
dennis.fink@c3l.lu
Reformat
1 file changed with 7 insertions and 8 deletions:
0 comments (0 inline, 0 general)
c3l_membership/views.py
Show inline comments
 
@@ -17,56 +17,55 @@ xml_template = "<member><numm>{name}</nu
 
@root_page.url_defaults
 
def add_lang_code(endpoint, values):
 
    values.setdefault("lang_code", g.lang_code)
 

	
 

	
 
@root_page.url_value_preprocessor
 
def pull_lang_code(endpoint, values):
 
    lang_code = values.pop("lang_code")
 
    if lang_code != "favicon.ico":
 
        g.lang_code = lang_code
 

	
 

	
 
@root_page.route("/", methods=("GET", "POST"))
 
def index():
 
    form = MembershipForm()
 

	
 
    choices = [
 
        ("cash", gettext("by cash")),
 
        ("wire transfer", gettext("by wire transfer")),
 
    ]
 

	
 
    if current_app.config["DIGICASH_ENABLED"]:
 
        choices.append(("digicash", gettext("by DigiCash")))
 

	
 
    for cryptocurrency_label, options in current_app.config["CRYPTOCURRENCIES"].items():
 
        if options["ENABLED"]:
 
            choices.append(
 
                (
 
                    cryptocurrency_label,
 
                    " ".join((gettext("by"), cryptocurrency_label.title())),
 
                ),
 
            )
 
    choices.extend(
 
        (cryptocurrency_label, " ".join((gettext("by"), cryptocurrency_label.title())))
 
        for cryptocurrency_label, options in current_app.config[
 
            "CRYPTOCURRENCIES"
 
        ].items()
 
        if options["ENABLED"]
 
    )
 

	
 
    form.payment.choices = choices
 

	
 
    if form.validate_on_submit():
 

	
 
        if (
 
            form.minor_member.data
 
            or form.student.data
 
            or form.membership.data == "supporting"
 
        ):
 
            price = current_app.config["SUPPORTING_FEE"]
 
        elif form.starving.data:
 
            price = 1
 
        else:
 
            price = current_app.config["REGULAR_FEE"]
 

	
 
        if form.starving.data:
 
            status = "Starving"
 
        elif form.minor_member.data or form.student.data:
 
            status = "Student"
 
        elif form.membership.data == "supporting":
 
            status = "Supporter"
 
        else:
 
            status = "Regular"
0 comments (0 inline, 0 general)