-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtemplate.py
92 lines (82 loc) · 3.02 KB
/
template.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
"""
ccextractor-web | template.py
Author : Saurabh Shrivastava
Email : saurabh.shrivastava54+ccextractorweb[at]gmail.com
Link : https://github.com/saurabhshri
"""
from datetime import datetime, timezone
from flask import url_for
class LayoutHelper():
def __init__(self, logged_in, details=None, admin=False):
self.entries = {}
self.entries['logged_in'] = "false"
if logged_in:
self.entries['logged_in'] = "true"
self.entries['menu'] = [
{
'display_name': 'Dashboard',
'url': details.dashboard_url,
'icon': 'fa fa-fw fa-dashboard'
},
{
'display_name': 'Files',
'url': details.uploaded_files_url,
'icon': 'fa fa-fw fa-file'
},
{
'display_name': 'Queue',
'url': details.queue_url,
'icon': 'fa fa-fw fa-spinner'
}
]
if details.admin_dashboard:
try:
if details.user_dashboard_url:
self.entries['menu'].append(
{
'display_name': 'User List',
'url': details.user_list_url,
'icon': 'fa fa-fw fa-list'
})
self.entries['menu'].append(
{
'display_name': 'User Dashboard',
'url': details.user_dashboard_url,
'icon': 'fa fa-fw fa-user'
})
except AttributeError:
pass
else:
try:
if details.admin_dashboard_url:
self.entries['menu'].append(
{
'display_name': 'Admin Dashboard',
'url': details.admin_dashboard_url,
'icon': 'fa fa-fw fa-lock'
})
except AttributeError:
pass
else:
self.entries['menu'] = [
{
'display_name': 'Home',
'url': url_for('mod_landing.index'),
'icon': 'fa fa-fw fa-home'
},
{
'display_name': 'Login',
'url': url_for('mod_auth.login'),
'icon': 'fa fa-fw fa-sign-in'
},
{
'display_name': 'SignUp',
'url': 'signup',
'icon': 'fa fa-user-plus'
}
]
now = datetime.now(timezone.utc)
self.entries['year'] = now.year
self.entries['curr_time'] = now
def get_entries(self):
return self.entries