-
Notifications
You must be signed in to change notification settings - Fork 0
/
rifflist.py
executable file
·77 lines (59 loc) · 1.89 KB
/
rifflist.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
import os
import cgi
import datetime
import urllib
import wsgiref.handlers
from google.appengine.ext.webapp import template
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import model;
class ListAllPage(webapp.RequestHandler):
def get(self):
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
logged = True
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
logged = False
riffs = model.Riff.all().order('-date')
template_values = {
'riffs': riffs,
'ControllerId' : 'list',
'ControllerName' : 'List of riffs',
'url' : url,
'url_linktext' : url_linktext,
'edit' : False,
'logged' : logged
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
class ListMyPage(webapp.RequestHandler):
def get(self):
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
logged = True
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
logged = False
riffs = model.Riff.all().order('-date')
my = self.request.get('my')
if not users.get_current_user():
self.redirect(url)
riffs.filter('author =', users.get_current_user())
template_values = {
'riffs': riffs,
'ControllerId' : 'list',
'ControllerName' : 'List of riffs',
'url' : url,
'url_linktext' : url_linktext,
'edit' : True,
'logged' : logged
}
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))