Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add myevents, pastevents code, refined list display on event page

  • Loading branch information...
commit a82b43e5ee76e5fc8ce05bb2316ef05bd57dc48f 1 parent 2b97f8c
@billsaysthis billsaysthis authored
View
5 index.yaml
@@ -12,5 +12,10 @@ indexes:
- kind: Event
properties:
+ - name: member
+ - name: start_time
+
+- kind: Event
+ properties:
- name: status
- name: start_time
View
28 main.py
@@ -139,6 +139,32 @@ def get(self):
tomorrow = today + timedelta(days=1)
self.response.out.write(template.render('templates/approved.html', locals()))
+class MyEventsHandler(webapp.RequestHandler):
+ @util.login_required
+ def get(self):
+ user = users.get_current_user()
+ if user:
+ logout_url = users.create_logout_url('/')
+ else:
+ login_url = users.create_login_url('/')
+ events = Event.all().filter('member = ', user).order('start_time')
+ today = datetime.today()
+ tomorrow = today + timedelta(days=1)
+ is_admin = username(user) in dojo('/groups/events')
+ self.response.out.write(template.render('templates/myevents.html', locals()))
+
+class PastHandler(webapp.RequestHandler):
+ def get(self):
+ user = users.get_current_user()
+ if user:
+ logout_url = users.create_logout_url('/')
+ else:
+ login_url = users.create_login_url('/')
+ today = datetime.today()
+ events = Event.all().filter('start_date < ', today).order('start_time DESC')
+ is_admin = username(user) in dojo('/groups/events')
+ self.response.out.write(template.render('templates/past.html', locals()))
+
class PendingHandler(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
@@ -189,7 +215,9 @@ def main():
application = webapp.WSGIApplication([
('/', ApprovedHandler),
('/events\.(.+)', EventsHandler),
+ ('/past\.(.+)', PastHandler),
('/pending', PendingHandler),
+ ('/myevents', MyEventsHandler),
('/new', NewHandler),
('/event/(\d+).*', EventHandler), ],debug=True)
util.run_wsgi_app(application)
View
1  templates/approved.html
@@ -6,6 +6,7 @@
<div id="primary">
<h3>Upcoming Events</h3>
+ <p><a href='/past'>Past Events</a></p>
{% regroup events by start_date as grouped_events %}
{% for events in grouped_events %}
View
13 templates/event.html
@@ -6,10 +6,11 @@
<div id="primary">
<h3><a href='{{event.url}}'>{{event.name|title}}</a></h3>
- <p><form method="post" style="display: inline;">
- {% if can_approve %}<input type="submit" name="state" value="Approve" />{% endif %}
- {% if is_admin %}<input type="submit" name="state" value="Cancel" />{% endif %}
- {% if can_staff %}<input type="submit" name="state" value="Staff" />{% endif %}
+ <p>
+ <form method="post" style="display: inline;">
+ {% if can_approve %}<input type="submit" name="state" value="Approve" />{% endif %}
+ {% if is_admin %}<input type="submit" name="state" value="Cancel" />{% endif %}
+ {% if can_staff %}<input type="submit" name="state" value="Staff" />{% endif %}
</form>
</p>
@@ -20,8 +21,8 @@
<div class='b-block'><div class='b-label'>Estimated size:</div><div class='b-data'>{{event.estimated_size}}</div></div>
<div class='b-block'><div class='b-label'>Contact:</div><div class='b-data'>{{event.contact_name}}, {{event.contact_phone}}</div></div>
<div class='b-block'><div class='b-label'>Fee:</div><div class='b-data'>{{event.fee}}</div></div>
- <div class='b-block'><div class='b-label'>Rooms:</div><div class='b-data'>{% for room in event.rooms %}{{room}}, {% endfor %}</div></div>
- <div class='b-block'><div class='b-label'>Staff:</div><div class='b-data'>{% for staffer in event.staff %}{{staffer}}, {% endfor %}</div></div>
+ <div class='b-block'><div class='b-label'>Rooms:</div><div class='b-data'>{% for room in event.rooms %}{{room}}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}</div></div>
+ <div class='b-block'><div class='b-label'>Staff:</div><div class='b-data'>{% for staffer in event.staff %}{{staffer}}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}</div></div>
<div class='thin-border'></div>
<div class='b-block'><div class='b-label'>Details:</div><div class='b-data'>{{event.details}}</div></div>
<br />
View
22 templates/myevents.html
@@ -0,0 +1,22 @@
+{% extends 'base.html' %}
+{% block content %}
+<div id="menu" style="float: right; margin: 10px; font-size: smaller;">
+ <a href="/">Approved</a> | Pending | <a href="/new" style="font-weight: bold;">New Event</a>
+</div>
+
+<div id="primary">
+ <h3>My Events</h3>
+ {% regroup events by start_date as grouped_events %}
+ {% for events in grouped_events %}
+ <h4>{% ifequal events.grouper today.date %}<span style="text-decoration:underline;">Today</span> - {% endifequal %}{% ifequal events.grouper tomorrow.date %}<span style="text-decoration:underline;">Tomorrow</span> - {% endifequal %}{{events.grouper|date:"l, F j"}}</h4>
+ <table>
+ {% for event in events.list %}
+ <tr><td width="75">{{event.start_time|date:"g:iA"|lower}}</td><td><a href="/event/{{event.key.id}}-{{event.name|slugify}}">{{event.name}}</a></td></tr>
+ {% endfor %}
+ </table>
+ {% endfor %}
+
+</div>
+
+
+{% endblock %}
View
25 templates/past.html
@@ -0,0 +1,25 @@
+{% extends 'base.html' %}
+{% block content %}
+<div id="menu" style="float: right; margin: 10px; font-size: smaller;">
+ Approved | <a href="/pending">Pending</a> | <a href="/new" style="font-weight: bold;">New Event</a>
+</div>
+
+<div id="primary">
+ <h3>Past Events</h3>
+ <p><a href='/'>Upcoming Events</a></p>
+
+ {% regroup events by start_date as grouped_events %}
+ {% for events in grouped_events %}
+ <h4>{% ifequal events.grouper today.date %}<span style="text-decoration:underline;">Today</span> - {% endifequal %}{{events.grouper|date:"l, F j"}}</h4>
+ <table>
+ {% for event in events.list %}
+ <tr><td width="75">{{event.start_time|date:"g:iA"|lower}}</td><td><a {% if event.is_canceled %}style="text-decoration: line-through;"{% endif %} href="/event/{{event.key.id}}-{{event.name|slugify}}">{{event.name}}</a> {% if event.is_canceled %}<span style="color: white; font-size: x-small; padding: 2px; background: gray">canceled</span>{% endif %}</td></tr>
+ {% endfor %}
+ </table>
+ {% endfor %}
+
+ <p style="font-size: x-small">Alternative formats: <a href="/events.ics">iCal</a> | RSS | JSON</p>
+</div>
+
+
+{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.