Changeset - 41232cb0b4fc
[Not reviewed]
Merge default
0 3 3
Dennis Fink - 10 years ago 2015-02-15 21:54:32
dennis.fink@c3l.lu
Merged online membership form
6 files changed with 245 insertions and 12 deletions:
0 comments (0 inline, 0 general)
ennstatus/root/forms.py
Show inline comments
 
from flask_wtf import Form
 
from wtforms import SelectField
 
from wtforms.validators import DataRequired
 
from wtforms import SelectField, StringField, RadioField, BooleanField, SubmitField
 
from wtforms.validators import DataRequired, InputRequired, Email, Optional, Length
 

	
 

	
 

	
 
COUNTRIES = [
 
    ('luxembourg', 'Luxembourg'),
 
    ('united_kingdom', 'United Kingdom'),
 
    ('united_states', 'United States of America'),
 
    ('belgium', 'Belgium'),
 
    ('france', 'France'),
 
    ('germany', 'Germany'),
 
]
 

	
 

	
 
class BPMForm(Form):
 
    country = SelectField('Country',
 
                          validators=[DataRequired()],
 
                          choices=COUNTRIES)
 

	
 

	
 
class MembershipForm(Form):
 

	
 
    username = StringField('Username*',
 
                           validators=[
 
                               InputRequired('This field is required!')]
 
                           )
 
    email = StringField('E-Mail*',
 
                        validators=[
 
                            InputRequired('This field is required!'),
 
                            Email()
 
                        ]
 
                        )
 
    firstname = StringField('First Name',
 
                            validators=[Optional()],
 
                            )
 
    surname = StringField('Surname',
 
                          validators=[Optional()],
 
                          )
 
    street = StringField('Nr., Street',
 
                         validators=[Optional()],
 
                         )
 
    zip = StringField('ZIP-Code',
 
                      validators=[Length(max=30), Optional()],
 
                      )
 
    city = StringField('City/Town',
 
                       validators=[Optional()],
 
                       )
 
    country = StringField('Country',
 
                          validators=[Optional()],
 
                          )
 
    gpg = StringField('GPG-ID',
 
                      validators=[Optional()],
 
                      )
 

	
 
    membership = RadioField('Membership Plan*',
 
                            validators=[DataRequired()],
 
                            choices=[
 
                                ('regular', 'Regular membership (120€/year)'),
 
                                ('student', 'Student memnbership (60€/year)'),
 
                                ('starving', 'Starving Hacker - Get in touch with us at info@enn.lu'),
 
                            ]
 
                            )
 

	
 
    c3l = BooleanField('Include "Chaos Computer Club Lëtzebuerg" Membership<sup>1</sup>')
 
    submit = SubmitField('Become a member')
ennstatus/root/functions.py
Show inline comments
 
new file 100644
 
from flask import render_template, current_app
 

	
 
from flask_mail import Mail, Message
 

	
 
from ennstatus.status.functions import mail
 

	
 

	
 
def send_membership_mail(form):
 
    try:
 
        msg = Message('New membership application', sender='ennstatus@enn.lu')
 
        msg.add_recipient(current_app.config['ENNSTATUS_MEMBERSHIP_MAIL'])
 

	
 
        msg.body = render_template('root/membership_mail.txt',
 
                                   username=form.username.data,
 
                                   email=form.email.data,
 
                                   membership=form.membership.data,
 
                                   c3l=form.c3l.data,
 
                                   firstname=form.firstname.data,
 
                                   surname=form.surname.data,
 
                                   street=form.street.data,
 
                                   zip=form.zip.data,
 
                                   city=form.city.data,
 
                                   country=form.country.data,
 
                                   gpg=form.gpg.data
 
                                   )
 
        print(msg.body)
 
        mail.send(msg)
 
    except KeyError:
 
        current_app.logger.error('Membership admin not found!')
 
    except AssertionError:
 
        pass
 
    except Exception as e:
 
        current_app.logger.error('Unexpecter error: %s' % e,
 
                                 exc_info=True)
ennstatus/root/views.py
Show inline comments
 
from flask import (Blueprint, render_template, current_app,
 
                   request, redirect, url_for)
 

	
 
