Skip to content

Commit

Permalink
always add a v6 prefix in simplemode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasberens committed Apr 8, 2024
1 parent e7a0642 commit da45499
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 0 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from flask import Flask, render_template
from .exts import db, mail, migrate
from .expert import expert
Expand Down
1 change: 1 addition & 0 deletions app/expert.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def expert_form():
create_select_field(ExpertForm, 'ipv6_pool', 'Wahlkreis', 'kein IPv6',
current_app.config['API_POOL_IPV6'], 'ipv4_prefix')


form = ExpertForm()
if form.validate_on_submit():
prefixes_v4 = [(current_app.config['API_POOL_HNA'], int(form.ipv4_prefix.data))] \
Expand Down
2 changes: 1 addition & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IPRequest(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120))
name = db.Column(db.String(120), unique=True)
router_id = db.Column(db.String(120))
# router_id = db.Column(db.String(120))
verified = db.Column(db.Boolean(), default=False)
token = db.Column(db.String(128), unique=True)
created_at = db.Column(db.DateTime(), default=datetime.now)
Expand Down
9 changes: 7 additions & 2 deletions app/simplemode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .utils import request_create, send_email, activate_and_redirect
from .forms import EmailForm
from .exts import db
from wtforms.validators import DataRequired

simplemode = Blueprint('simplemode', __name__)

Expand All @@ -17,7 +18,10 @@ def simplemode_activate(request_id, signed_token):
def simplemode_form():

# add location field dynamically (values are set in config)
setattr(EmailForm, 'ipv6_pool', SelectField('Wahlkreis', choices=current_app.config['API_POOL_IPV6']))
v6pool = current_app.config['API_POOL_IPV6_SIMPLE']
v6_choices = [("", "Bitte Stadteil wählen")] + [(k, k) for k in list(v6pool.keys())]

setattr(EmailForm, 'ipv6_pool', SelectField('Stadtteil', choices=v6_choices, validators=[DataRequired()]))
form = EmailForm()

if form.validate_on_submit():
Expand All @@ -27,7 +31,8 @@ def simplemode_form():
# hna network
pool_hna = current_app.config['API_POOL_HNA']
prefixes_hna = [(pool_hna, '27')]
prefixes_v6 = [(form.ipv6_pool.data, None)] if form.ipv6_pool.data else []

prefixes_v6 = [(v6pool[form.ipv6_pool.data], None)]

r = request_create(form.hostname.data, form.email.data,
prefixes_mesh + prefixes_hna, prefixes_v6)
Expand Down
2 changes: 1 addition & 1 deletion app/templates/simplemode/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{ form.csrf_token }}
{{ render_bootstrap_field(form.hostname, "Spitzname des Routers", "Ein kurzer und eindeutiger Name für deinen Router (z.B. <em>funkenpumpe</em> oder <em>HermannStr42_VH</em>). Dieser Name wird nur intern für dich hinterlegt und muss zwischen 4 und 32 Zeichen lang sein.") }}
{{ render_bootstrap_field(form.email, "Kontaktadresse", "Notwendig, damit wir dir die Router-Konfiguration per E-Mail zuschicken können. Benutze am besten immer die gleiche Adresse, auch falls du mehrere Router hast; dann kannst du die IPs hier gesammelt verwalten.") }}
{{ render_bootstrap_field(form.ipv6_pool, help="Dies wird ben&oumltigt um verbindungen im Netzwerk zu optimieren") }}
{{ render_bootstrap_field(form.ipv6_pool, help="Dies wird ben&oumltigt um Verbindungen im Netzwerk zu optimieren", placeholder="Bitte Stadtteil ausw&auml;hlen, html" ) }}
{{ render_bootstrap_field(form.captcha, "Hauptstadt Deutschlands?", "Wird benötigt, um Spam-Bots auszuschließen.") }}

<div class="form-group">
Expand Down
4 changes: 0 additions & 4 deletions default.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
PREFIX_DEFAULTS = {
'Wohnung (max. 14 Clients)' : 28,
'Kneipe/Cafe (max. 30 Clients)' : 27
}

EXPERT_MAX_PREFIX = 24

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Flask-Migrate==3.1.0
Flask-SQLAlchemy==3.1.1
Flask-Script==2.0.6
Flask-WTF==1.2.1
SQLAlchemy==2.0.23
SQLAlchemy==2.0.29
Jinja2==3.1.3
psycopg2-binary==2.9.9
WTForms==3.1.1
email-validator==1.3.1
prettytable==3.9.0
markupsafe==2.1.3
markupsafe==2.1.3

0 comments on commit da45499

Please sign in to comment.