Changeset - 9dac928ea7d1
[Not reviewed]
default
1 5 1
Dennis Fink - 11 years ago 2014-01-28 11:09:25
dennis.fink@c3l.lu
moved bpm address selector to contact page
6 files changed with 51 insertions and 72 deletions:
0 comments (0 inline, 0 general)
ennstatus/constants.py
Show inline comments
 
file renamed from ennstatus/donate/constants.py to ennstatus/constants.py
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, BPMForm
 
from ennstatus.donate.forms import DateForm
 
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():
 
@@ -35,42 +34,15 @@ def bitcoin():
 

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

	
 

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

	
 
    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)
 
    return render_template('donate/bpm.html')
 

	
 

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

	
ennstatus/templates/donate/bpm.html
Show inline comments
 
@@ -10,31 +10,12 @@
 
  <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>
ennstatus/templates/root/contact.html
Show inline comments
 
@@ -6,19 +6,31 @@
 
  <div class="col-md-4 text-center">
 
    <img src="{{ url_for('static', filename='images/Contact.png') }}" class="img-rounded" alt="WhoIs" width="160"></img>
 
    <h2>Contact</h2>
 
  </div>
 
  <div class="col-md-8">
 
    <h2>General</h2>
 
    <div class="pull-right">
 
      <form class="form-inline" role="form" method="POST" action="/contact">
 
        {{ 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>
 

	
 
    <p>Please mail all general inqueries to:</p>
 
    <address>
 
      <strong>Frënn vun der Ënn, ASBL</strong><br>
 
              BPM 381892<br>
 
              34, Rue Gabriel Lippmann<br>
 
              L-5365, Munsbach<br>
 
              Luxembourg, Europe, Earth<br>
 
              {{ address['address'] }}<br>
 
              {{ address['postal_code'] }},{{ address['city'] }}<br>
 
              {{ address['country'] }}<br>
 
              <br>
 
      <abbr title="E-Mail"><span class="glyphicon glyphicon-envelope"></span></abbr> : <a href="mailto:info@enn.lu">info@enn.lu</a> <span class="glyphicon glyphicon-lock"></span> GPG: <a href="http://adamas.ai:11371/pks/lookup?search=info@enn.lu&op=vindex" target="_blank">0x02225522</a><br>
 
      <abbr title="Website"><span class="glyphicon glyphicon-cloud"></span></abbr> : <a href="http://enn.lu/">http://enn.lu/</a> <strong>or</strong> <a href="http://5hwvqsndr2pv6kz.onion" target="_blank">http://5hwvqsndr2pv6kz.onion</a><br>
 
      <abbr title="Phone"><span class="glyphicon glyphicon-earphone"></span></abbr> : </strong>+352-691-71-77-44<br>
 
      <abbr title="Fax"><strong>f.: </abbr></strong>not available yet</a>
 
    </address>
ennstatus/views.py
Show inline comments
 
from flask import Blueprint, render_template
 
from flask import (Blueprint, render_template, current_app,
 
                   request, redirect, url_for)
 

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

	
 
root_page = Blueprint('root', __name__)
 

	
 

	
 
@root_page.route('/')
 
def index():
 
@@ -20,15 +24,41 @@ def services():
 

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

	
 

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

	
 
    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'
 

	
 
    form.country.data = country
 

	
 
    address = BPM_ADDRESSES[country]
 

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

	
 

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

	
0 comments (0 inline, 0 general)