from ennstatus.root.forms import BPMForm
 
from ennstatus.root.forms import BPMForm, MembershipForm
 
from ennstatus.root.constants import BPM_ADDRESSES
 
from ennstatus.root.functions import send_membership_mail
 

	
 
root_page = Blueprint('root', __name__)
 

	
 

	
 
@root_page.route('/')
 
def index():
 
    return render_template('root/index.html')
 

	
 

	
 
@root_page.route('/about')
 
def about():
 
    return render_template('root/about.html')
 

	
 

	
 
@root_page.route('/services')
 
def services():
 
    return render_template('root/services.html')
 

	
 

	
 
@root_page.route('/partners')
 
def partners():
 
    return render_template('root/partners.html')
 

	
 

	
 
@root_page.route('/bridgeprogram')
 
def bridgeprogram():
 
    return render_template('root/bridgeprogram.html')
 

	
 

	
 
@root_page.route('/member')
 
def member():
 
    return render_template('root/member.html')
 

	
 

	
 
@root_page.route('/membership', methods=('GET', 'POST'))
 
def membership():
 

	
 
    current_app.logger.info('Handling membership')
 
    form = MembershipForm()
 

	
 
    if request.method == 'POST':
 
        current_app.logger.debug('Validating form')
 
        if form.validate_on_submit():
 
            send_membership_mail(form)
 

	
 
    return render_template('root/membership.html', form=form)
 

	
 

	
 
@root_page.route('/contact', methods=('GET', 'POST'))
 
def contact():
 

	
 
    current_app.logger.info('Handling contact')
 
    form = BPMForm()
 
    country_choices = [choice[0] for choice in form.country.choices]
 

	
 
    if request.method == 'POST':
 
        current_app.logger.debug('Validating form')
 
        if form.validate_on_submit():
 
            country = form.country.data
 
            return redirect(url_for('root.contact', country=country))
 
    else:
 
        if 'country' in request.args:
 
            country = request.args['country']
 
            if country in country_choices:
 
                current_app.logger.info('Showing country %s' % country)
 
            else:
 
                current_app.logger.warn('Country %s not found' % country)
 
                country = 'luxembourg'
 
        else:
 
            current_app.logger.info('Using default country')
 
            country = 'luxembourg'
 

	
ennstatus/templates/root/member.html
Show inline comments
 
@@ -13,35 +13,51 @@
 
      <small>Daniel Suarez</small>
 
    </blockquote>
 

	
 
    <h3>Why becoming a member?</h3>
 
    <p>Joining our organization has several advantages.</p>
 
    <p>As an active member you get to know the people behind FVDE and you can join us on our weekly meetings (online or AFK).
 
       You'll have the possibility to actively contribute to our projects,
 
       bring in new ideas, and eventually become a part of our core team.</p>
 

	
 
    <p>We are a dynamic group of people with different backgrounds and skills
 
       who constantly learn from each other. Most of us have a broader
 
       knowledge in TOR, network security and FOSS in general,
 
       but our activities aren't limited to technical questions alone.
 
       Regularly we meet to discuss political or philosophical questions or
 
       just have a convivial evening.</p>
 

	
 
    <p>Protecting civil liberties and human rights (such as privacy, freedom of
 
       speech, free access to information,...) is our common conviction!</p>
 

	
 
    <p>If you share our goals and are eager to socialize with like-minded
 
       people, then: Stand up for a free internet! Join us today!</p>
 

	
 
    <h3>How to become a member?</h3>
 
    <p>Becoming a member is very simple. Just follow these steps:</p>
 
    <ol>
 
      <li>Download the following <a href="{{ url_for('static', filename='files/MembershipForm.pdf') }}">membership form</a> and fill in the necessary information</li>
 
      <li>Send the membership form per mail to <a href="mailto://info@enn.lu">info@enn.lu</a> or to one of our
 
          <a href="{{ url_for('donate.snailmail') }}">snailmail</a> address.</li>
 
      <li>Pay your annually membership fee. Use one of the payment methods (except <a href="{{ url_for('donate.flattr') }}">Flattr</a> or <a href="{{ url_for('donate.bpm') }}">BPM Points</a>)
 
          specified on our <a href="{{ url_for('donate.index') }}">donations</a> page.
 
      </li>
 
      <li>Wait until we get back in touch with you.</li>
 
    </ol>
 
    <table class="table table-bordered">
 
      <thead>
 
        <tr class="info">
 
          <th>Using online form</th>
 
          <th>Using PDF form</th>
 
        </tr>
 
      </thead>
 
      <tbody>
 
        <tr>
 
          <td>Fill out the <a href="{{ url_for('root.membership') }}">online form</a>.</td>
 
          <td>Download the following <a href="{{ url_for('static', filename='files/MembershipForm.pdf') }}">membership form</a> and fill in the necessary information.</td>
 
        </tr>
 
        <tr>
 
          <td>The form will automatically send a mail to our staff when you click the 'Become a member' button.</td>
 
          <td>Send the membership form per mail to <a href="mailto://info@enn.lu">info@enn.lu</a> or to one ou our <a href="{{ url_for('donate.snailmail') }}">snailmail</a> addresses.</td>
 
        </tr>
 
        <tr>
 
          <td colspan="2">Pay your annually membership fee. Use one of the payment methods (except <a href="{{ url_for('donate.flattr') }}">Flattr</a> or <a href="{{ url_for('donate.bpm') }}">BPM Points</a>)
 
              specified on our <a href="{{ url_for('donate.index') }}">donations</a> page.</td>
 
        </tr>
 
        <tr>
 
          <td colspan="2">Wait until we get back in touch with you.</td>
 
        </tr>
 
      </tbody>
 
    </table>
 
  </div>
 
