Changeset - 60106c6a84ba
[Not reviewed]
default
0 3 1
Dennis Fink - 11 years ago 2014-01-27 22:49:32
dennis.fink@c3l.lu
added bpm addresses
4 files changed with 106 insertions and 3 deletions:
0 comments (0 inline, 0 general)
ennstatus/donate/constants.py
Show inline comments
 
new file 100644
 

	
 
BPM_ADDRESSES = {
 
    'united_kingdom': {
 
        'address': '372 Old Street',
 
        'postal_code': 'EC1V 9AU',
 
        'city': 'London',
 
        'country': 'United Kingdom',
 
    },
 
    'united_states': {
 
        'address': '8345 NW 66 Street 2000',
 
        'postal_code': '33166-2626',
 
        'city': 'Miami',
 
        'country': 'United States of America',
 
    },
 
    'germany': {
 
        'address': 'Zum Bürgerwehr 28',
 
        'postal_code': 'D-5416',
 
        'city': 'Wittlich',
 
        'country': 'Germany',
 
    },
 
    'belgium': {
 
        'address': '3, Rue des Deux Luxembourg',
 
        'postal_code': 'B-6791',
 
        'city': 'Athus',
 
        'country': 'Belgium',
 
    },
 
    'france': {
 
        'address': 'RN 18 Les Maragolles',
 
        'postal_code': 'F-54720',
 
        'city': 'Lexy',
 
        'country': 'France',
 
    },
 
    'luxembourg': {
 
        'address': '34, Rue Gabriel Lippmann',
 
        'postal_code': 'L-5362',
 
        'city': 'Munsbach',
 
        'country': 'Luxembourg',
 
    },
 
}
ennstatus/donate/forms.py
Show inline comments
 
from flask_wtf import Form
 
from wtforms import SelectField
 
from wtforms.validators import DataRequired
 

	
 

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

	
 

	
 
class DateForm(Form):
 
    date = SelectField('date', validators=[DataRequired()])
 

	
 

	
 
class BPMForm(Form):
 
    country = SelectField('Country',
 
                          validators=[DataRequired()],
 
                          choices=COUNTRIES)
ennstatus/donate/views.py
Show inline comments
 
from flask import (Blueprint, render_template, request,
 
                   redirect, url_for, current_app)
 

	
 
from ennstatus.donate.forms import DateForm
 
from ennstatus.donate.forms import DateForm, BPMForm
 
from ennstatus.donate.functions import load_csv, get_choices
 
from ennstatus.donate.constants import BPM_ADDRESSES
 

	
 
donate_page = Blueprint('donate', __name__)
 

	
 

	
 
@donate_page.route('/')
 
def index():
 
@@ -34,15 +35,42 @@ def bitcoin():
 

	
 
@donate_page.route('/flattr')
 
def flattr():
 
    return render_template('donate/flattr.html')
 

	
 

	
 
@donate_page.route('/bpm')
 
@donate_page.route('/bpm', methods=('GET', 'POST'))
 
def bpm():
 
    return render_template('donate/bpm.html')
 

	
 
    current_app.logger.info('Handling BPM')
 
    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('donate.bpm', 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'
 

	
 
    form.country.data = country
 

	
 
    address = BPM_ADDRESSES[country]
 

	
 
    return render_template('donate/bpm.html', form=form,
 
                           address=address)
 

	
 

	
 
@donate_page.route('/received',
 
                   methods=('GET', 'POST'))
 
def received():
 

	
ennstatus/templates/donate/bpm.html
Show inline comments
 
@@ -10,12 +10,32 @@
 
  <div class="col-md-8">
 
    <blockquote>
 
      <p>"<em>Privacy is not something that I'm merely entitled to, it's an absolute prerequisite.</em>"</p>
 
      <small>Marlon Brando<cite>brainyquote</cite></small>
 
    </blockquote>
 

	
 
        <div class="pull-right">
 
      <form class="form-inline" role="form" method="POST" action="/donate/bpm">
 
        {{ form.hidden_tag()}}
 
        <div class="form-group">
 
          {{ form.country.label }}
 
          {{ form.country(_class="form-control") }}
 
        </div>
 
        <input type="submit" class="btn btn-primary btn-sm" value="Submit">
 
      </form>
 
    </div>
 
    <div class="clearfix"></div>
 
    <address>
 
      <strong>Frënn vun der Ënn, ASBL</strong><br>
 
              BPM 381892<br>
 
              {{ address['address'] }}<br>
 
              {{ address['postal_code'] }},{{ address['city'] }}<br>
 
              {{ address['country'] }}<br>
 
              <br>
 
            </address>
 
    <p>We accept <strong>BPM</strong> points as they will be used for our BPM Parcel Station. The parcel station is used for receiving and sending mails and packages around the world!</p>
 
    <div class="alert-info text-center">
 
	    <a href="mailto:info@enn.lu">Mail us your BPM voucher code!</a>
 
    </div>
 

	
 
  </div>
 
{% endblock %}
0 comments (0 inline, 0 general)