forked from Scouterna/skojjt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoutgroupinfo.py
53 lines (51 loc) · 2.63 KB
/
scoutgroupinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from data import Semester, UserPrefs
from flask import Blueprint, render_template, redirect, request
from google.appengine.ext import ndb
from imports import startAsyncImport
import logging
scoutgroupinfo = Blueprint('scoutgroupinfo_page', __name__, template_folder='templates')
@scoutgroupinfo.route('/<sgroup_url>')
@scoutgroupinfo.route('/<sgroup_url>/', methods = ['POST', 'GET'])
def show(sgroup_url):
user = UserPrefs.current()
if not user.canImport():
return "denied", 403
breadcrumbs = [{'link':'/', 'text':'Hem'}]
baselink = "/scoutgroupinfo/"
section_title = "Kårinformation"
scoutgroup = None
if sgroup_url!=None:
sgroup_key = ndb.Key(urlsafe=sgroup_url)
scoutgroup = sgroup_key.get()
baselink += sgroup_url+"/"
breadcrumbs.append({'link':baselink, 'text':scoutgroup.getname()})
if request.method == "POST":
logging.info("POST, %s" % str(request.form))
scoutgroup.organisationsnummer = request.form['organisationsnummer'].strip()
scoutgroup.foreningsID = request.form['foreningsID'].strip()
scoutgroup.scoutnetID = request.form['scoutnetID'].strip()
scoutgroup.kommunID = request.form['kommunID'].strip()
scoutgroup.apikey_waitinglist = request.form['apikey_waitinglist'].strip()
scoutgroup.apikey_all_members = request.form['apikey_all_members'].strip()
scoutgroup.bankkonto = request.form['bankkonto'].strip()
scoutgroup.adress = request.form['adress'].strip()
scoutgroup.postadress = request.form['postadress'].strip()
scoutgroup.epost = request.form['epost'].strip()
scoutgroup.telefon = request.form['telefon'].strip()
scoutgroup.default_lagerplats = request.form['lagerplats'].strip()
scoutgroup.firmatecknare = request.form['firmatecknare'].strip()
scoutgroup.firmatecknartelefon = request.form['firmatecknartelefon'].strip()
scoutgroup.attendance_min_year = request.form.get('attendance_min_year', type=int)
scoutgroup.attendance_incl_hike = request.form.get('attendance_incl_hike') == 'on'
scoutgroup.put()
if "import" in request.form:
return startAsyncImport(scoutgroup.apikey_all_members, scoutgroup.scoutnetID, Semester.getOrCreateCurrent().key, user, request)
else:
return redirect(breadcrumbs[-1]['link'])
else:
return render_template('scoutgroupinfo.html',
heading=section_title,
baselink=baselink,
scoutgroup=scoutgroup,
breadcrumbs=breadcrumbs)