Changeset - 4abf18c39fcd
[Not reviewed]
version_5
0 3 0
Dennis Fink - 9 years ago 2015-10-16 20:39:49
dennis.fink@c3l.lu
Remove united_kingdom and united_states
3 files changed with 0 insertions and 22 deletions:
0 comments (0 inline, 0 general)
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.functions import load_csv, get_choices
 

	
 
from ennstatus.root.forms import BPMForm
 
from ennstatus.root.constants import BPM_ADDRESSES
 

	
 
COUNTRIES = [
 
    ('luxembourg', 'Luxembourg'),
 
    ('belgium', 'Belgium'),
 
    ('france', 'France'),
 
    ('germany', 'Germany'),
 
]
 

	
 
donate_page = Blueprint('donate', __name__)
 

	
 

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

	
 
    current_app.logger.info('Handling index')
 
    form = BPMForm()
 
    form.country.choices = COUNTRIES
 
    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.index', 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/index.html', form=form, address=address)
 

	
 

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

	
 
    current_app.logger.info('Handling received')
 
    form = DateForm()
 

	
 
    current_app.logger.debug('Creating choices')
 

	
 
    files = [name for name in get_choices()]
 
    files.sort()
 

	
 
    year_choices = list({name.split('-')[0] for name in files})
 
    year_choices.sort()
 
    form.year.choices = [(name, name) for name in year_choices]
 

	
 
    if not year_choices:
 
        current_app.logger.warn('No donations found!')
 
        return render_template('donate/received.html',
 
                               form=form, csv_file=None,
 
                               year=None, month=None)
 

	
 
    if request.method == 'POST':
ennstatus/root/constants.py
Show inline comments
 

	
 
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-54516',
 
        'city': 'Wittlich',
 
        'country': 'Germany',
 
    },
 
    'belgium': {
 
        'address': '3, Rue des Deux Luxembourg',
 
        'postal_code': 'B-6791',
 
        'city': 'Athus',
 
        'country': 'Belgium',
 
    },
 
    'france': {
 
        'address': 'Les Maragolles',
 
        'postal_code': 'F-54720',
 
        'city': 'Lexy',
 
        'country': 'France',
 
    },
 
    'luxembourg': {
 
        'address': '34, Rue Gabriel Lippmann',
 
        'postal_code': 'L-5365',
 
        'city': 'Munsbach',
 
        'country': 'Luxembourg',
 
    },
 
}
ennstatus/root/forms.py
Show inline comments
 
from flask_wtf import Form
 
from wtforms import (SelectField,
 
                     StringField,
 
                     RadioField,
 
                     BooleanField,
 
                     SubmitField
 
                     )
 
from wtforms.validators import InputRequired, Email, Length, DataRequired
 

	
 

	
 
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!'),
 
                               Length(max=255)
 
                           ]
 
                           )
 
    email = StringField('E-Mail*',
 
                        validators=[
 
                            InputRequired('This field is required!'),
 
                            Email()
 
                        ]
 
                        )
 
    fullname = StringField('Full name',
 
                           validators=[Length(max=65536)],
 
                           )
 
    street = StringField('Nr., Street',
 
                         validators=[Length(max=4000)],
 
                         )
 
    zip = StringField('ZIP-Code',
 
                      validators=[Length(max=30)],
 
                      )
 
    city = StringField('City/Town',
 
                       validators=[Length(max=500)],
 
                       )
 
    country = StringField('Country',
 
                          validators=[Length(max=500)],
 
                          )
 
    gpg = StringField('GPG-ID',
 
                      validators=[Length(max=18)],
 
                      )
 

	
 
    membership = RadioField('Membership Plan*',
 
                            validators=[
 
                                InputRequired(
0 comments (0 inline, 0 general)