-
Notifications
You must be signed in to change notification settings - Fork 15
/
start.py
602 lines (556 loc) · 30.8 KB
/
start.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# -*- coding: utf-8 -*-
import urllib
import logging
import datetime
from operator import attrgetter
from flask import Blueprint, make_response, redirect, render_template, request
from google.appengine.ext import ndb # pylint: disable=import-error
import htmlform
import lagerbidrag
import scoutnet
import sensus
from excelreport import ExcelReport
from excelreport_sthlm import ExcelReportSthlm
from jsonreport import JsonReport
from data import Meeting, Person, ScoutGroup, Semester, Troop, TroopPerson, UserPrefs
from dakdata import DakData, Deltagare, Sammankomst
from data_badge import TroopBadge
start = Blueprint('start_page', __name__, template_folder='templates') # pylint : disable=invalid-name
@start.route('/')
@start.route('/<sgroup_url>', methods=['POST', 'GET'])
@start.route('/<sgroup_url>/', methods=['POST', 'GET'])
@start.route('/<sgroup_url>/<troop_url>', methods=['POST', 'GET'])
@start.route('/<sgroup_url>/<troop_url>/', methods=['POST', 'GET'])
@start.route('/<sgroup_url>/<troop_url>/<key_url>', methods=['POST', 'GET'])
@start.route('/<sgroup_url>/<troop_url>/<key_url>/', methods=['POST', 'GET'])
def show(sgroup_url=None, troop_url=None, key_url=None):
user = UserPrefs.current()
if not user.hasAccess():
return "denied", 403
breadcrumbs = [{'link': '/', 'text': 'Hem'}]
section_title = u'Kårer'
breadcrumbs.append({'link': '/start', 'text': section_title})
baselink = '/start/'
scoutgroup = None
if sgroup_url is not None:
sgroup_key = ndb.Key(urlsafe=sgroup_url)
if not user.hasGroupKeyAccess(sgroup_key):
return "denied", 403
scoutgroup = sgroup_key.get()
baselink += sgroup_url+"/"
breadcrumbs.append({'link': baselink, 'text': scoutgroup.getname()})
troop = None
semester = user.activeSemester.get()
if troop_url is not None and troop_url != 'lagerbidrag':
baselink += troop_url + "/"
troop_key = ndb.Key(urlsafe=troop_url)
troop = troop_key.get()
breadcrumbs.append({'link': baselink, 'text': troop.getname()})
semester = troop.semester_key.get()
if key_url == "settings":
section_title = u'Inställningar'
baselink += "settings/"
breadcrumbs.append({'link': baselink, 'text': section_title})
if request.method == "POST":
troop.defaultstarttime = request.form['defaultstarttime']
troop.defaultduration = int(request.form['defaultduration'])
troop.rapportID = int(request.form['rapportID'])
troop.scoutnetID = int(request.form['scoutnetID'])
troop.put()
form = htmlform.HtmlForm('troopsettings')
form.AddField('defaultstarttime', troop.defaultstarttime, 'Avdelningens vanliga starttid')
form.AddField('defaultduration', troop.defaultduration, u'Avdelningens vanliga mötestid i minuter', 'number')
form.AddField('scoutnetID', troop.scoutnetID, u'ScoutnetID för avdelningen : ID för DAK närvarorapport', 'number')
form.AddField('rapportID', troop.rapportID, u'Rapport ID för kommunens närvarorapport', 'number')
form.AddField('unique_id', troop.get_unique_id(), u'Unikt ID för avdelningen', 'number', False, True)
return render_template('form.html',
heading=section_title,
baselink=baselink,
form=str(form),
breadcrumbs=breadcrumbs)
if key_url == "delete":
if troop is None:
return "", 404
if request.form and "confirm" in request.form:
if not user.isGroupAdmin():
return "", 403
troop.delete()
troop = None
del breadcrumbs[-1]
baselink = breadcrumbs[-1]["link"]
else:
form = htmlform.HtmlForm('deletetroop', submittext="Radera", buttonType="btn-danger",
descriptionText=u"Vill du verkligen radera avdelningen och all registrerad närvaro?\n"
u"Det går här inte att ångra.")
form.AddField('confirm', '', '', 'hidden')
return render_template('form.html',
heading=section_title,
baselink=baselink,
form=str(form),
breadcrumbs=breadcrumbs)
if key_url == "newperson":
section_title = "Ny person"
baselink += key_url + "/"
breadcrumbs.append({'link': baselink, 'text': section_title})
if request.method == "GET":
return render_template('person.html',
heading=section_title,
baselink=baselink,
breadcrumbs=breadcrumbs,
troop_persons=[],
scoutgroup=scoutgroup,
badge_url="")
elif request.method == "POST":
pnr = request.form['personnummer'].replace('-', '')
if scoutgroup.canAddToWaitinglist():
try:
member_no = scoutnet.AddPersonToWaitinglist(scoutgroup,
request.form['firstname'],
request.form['lastname'],
pnr,
request.form['email'],
request.form["street"],
request.form["zip_code"],
request.form["zip_name"],
request.form['phone'],
request.form['mobile'],
troop,
request.form['anhorig1_name'],
request.form['anhorig1_email'],
request.form['anhorig1_mobile'],
request.form['anhorig1_phone'],
request.form['anhorig2_name'],
request.form['anhorig2_email'],
request.form['anhorig2_mobile'],
request.form['anhorig2_phone'])
if member_no != 0:
person = Person.create(
member_no,
request.form['firstname'],
request.form['lastname'],
pnr)
person.mobile = request.form['mobile']
person.phone = request.form['phone']
person.email = request.form['email']
person.street = request.form["street"]
person.zip_code = request.form["zip_code"]
person.zip_name = request.form["zip_name"]
if "patrol" in request.form:
person.setpatrol(request.form["patrol"])
person.scoutgroup = sgroup_key
person.notInScoutnet = False
person.put()
logging.info("created person %s, id=%d", person.getname(), person.getmembernumber())
troop_person = TroopPerson.create_or_update(troop_key, person.key, False)
troop_person.put()
except scoutnet.ScoutnetException as exp:
return render_template('error.html', error=str(exp))
return redirect(breadcrumbs[-2]['link'])
if request.method == "GET" and request.args and "action" in request.args:
action = request.args["action"]
logging.debug("action %s", action)
if action == "lookupperson":
if scoutgroup is None:
raise ValueError('Missing group')
name = request.args['name'].lower()
if len(name) < 2:
return "[]"
logging.debug("name=%s", name)
json_str = '['
person_counter = 0
for person in Person().query(Person.scoutgroup == sgroup_key).order(Person.removed, Person.firstname, Person.lastname):
if person.getname().lower().find(name) != -1:
if person_counter != 0:
json_str += ', '
json_str += '{"name": "'+person.getnameWithStatus()+'", "url": "' + person.key.urlsafe() + '"}'
person_counter += 1
if person_counter == 8:
break
json_str += ']'
return json_str
elif action == "addperson":
if troop is None or key_url is None:
raise ValueError('Missing troop or person')
person_key = ndb.Key(urlsafe=key_url)
person = person_key.get()
logging.info("adding person=%s to troop=%s", person.getname(), troop.getname())
troop_person = TroopPerson.create_or_update(troop_key, person_key, person.isLeader())
troop_person.put()
return redirect(breadcrumbs[-1]['link'])
elif action == "setsemester":
if user is None or "semester" not in request.args:
raise ValueError('Missing user or semester arg')
semester_url = request.args["semester"]
user.activeSemester = ndb.Key(urlsafe=semester_url)
user.put()
elif action == "removefromtroop" or action == "setasleader" or action == "removeasleader":
if troop is None or key_url is None:
raise ValueError('Missing troop or person')
person_key = ndb.Key(urlsafe=key_url)
tps = TroopPerson.query(TroopPerson.person == person_key, TroopPerson.troop == troop_key).fetch(1)
if len(tps) == 1:
troop_person = tps[0]
if action == "removefromtroop":
troop_person.delete()
else:
troop_person.leader = (action == "setasleader")
troop_person.put()
return "ok"
else:
logging.error('unknown action=%s', action)
return "", 404
if request.method == "POST" and request.form and "action" in request.form:
action = request.form["action"]
if action == "saveattendance":
if troop is None or scoutgroup is None or key_url is None:
raise ValueError('Missing troop or group')
meeting = ndb.Key(urlsafe=key_url).get()
meeting.attendingPersons[:] = [] # clear the list
for person_url in request.form["persons"].split(","):
# logging.debug("person_url=%s", person_url)
if len(person_url) > 0:
person_key = ndb.Key(urlsafe=person_url)
meeting.attendingPersons.append(person_key)
meeting.put()
return "ok"
elif action == "addmeeting" or action == "updatemeeting":
mname = request.form['name']
mdate = request.form['date']
mishike = bool(request.form.get('ishike'))
mtime = request.form['starttime'].replace('.', ':')
dtstring = mdate + "T" + mtime
mduration = request.form['duration']
date_str = datetime.datetime.strptime(dtstring, "%Y-%m-%dT%H:%M")
if action == "addmeeting":
meeting = Meeting.getOrCreate(troop_key,
mname,
date_str,
int(mduration),
mishike)
else:
meeting = ndb.Key(urlsafe=key_url).get()
meeting.name = mname
meeting.datetime = date_str
meeting.duration = int(mduration)
meeting.ishike = mishike
meeting.put()
return redirect(breadcrumbs[-1]['link'])
elif action == "deletemeeting":
meeting = ndb.Key(urlsafe=key_url).get()
logging.debug("deleting meeting=%s", meeting.getname())
meeting.delete()
return redirect(breadcrumbs[-1]['link'])
elif action == "addhike":
mname = request.form['name']
mdate = request.form['date']
mdays = int(request.form['days'])
date_str = datetime.datetime.strptime(mdate, "%Y-%m-%d")
for i in range(mdays):
day_time = date_str + datetime.timedelta(days=i)
meeting = Meeting.getOrCreate(troop_key,
mname,
day_time,
duration=1440, # 24h (needs some value)
ishike=True)
meeting.put()
return redirect(breadcrumbs[-1]['link'])
elif action == "savepatrol":
patrolperson = ndb.Key(urlsafe=request.form['person']).get()
patrolperson.setpatrol(request.form['patrolName'])
patrolperson.put()
return "ok"
elif action == "newtroop":
troopname = request.form['troopname']
troop_id = hash(troopname)
conflict = Troop.get_by_id(Troop.getid(troop_id, scoutgroup.key, user.activeSemester), use_memcache=True)
if conflict is not None:
return "Avdelningen finns redan", 404
troop = Troop.create(troopname, troop_id, scoutgroup.key, user.activeSemester)
troop.put()
troop_key = troop.key
logging.info("created local troop %s", troopname)
action = ""
return redirect(breadcrumbs[-1]['link'])
else:
logging.error('unknown action=%s', action)
return "", 404
# render main pages
if scoutgroup is None:
return render_template('index.html',
heading=section_title,
baselink=baselink,
items=ScoutGroup.getgroupsforuser(user),
breadcrumbs=breadcrumbs)
elif troop_url == "lagerbidrag":
return lagerbidrag.render_lagerbidrag(request, scoutgroup, "group", user=user, sgroup_key=sgroup_key)
elif troop is None:
section_title = 'Avdelningar'
troops = sorted(Troop.getTroopsForUser(sgroup_key, user), key=attrgetter('name'))
troops_badges = [TroopBadge.get_badges_for_troop(trp) for trp in troops]
nr_badge_cols = 5
if len(troops_badges) > 0:
nr_badge_cols = max(5, *[len(tb) for tb in troops_badges])
return render_template('troops.html',
heading=section_title,
baselink=baselink,
scoutgroupbadgeslink='/badges/' + sgroup_url + '/',
scoutgroupinfolink='/scoutgroupinfo/' + sgroup_url + '/',
groupsummarylink='/groupsummary/' + sgroup_url + '/',
gbg_memberlist_csv_link='/persons/' + sgroup_url + '/?gbg_csv',
user=user,
semester=semester,
semesters=Semester.getAllSemestersSorted(),
troops=troops,
nr_badge_cols=nr_badge_cols,
troops_badges=troops_badges,
lagerplats=scoutgroup.default_lagerplats,
breadcrumbs=breadcrumbs)
elif key_url is not None and key_url not in ("dak", "sensus", "lagerbidrag", "excel", "excel_sthlm", "json"):
meeting = ndb.Key(urlsafe=key_url).get()
section_title = meeting.getname()
baselink += key_url + "/"
breadcrumbs.append({'link': baselink, 'text': section_title})
return render_template('meeting.html',
heading=section_title,
baselink=baselink,
existingmeeting=meeting,
breadcrumbs=breadcrumbs,
semester=troop.semester_key.get(),
troop=troop)
else:
meeting_count = 0
sum_male_attendance_count = 0
sum_female_attendance_count = 0
sum_male_leader_attendance_count = 0
sum_female_leader_attendance_count = 0
no_leader_meeting_count = 0
too_small_group_meeting_count = 0
age_problem_count = 0
age_problem_desc = []
section_title = troop.getname()
troop_persons = TroopPerson.getTroopPersonsForTroop(troop_key)
meetings = Meeting.gettroopmeetings(troop_key)
attendances = [] # [meeting][person]
persons = []
persons_dict = {}
for troop_person in troop_persons:
person_key = troop_person.person
person = troop_person.person.get()
persons.append(person)
persons_dict[person_key] = person
year = semester.year
for meeting in meetings:
male_attendance_count = 0
female_attendence_count = 0
male_leader_attendance_count = 0
female_leader_attendence_count = 0
meeting_attendance = []
for troop_person in troop_persons:
is_attending = troop_person.person in meeting.attendingPersons
meeting_attendance.append(is_attending)
if is_attending:
person = persons_dict[troop_person.person]
age = person.getyearsoldthisyear(year)
if troop_person.leader:
if 13 <= age <= 100:
if female_leader_attendence_count + male_leader_attendance_count < 2:
if person.isFemale():
female_leader_attendence_count += 1
else:
male_leader_attendance_count += 1
else:
age_problem_count += 1
age_problem_desc.append(person.getname() + ": " + str(age))
else:
if 7 <= age <= 25:
if person.isFemale():
female_attendence_count += 1
else:
male_attendance_count += 1
else:
age_problem_count += 1
age_problem_desc.append(person.getname() + ": " + str(age))
attendances.append(meeting_attendance)
total_attendance = male_attendance_count+female_attendence_count
# max 40 people
if total_attendance > 40:
surplus_people = total_attendance - 40
removed_men = min(male_attendance_count, surplus_people)
male_attendance_count -= removed_men
surplus_people -= removed_men
female_attendence_count -= surplus_people
max_leaders = 1 if total_attendance <= 10 else 2
total_leaders = female_leader_attendence_count + male_leader_attendance_count
if total_attendance < 3:
too_small_group_meeting_count += 1
else:
if total_leaders == 0:
no_leader_meeting_count += 1
else:
meeting_count += 1
sum_female_attendance_count += female_attendence_count
sum_male_attendance_count += male_attendance_count
if total_leaders > max_leaders:
if male_leader_attendance_count > max_leaders and female_leader_attendence_count == 0:
male_leader_attendance_count = max_leaders
elif male_leader_attendance_count == 0 and female_leader_attendence_count > max_leaders:
female_leader_attendence_count = max_leaders
else:
female_leader_attendence_count = max_leaders / 2
max_leaders -= female_leader_attendence_count
male_leader_attendance_count = max_leaders
sum_female_leader_attendance_count += female_leader_attendence_count
sum_male_leader_attendance_count += male_leader_attendance_count
if key_url in ("dak", "excel", "excel_sthlm", "json"):
dak = DakData()
dak.foerenings_namn = scoutgroup.getname()
dak.forenings_id = scoutgroup.foreningsID
dak.organisationsnummer = scoutgroup.organisationsnummer
dak.kommun_id = scoutgroup.kommunID
dak.kort.namn_paa_kort = troop.getname()
if troop.rapportID is None or troop.rapportID == 0:
troop.rapportID = troop.scoutnetID
troop.put()
dak.kort.naervarokort_nummer = str(troop.get_unique_id())
for troop_person in troop_persons:
p = persons_dict[troop_person.person]
if troop_person.leader:
dak.kort.ledare.append(Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
True, p.email, p.mobile, p.zip_code))
else:
dak.kort.deltagare.append(Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
False, p.email, p.mobile, p.zip_code))
for m in meetings:
if (not scoutgroup.attendance_incl_hike) and m.ishike:
continue
sammankomst = Sammankomst(m.get_short_key(troop), m.datetime, m.duration, m.getname())
for troop_person in troop_persons:
is_attending = troop_person.person in m.attendingPersons
if is_attending:
p = persons_dict[troop_person.person]
if troop_person.leader:
sammankomst.ledare.append(Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
True, p.email, p.mobile, p.zip_code))
else:
sammankomst.deltagare.append(Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
False, p.email, p.mobile, p.zip_code))
dak.kort.sammankomster.append(sammankomst)
if key_url in ("excel", "excel_sthlm"):
if key_url == "excel":
excel_report = ExcelReport(dak, semester)
else:
dak.kort.lokal = scoutgroup.default_lagerplats
excel_report = ExcelReportSthlm(dak, semester)
resultbytes = excel_report.getFilledInExcelSpreadsheet()
response = make_response(resultbytes)
response.headers['Content-Type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
response.headers['Content-Disposition'] = ('attachment; filename=' + urllib.parse.quote(str(dak.kort.namn_paa_kort), safe='') +
'-' + semester.getname() + '.xlsx;')
return response
elif key_url == "json":
json_report = JsonReport(dak, semester)
resultbytes = json_report.get_report_string()
response = make_response(resultbytes)
response.headers['Content-Type'] = json_report.get_mime_type()
response.headers['Content-Disposition'] = 'attachment; filename=' + urllib.parse.quote(json_report.get_filename(), safe='') + ';'
return response
else:
result = render_template('dak.xml', dak=dak)
response = make_response(result)
response.headers['Content-Type'] = 'application/xml'
response.headers['Content-Disposition'] = ('attachment; filename=' + urllib.parse.quote(str(dak.kort.namn_paa_kort), safe='') +
'-' + semester.getname() + '.xml;')
return response
elif key_url == "sensus":
leaders = []
for troop_person in troop_persons:
if troop_person.leader:
leaders.append(troop_person.getname())
patrols = []
for p in persons:
if p.getpatrol() not in patrols:
patrols.append(p.getpatrol())
sensusdata = sensus.SensusData()
sensusdata.foereningsNamn = scoutgroup.getname()
sensusdata.foreningsID = scoutgroup.foreningsID
sensusdata.organisationsnummer = scoutgroup.organisationsnummer
sensusdata.kommunID = scoutgroup.kommunID
sensusdata.verksamhetsAar = semester.getname()
for patrol in patrols:
sensuslista = sensus.SensusLista()
sensuslista.NamnPaaKort = troop.getname() + "/" + patrol
fill_in_leader = 1 # make sure there is space to manually fill in minimum number of ledare.
fill_in_deltagare = 2 # make sure there is space to manually fill in minimum number of deltagare.
for troop_person in troop_persons:
p = persons_dict[troop_person.person]
if p.getpatrol() != patrol:
continue
if troop_person.leader:
sensuslista.ledare.append(sensus.Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
True, p.email, p.mobile))
fill_in_leader -= 1
else:
sensuslista.deltagare.append(sensus.Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(), False))
fill_in_deltagare -= 1
for _ in range(0, fill_in_leader):
sensuslista.ledare.append(sensus.Deltagare('', '', '', '', True, '', ''))
for _ in range(0, fill_in_deltagare):
sensuslista.deltagare.append(sensus.Deltagare('', '', '', '', False, '', ''))
for m in meetings:
sammankomst = sensus.Sammankomst(str(m.key.id()[:50]), m.datetime, m.duration, m.getname())
for troop_person in troop_persons:
p = persons_dict[troop_person.person]
if p.getpatrol() != patrol:
continue
is_attending = troop_person.person in m.attendingPersons
if troop_person.leader:
sammankomst.ledare.append(sensus.Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
True, p.email, p.mobile, is_attending))
else:
sammankomst.deltagare.append(sensus.Deltagare(p.getReportID(), p.firstname, p.lastname, p.getpersonnr(),
False, p.email, p.mobile, is_attending))
for _ in range(0, fill_in_leader):
sammankomst.ledare.append(sensus.Deltagare('', '', '', '', True, '', '', False))
for _ in range(0, fill_in_deltagare):
sammankomst.deltagare.append(sensus.Deltagare('', '', '', '', False, '', '', False))
sensuslista.Sammankomster.append(sammankomst)
sensusdata.listor.append(sensuslista)
result = render_template('sensusnarvaro.html', sensusdata=sensusdata)
response = make_response(result)
return response
elif key_url == "lagerbidrag":
return lagerbidrag.render_lagerbidrag(request, scoutgroup, "troop", trooppersons=troop_persons, troop_key=troop_key)
else:
allowance = []
allowance.append({'name': 'Antal möten:', 'value': meeting_count})
allowance.append({'name': 'Deltagartillfällen', 'value': ''})
allowance.append({'name': 'Kvinnor:', 'value': sum_female_attendance_count})
allowance.append({'name': 'Män:', 'value': sum_male_attendance_count})
allowance.append({'name': 'Ledare Kvinnor:', 'value': sum_female_leader_attendance_count})
allowance.append({'name': 'Ledare Män:', 'value': sum_male_leader_attendance_count})
if no_leader_meeting_count > 0:
allowance.append({'name': 'Antal möten utan ledare', 'value': no_leader_meeting_count})
if too_small_group_meeting_count > 0:
allowance.append({'name': 'Antal möten med för få deltagare', 'value': too_small_group_meeting_count})
if age_problem_count > 0:
allowance.append({'name': 'Ålder utanför intervall:', 'value': age_problem_count})
if age_problem_desc != "":
age_problem_desc_str = ','.join(age_problem_desc[:3])
if len(age_problem_desc) > 3:
age_problem_desc_str += "..."
allowance.append({'name': '', 'value': age_problem_desc_str})
return render_template('troop.html',
heading=section_title,
semestername=semester.getname(),
baselink='/persons/' + scoutgroup.key.urlsafe() + '/',
persons=persons,
trooppersons=troop_persons,
meetings=meetings,
attendances=attendances,
breadcrumbs=breadcrumbs,
allowance=allowance,
troop=troop,
user=user,
semester=semester,
lagerplats=scoutgroup.default_lagerplats
)