-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavigation.py
123 lines (103 loc) · 4.62 KB
/
navigation.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
import os
import webapp2
import jinja2
from google.appengine.ext import ndb
from google.appengine.api import users
import logging
template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.getcwd()))
from tasks import Tasks
class SidebarHandler(webapp2.RequestHandler):
"""
Check if the User Logged in load all defaults for the user on the sidebar including username
profile information and others
Sidebar variables
vstrUsername
vstrLogoutURL
vstrLoginURL
"""
def get(self):
Guser = users.get_current_user()
vstrLogoutURL = users.create_logout_url(dest_url="/")
vstrLoginURL = users.create_login_url(dest_url="/")
if Guser:
vstrUsername = Guser.nickname()
template = template_env.get_template('templates/dynamic/navigation/sidebar.html')
context = {'vstrUsername': vstrUsername,
'vstrLogoutURL': vstrLogoutURL}
self.response.write(template.render(context))
else:
template = template_env.get_template('templates/dynamic/navigation/sidebar.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class AdminSideBar(webapp2.RequestHandler):
def get(self):
Guser = users.get_current_user()
vstrLogoutURL = users.create_logout_url(dest_url="/")
vstrLoginURL = users.create_login_url(dest_url="/")
if Guser:
vstrUsername = Guser.nickname()
template = template_env.get_template('templates/dynamic/admin/navigation/sidebar.html')
context = {'vstrUsername': vstrUsername,
'vstrLogoutURL': vstrLogoutURL}
self.response.write(template.render(context))
else:
template = template_env.get_template('templates/dynamic/admin/navigation/sidebar.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class HeaderHandler(webapp2.RequestHandler):
"""
Header Variables
vstrUsername
vstrDesignation
vstrTotalMessages
vstrTotalNotifications
vstrTotalTasks
vstrLogoutURL
"""
def get(self):
Guser = users.get_current_user()
if Guser:
vstrUsername = Guser.nickname()
vstrLogoutURL = users.create_logout_url(dest_url="/")
findRequest = Tasks.query(Tasks.strToReference == Guser.user_id())
TaskList = findRequest.fetch()
vstrTotalTasks = len(TaskList)
template = template_env.get_template('templates/dynamic/navigation/header.html')
context = {'vstrUsername': vstrUsername, 'vstrLogoutURL': vstrLogoutURL,
'TaskList':TaskList,'vstrTotalTasks':vstrTotalTasks}
self.response.write(template.render(context))
else:
vstrLoginURL = users.create_login_url(dest_url="/")
template = template_env.get_template('templates/dynamic/navigation/header.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class AdminHeader(webapp2.RequestHandler):
def get(self):
Guser = users.get_current_user()
if Guser:
vstrUsername = Guser.nickname()
vstrLogoutURL = users.create_logout_url(dest_url="/")
findRequest = Tasks.query(Tasks.strToReference == Guser.user_id())
TaskList = findRequest.fetch()
vstrTotalTasks = len(TaskList)
template = template_env.get_template('templates/dynamic/admin/navigation/header.html')
context = {'vstrUsername': vstrUsername,'vstrLogoutURL': vstrLogoutURL,
'TaskList':TaskList,'vstrTotalTasks':vstrTotalTasks}
self.response.write(template.render(context))
else:
vstrLoginURL = users.create_login_url(dest_url="/")
template = template_env.get_template('templates/dynamic/admin/navigation/header.html')
context = {'vstrLoginURL': vstrLoginURL}
self.response.write(template.render(context))
class FooterHandler(webapp2.RequestHandler):
def get(self):
template = template_env.get_template('templates/dynamic/navigation/footer.html')
context = {}
self.response.write(template.render(context))
app = webapp2.WSGIApplication([
('/navigation/sidebar', SidebarHandler),
('/navigation/admin/header',AdminHeader),
('/navigation/header', HeaderHandler),
('/navigation/admin/sidebar',AdminSideBar),
('/navigation/footer', FooterHandler)
], debug=True)