1 """ |
1 """ |
2 Our URL action handlers |
2 Our URL action handlers |
3 """ |
3 """ |
4 |
4 |
5 import pytz |
5 import datetime, calendar, pytz |
6 |
6 |
7 from qmsk.web import http, template |
7 from qmsk.web import http, template |
8 |
8 |
9 import urls, channels, helpers |
9 import urls, channels, helpers |
10 import preferences as prefs |
10 import preferences as prefs |
11 from preferences import preferences |
11 from preferences import preferences |
12 |
12 |
13 # load templates from here |
13 # load templates from here |
14 templates = template.TemplateLoader("templates", |
14 templates = template.TemplateLoader("templates", |
15 h = helpers, |
15 _helper_class = helpers.Helpers, |
16 urls = urls, |
16 urls = urls, |
17 channel_list = channels.channel_list, |
17 channel_list = channels.channel_list, |
18 ) |
18 ) |
19 |
19 |
20 def index (request) : |
20 def index (request) : |
31 Redirect to the appropriate channel_view |
31 Redirect to the appropriate channel_view |
32 """ |
32 """ |
33 |
33 |
34 return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
34 return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
35 |
35 |
36 @preferences.handler(prefs.Formatter) |
36 @preferences.handler(prefs.Formatter, prefs.Timezone) |
37 def channel_view (request, channel, count, formatter) : |
37 def channel_view (request, channel, count, formatter, timezone) : |
38 """ |
38 """ |
39 The main channel view page, display the most important info, and all requisite links |
39 The main channel view page, display the most important info, and all requisite links |
40 """ |
40 """ |
41 |
41 |
42 # get latest events |
42 # get latest events |
64 pass |
65 pass |
65 |
66 |
66 else : |
67 else : |
67 raise http.ResponseError("Unknown filetype %r" % format) |
68 raise http.ResponseError("Unknown filetype %r" % format) |
68 |
69 |
69 def channel_calendar (request, channel) : |
70 @preferences.handler(prefs.Timezone) |
|
71 def channel_calendar (request, channel, year, month, timezone) : |
70 """ |
72 """ |
71 Display a list of avilable logs for some days |
73 Display a list of avilable logs for some month |
72 """ |
74 """ |
73 |
75 |
74 pass |
76 # current date as default |
|
77 now = timezone.localize(datetime.datetime.now()) |
|
78 |
|
79 # target year/month |
|
80 target = timezone.localize(datetime.datetime( |
|
81 year = year if year else now.year, |
|
82 month = month if month else now.month, |
|
83 day = 1 |
|
84 )) |
|
85 |
|
86 # get set of days available |
|
87 days = channel.source.get_month_days(target) |
|
88 |
|
89 # display calendar |
|
90 return templates.render_to_response("channel_calendar", |
|
91 req = request, |
|
92 timezone = timezone, |
|
93 channel = channel, |
|
94 calendar = calendar.Calendar(), |
|
95 month = target.date(), |
|
96 days = days, |
|
97 ) |
75 |
98 |
76 @preferences.handler(prefs.Formatter, prefs.Timezone) |
99 @preferences.handler(prefs.Formatter, prefs.Timezone) |
77 def channel_date (request, channel, date, formatter, timezone) : |
100 def channel_date (request, channel, date, formatter, timezone) : |
78 """ |
101 """ |
79 Display all log data for the given date |
102 Display all log data for the given date |