forked from Gig-o-Matic/GO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivity.py
More file actions
62 lines (49 loc) · 1.71 KB
/
activity.py
File metadata and controls
62 lines (49 loc) · 1.71 KB
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
#
#
# Activity page: show recent changes to member plans for gigs
#
from google.appengine.api import users
from requestmodel import *
import webapp2
import member
import gig
import plan
import band
import assoc
import logging
from debug import debug_print
import datetime
class MainPage(BaseHandler):
@user_required
def get(self):
""" get handler for agenda view """
self._make_page(the_user=self.user)
def _make_page(self, the_user):
""" construct page for activity view """
the_band_key_urlsafe = self.request.get("bk", '0')
if the_band_key_urlsafe == '0':
return
else:
the_band_key = ndb.Key(urlsafe=the_band_key_urlsafe)
if the_band_key is None:
self.response.write('did not find a band!')
return # todo figure out what to do if we didn't find it
# get all of the plans related to this band key that changed in the last day
the_changed_plans = plan.get_recent_changes_for_band_key(
the_band_key=the_band_key, the_time_delta_days=1, keys_only=False)
# sort the plans by gig
change_gigs = {}
for a_plan in the_changed_plans:
the_change_gig = a_plan.key.parent()
if the_change_gig in change_gigs:
change_gigs[the_change_gig] = change_gigs[the_change_gig].append(a_plan)
else:
change_gigs[the_change_gig] = [a_plan]
print "\nactivity:"
print '{0}'.format(change_gigs)
print "\n"
template_args = {
'the_band' : the_band_key.get(),
'change_gigs' : change_gigs
}
self.render_template('band_activity.html', template_args)