Skip to content
This repository

Implemented a nice little fix for HTML <title> on the events page #37

Merged
merged 4 commits into from over 2 years ago

2 participants

Brian Klug Geo Mealer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
18 main.py
@@ -77,7 +77,7 @@ def get(self, format):
77 77 self.response.out.write(body)
78 78
79 79 def export_json(self):
80   - events = Event.get_approved_list()
  80 + events = Event.get_recent_past_and_future()
81 81 for k in self.request.GET:
82 82 if self.request.GET[k] and k in ['member']:
83 83 value = users.User(urllib.unquote(self.request.GET[k]))
@@ -88,7 +88,7 @@ def export_json(self):
88 88 return 'application/json', simplejson.dumps(events)
89 89
90 90 def export_ics(self):
91   - events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
  91 + events = Event.get_recent_past_and_future()
92 92 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
93 93 cal = Calendar()
94 94 for event in events:
@@ -121,7 +121,7 @@ def export_ics(self):
121 121 return 'text/calendar', cal.as_string()
122 122
123 123 def export_large_ics(self):
124   - events = Event.get_large_list()
  124 + events = Event.get_recent_past_and_future()
125 125 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
126 126 cal = Calendar()
127 127 for event in events:
@@ -155,7 +155,7 @@ def export_large_ics(self):
155 155
156 156 def export_rss(self):
157 157 url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
158   - events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
  158 + events = Event.get_recent_past_and_future()
159 159 rss = PyRSS2Gen.RSS2(
160 160 title = "Hacker Dojo Events Feed",
161 161 link = url_base,
@@ -204,7 +204,10 @@ def post(self, id):
204 204 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
205 205 conflicts = Event.check_conflict(start_time,end_time,self.request.get_all('rooms'), int(id))
206 206 if conflicts:
207   - raise ValueError('Room conflict detected')
  207 + if "Deck" in self.request.get_all('rooms') or "Savanna" in self.request.get_all('rooms'):
  208 + raise ValueError('Room conflict detected <small>(Note: Deck &amp; Savanna share the same area, two events cannot take place at the same time in these rooms.)</small>')
  209 + else:
  210 + raise ValueError('Room conflict detected')
208 211 if not self.request.get('estimated_size').isdigit():
209 212 raise ValueError('Estimated number of people must be a number')
210 213 if not int(self.request.get('estimated_size')) > 0:
@@ -447,7 +450,10 @@ def post(self):
447 450 self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
448 451 conflicts = Event.check_conflict(start_time,end_time,self.request.get_all('rooms'))
449 452 if conflicts:
450   - raise ValueError('Room conflict detected')
  453 + if "Deck" in self.request.get_all('rooms') or "Savanna" in self.request.get_all('rooms'):
  454 + raise ValueError('Room conflict detected <small>(Note: Deck &amp; Savanna share the same area, two events cannot take place at the same time in these rooms.)</small>')
  455 + else:
  456 + raise ValueError('Room conflict detected')
451 457 if not self.request.get('estimated_size').isdigit():
452 458 raise ValueError('Estimated number of people must be a number')
453 459 if not int(self.request.get('estimated_size')) > 0:
12 models.py
@@ -48,6 +48,10 @@ def check_conflict(cls,proposed_start_time,proposed_end_time,proposed_rooms,opti
48 48 .filter('end_time >', proposed_start_time) \
49 49 .filter('status IN', ['approved', 'pending', 'onhold'])
50 50 conflicts = []
  51 + if 'Deck' in proposed_rooms and 'Savanna' not in proposed_rooms:
  52 + proposed_rooms.append('Savanna')
  53 + if 'Savanna' in proposed_rooms and 'Deck' not in proposed_rooms:
  54 + proposed_rooms.append('Deck')
51 55 for e in possible_conflicts:
52 56 if e.key().id() != optional_existing_event_id:
53 57 if e.start_time < proposed_end_time:
@@ -78,10 +82,18 @@ def get_large_list(cls):
78 82 def get_approved_list(cls):
79 83 return cls.all() \
80 84 .filter('start_time >', local_today()) \
  85 + # .filter('start_time <', local_today() + timedelta(days=60)) \
81 86 .filter('status IN', ['approved', 'canceled']) \
82 87 .order('start_time')
83 88
84 89 @classmethod
  90 + def get_recent_past_and_future(cls):
  91 + return cls.all() \
  92 + .filter('start_time >', local_today() - timedelta(days=2)) \
  93 + .filter('status IN', ['approved', 'canceled']) \
  94 + .order('start_time').fetch(200)
  95 +
  96 + @classmethod
85 97 def get_pending_list(cls):
86 98 return cls.all() \
87 99 .filter('start_time >', local_today()) \
2  templates/base.html
... ... @@ -1,6 +1,6 @@
1 1 <html>
2 2 <head>
3   - <title>Events at Hacker Dojo</title>
  3 + <title>{% block title %}Events at Hacker Dojo{% endblock %}</title>
4 4 <link href="/static/style.css" type="text/css" rel="stylesheet" />
5 5 {% block feed %}
6 6 <link rel="alternate" type="application/xml" title="Hacker Dojo events feed" href="/events.rss" />
1  templates/event.html
... ... @@ -1,4 +1,5 @@
1 1 {% extends 'base.html' %}
  2 +{% block title %}{{event.name|title}}{% endblock %}
2 3 {% block content %}
3 4
4 5 <div id="primary">

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.