forked from sydney-linux-user-group/slug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.py
93 lines (65 loc) · 2.46 KB
/
events.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
#!/usr/bin/python
#
# -*- coding: utf-8 -*-
# vim: set ts=4 sw=4 et sts=4 ai:
"""Module for viewing the events."""
import config
config.setup()
from google.appengine.api import users
from google.appengine.ext import webapp
from aeoid import users as openid_users
import datetime
import models
import event_lists
from utils.render import render as r
class Next(webapp.RequestHandler):
"""Figure out the next event, then redirect to it."""
def get(self):
self.redirect(event_lists.get_next_event().get_url())
class Event(webapp.RequestHandler):
"""Handler for display a single event."""
def get(self, key=None):
# We are using locals which confuses pylint.
# pylint: disable-msg=W0612
if not key:
key = self.request.get('id')
key = long(key)
event = models.Event.get_by_id(key)
current_user = users.get_current_user()
response, guests = event_lists.get_event_responses(event, current_user)
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(r(
'templates/event.html', locals()))
class Agenda(webapp.RequestHandler):
"""Handler for displaying the agenda for a single event."""
def get (self, key=None):
if not key:
key = self.request.get('id')
key = long(key)
event = models.Event.get_by_id(key)
agenda = event.agenda
template_values = {}
template_values['agenda'] = agenda
template_values['self'] = self
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(r(
'templates/countdown.html', template_values))
class Events(webapp.RequestHandler):
"""Handler for display a table of events."""
template = "templates/events.html"
published_only = False
def get(self, year=None, month=None, day=None):
# We are using locals which confuses pylint.
# pylint: disable-msg=W0613,W0612
now = datetime.datetime.now()
if users.is_current_user_admin():
published_only = False
else:
published_only = True
current_user = users.get_current_user()
events_lists = event_lists.get_event_lists(
published_only=published_only, user=current_user)
next_event = event_lists.get_next_event()
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(r(
self.template, locals()))