Changeset - 3e495ae230a2
[Not reviewed]
default
0 2 0
Dennis Fink - 3 years ago 2022-01-17 21:36:09
dennis.fink@c3l.lu
Mark fields that are not required as explicitly optional
2 files changed with 9 insertions and 7 deletions:
0 comments (0 inline, 0 general)
c3l_membership/forms.py
Show inline comments
 
@@ -42,63 +42,63 @@ class MembershipForm(FlaskForm):
 
                lazy_gettext(
 
                    "Supporting membership - Membership without voting rights on the general assembly."
 
                ),
 
            ),
 
        ],
 
    )
 

	
 
    student = BooleanField(
 
        lazy_gettext(
 
            "I am a student and would like to have the reduced membership fees."
 
        ),
 
    )
 

	
 
    starving = BooleanField(
 
        lazy_gettext(
 
            "I am a starving hacker and cannot afford the membership! (Please get in touch with us at info@c3l.lu before filling out this membership form)"
 
        )
 
    )
 

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

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

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

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

	
 
    state = StringField(
 
        lazy_gettext("State/County/Province"),
 
        validators=[Length(max=500)],
 
        validators=[Optional(), Length(max=500)],
 
    )
 

	
 
    country = StringField(
 
        lazy_gettext("Country"),
 
        validators=[Length(max=500)],
 
        validators=[Optional(), Length(max=500)],
 
    )
 

	
 
    terms = BooleanField(
 
        lazy_gettext(
 
            'By submitting this membership application, you agree to have read and understood the <a href="http://statutes.c3l.lu">statutes of the Chaos Computer Club Lëtzebuerg A.S.B.L.</a>.'
 
        ),
 
        validators=[InputRequired()],
 
    )
 

	
 
    minor_member = BooleanField(
 
        lazy_gettext(
 
            "I am under 18 years of age and have the approval of my legal representative."
 
        )
 
    )
 
    submit = SubmitField(lazy_gettext("Become a member"))
c3l_membership/views.py
Show inline comments
 
@@ -52,49 +52,51 @@ def index():
 
        if (
 
            form.minor_member.data
 
            or form.student.data
 
            or form.membership.data == "supporting"
 
        ):
 
            price = current_app.config["SUPPORTING_FEE"]
 
            xml_data["voting"] = 0
 
        elif form.membership.data == "regular":
 
            price = current_app.config["REGULAR_FEE"]
 
            xml_data["voting"] = 1
 

	
 
        if form.starving.data:
 
            price = 1
 

	
 
        if form.starving.data:
 
            xml_data["status"] = "Starving"
 
        elif form.minor_member.data or form.student.data:
 
            xml_data["status"] = "Student"
 
        elif form.membership.data == "supporting":
 
            xml_data["status"] = "Supporter"
 
        else:
 
            xml_data["status"] = "Regular"
 

	
 
        xml_data["name"] = form.fullname.data
 
        xml_data["birthday"] = form.birthday.data
 
        xml_data["birthday"] = (
 
            form.birthday.data if form.birthday.data is not None else date(9999, 12, 12)
 
        )
 
        xml_data["username"] = form.username.data
 
        xml_data["email"] = form.email.data
 
        xml_data["address"] = " ".join(
 
            (
 
                form.street.data,
 
                form.zip.data,
 
                form.city.data,
 
                form.state.data,
 
                form.country.data,
 
            )
 
        )
 
        xml_data["address"] = re.sub("\s+", " ", xml_data["address"])
 

	
 
        if form.payment.data == "bitcoin":
 
            price = subprocess.check_output(
 
                [current_app.config["BITCOIN_CONVERSION_SCRIPT"], str(price)]
 
            ).decode("utf-8")
 
        elif form.payment.data == "ethereum":
 
            price = subprocess.check_output(
 
                [current_app.config["ETHEREUM_CONVERSION_SCRIPT"], str(price)]
 
            ).decode("utf-8")
 
        elif form.payment.data == "monero":
 
            price = subprocess.check_output(
 
                [current_app.config["MONERO_CONVERSION_SCRIPT"], str(price)]
0 comments (0 inline, 0 general)