This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
templates.py
48 lines (42 loc) · 1.55 KB
/
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
39
40
41
42
43
44
45
46
47
48
import layouts
class Template(object):
pdf = None
name = None
description = None
creator = None
link = None
layouts = []
class BerniePartyTwoUp(Template):
name = "Bernie Party 2-up"
description = "Go Bernie Go! A 2-up debate watching invite."
creator = "Gavin MacPherson"
layouts = [layouts.BerniePartyTwoUp]
class DebateWatch(Template):
name = "Debate Watch!"
description = "A large flyer that fits many debate watch events."
creator = "Flyers for Bernie"
layouts = [layouts.TwoColumnLayout]
class Bernie2016Plain(Template):
name = "Plain Bernie"
description = "A large, plain flyer with logo. Great for many events or featured events."
creator = "Chris Estrada"
layouts = [layouts.TwoColumnLayout, layouts.FeaturedLayout]
cached_templates = None
def templates():
global cached_templates
if cached_templates is None:
cached_templates = {c.__name__: c for c in Template.__subclasses__()}
return cached_templates
cached_templates_dict = None
def templates_dict():
global cached_templates_dict
if cached_templates_dict is None:
ts = []
for t in Template.__subclasses__():
ls = []
for l in t.layouts:
ls.append({ "id": l.__name__, "name": l.name, "description": l.description, "events": l.events })
ts.append({ "id": t.__name__, "name": t.name, "description": t.description, "creator": t.creator,
"link": t.link, "layouts": ls })
cached_templates_dict = ts
return cached_templates_dict