-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbadge_templates.py
38 lines (29 loc) · 1.38 KB
/
badge_templates.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
# -*- coding: utf-8 -*-
"""Badge definitions including parts with short and long descriptions."""
import logging
from collections import namedtuple
from flask import Blueprint, render_template, request
from google.appengine.ext import ndb # pylint: disable=import-error
from data import ScoutGroup, TroopPerson, UserPrefs
from data_badge import Badge, BadgePartDone, TroopBadge, BadgeCompleted, ADMIN_OFFSET
badge_templates = Blueprint('badgetemplates_page', __name__, template_folder='templates') # pylint : disable=invalid-name
@badges.route('/')
@badges.route('/<badge_url>/)
def show(badge_url=None):
logging.info("badgetemplates: badge_url=%s", badge_url)
user = UserPrefs.current()
if not user.hasAccess():
return "denied badges", 403
breadcrumbs = [{'link': '/', 'text': 'Hem'}]
section_title = u'Märkesmallar'
breadcrumbs.append({'link': '/badgetemplates', 'text': section_title})
baselink = '/badgetemplates/'
if badge_url is None:
# logging.info("Render list of all badges for scout_group")
section_title = 'Märken för kår'
badges = Badge.get_badges('general')
return render_template('badgelist.html',
heading=section_title,
baselink=baselink,
badges=badges,
breadcrumbs=breadcrumbs)