{% endblock %}
ennstatus/templates/root/membership.html
Show inline comments
 
new file 100644
 
{% extends 'base.html' %}
 

	
 
{% import 'bootstrap/wtf.html' as wtf %}
 

	
 
{% set title = 'Membership' %}
 

	
 
{% block content %}
 
  <div class="col-md-12">
 
    <h2>Register as member</h2>
 
    <form method="post" class="form form-horizontal" role="form">
 
      {{ form.hidden_tag() }}
 
      <div class="form-group">
 
        {{ form.username.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.username(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.email.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.email(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.firstname.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.firstname(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.surname.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.surname(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.street.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.street(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.zip.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.zip(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.city.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.city(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.country.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.country(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.gpg.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
          {{ form.gpg(class_='form-control') }}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        {{ form.membership.label(class_='control-label col-lg-2') }}
 
        <div class="col-lg-10">
 
        {% for field in form.membership %}
 
          <div class="radio">
 
            <label>
 
              {{ field() }} {{ field.label.text }}
 
            </label>
 
          </div>
 
        {% endfor %}
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        <label class="col-lg-2 control-label">Double membership</label>
 
        <div class="col-lg-10">
 
          <div class="checkbox">
 
            <label>
 
              {{ form.c3l() }} {{ form.c3l.label.text|safe }}
 
            </label>
 
          </div>
 
        </div>
 
      </div>
 
      <div class="form-group">
 
        <div class="col-lg-offset-2 col-lg-10">
 
        {{ form.submit(class_='btn btn-primary') }}
 
        </div>
 
      </div>
 
    </div>
 
    </form>
 
    <p>Field marked with * are required!</p>
 
    <p><sup>1</sup>: If you have decided to apply for the <i>double membership</i>, the membership fees are 150€/year for the regular
 
    membership and 70€/year for the student membership.</p>
 
  </div>
 
{% endblock %}
ennstatus/templates/root/membership_mail.txt
Show inline comments
 
new file 100644
 
Hi,
 

	
 
We got a new membership application!
 

	
 
Username: {{ username }}
 
E-Mail: {{ email }}
 
Membership Plan: {{ membership }}
 
Double Membership: {{ c3l }}
 

	
 
Additional information:
 

	
 
First Name: {{ firstname }}
 
Surname: {{ surname }}
 
Nr., Street: {{ street }}
 
ZIP-Code: {{ zip }}
 
City: {{ city }}
 
Country: {{ country }}
 
GPG-ID: {{ gpg }}
 

	
 
Sincerely,
 
Ennstatus
0 comments (0 inline, 0 general)