equal
deleted
inserted
replaced
5 import pytz |
5 import 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 |
|
11 from preferences import preferences |
10 |
12 |
11 # load templates from here |
13 # load templates from here |
12 templates = template.TemplateLoader("templates", |
14 templates = template.TemplateLoader("templates", |
13 h = helpers, |
15 h = helpers, |
14 urls = urls, |
16 urls = urls, |
29 Redirect to the appropriate channel_view |
31 Redirect to the appropriate channel_view |
30 """ |
32 """ |
31 |
33 |
32 return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
34 return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
33 |
35 |
|
36 @preferences.handler(prefs.Formatter) |
34 def channel_view (request, channel, count, formatter) : |
37 def channel_view (request, channel, count, formatter) : |
35 """ |
38 """ |
36 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 |
37 """ |
40 """ |
38 |
41 |
39 # get latest events |
42 # get latest events |
40 lines = channel.source.get_latest(count) |
43 lines = channel.source.get_latest(count) |
41 |
44 |
42 # formatter |
|
43 formatter = formatter(pytz.utc, '%H:%M:%S') |
|
44 |
|
45 # lines |
45 # lines |
46 lines = formatter.format_html(lines) |
46 lines = formatter.format_html(lines) |
47 |
47 |
48 return templates.render_to_response("channel_view", |
48 return templates.render_to_response("channel_view", |
49 req = request, |
49 req = request, |
71 Display a list of avilable logs for some days |
71 Display a list of avilable logs for some days |
72 """ |
72 """ |
73 |
73 |
74 pass |
74 pass |
75 |
75 |
76 def channel_date (request, channel, date, formatter) : |
76 @preferences.handler(prefs.Formatter, prefs.Timezone) |
|
77 def channel_date (request, channel, date, formatter, timezone) : |
77 """ |
78 """ |
78 Display all log data for the given date |
79 Display all log data for the given date |
79 """ |
80 """ |
80 |
81 |
81 # XXX: fix date timezone |
82 # fix date timezone |
82 date = date.replace(tzinfo=pytz.utc) |
83 date = date.replace(tzinfo=timezone) |
83 |
84 |
84 # get latest events |
85 # get latest events |
85 lines = channel.source.get_date(date) |
86 lines = channel.source.get_date(date) |
86 |
87 |
87 # formatter |
|
88 formatter = formatter(pytz.utc, '%H:%M:%S') |
|
89 |
|
90 # lines |
88 # lines |
91 lines = formatter.format_html(lines) |
89 lines = formatter.format_html(lines) |
92 |
90 |
93 return templates.render_to_response("channel_date", |
91 return templates.render_to_response("channel_date", |
94 req = request, |
92 req = request, |