equal
deleted
inserted
replaced
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """html timetable views""" |
18 """html timetable views""" |
19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 _ = unicode |
21 _ = unicode |
|
22 |
|
23 from six.moves import range |
22 |
24 |
23 from logilab.mtconverter import xml_escape |
25 from logilab.mtconverter import xml_escape |
24 from logilab.common.date import ONEDAY, date_range, todatetime |
26 from logilab.common.date import ONEDAY, date_range, todatetime |
25 |
27 |
26 from cubicweb.predicates import adaptable |
28 from cubicweb.predicates import adaptable |
49 self._cw.add_css('cubicweb.timetable.css') |
51 self._cw.add_css('cubicweb.timetable.css') |
50 dates = {} |
52 dates = {} |
51 users = [] |
53 users = [] |
52 users_max = {} |
54 users_max = {} |
53 # XXX: try refactoring with calendar.py:OneMonthCal |
55 # XXX: try refactoring with calendar.py:OneMonthCal |
54 for row in xrange(self.cw_rset.rowcount): |
56 for row in range(self.cw_rset.rowcount): |
55 task = self.cw_rset.get_entity(row, 0) |
57 task = self.cw_rset.get_entity(row, 0) |
56 icalendarable = task.cw_adapt_to('ICalendarable') |
58 icalendarable = task.cw_adapt_to('ICalendarable') |
57 if len(self.cw_rset[row]) > 1 and self.cw_rset.description[row][1] == 'CWUser': |
59 if len(self.cw_rset[row]) > 1 and self.cw_rset.description[row][1] == 'CWUser': |
58 user = self.cw_rset.get_entity(row, 1) |
60 user = self.cw_rset.get_entity(row, 1) |
59 else: |
61 else: |
86 date_max = max(dates) |
88 date_max = max(dates) |
87 #users = list(sorted(users, key=lambda u:u.login)) |
89 #users = list(sorted(users, key=lambda u:u.login)) |
88 |
90 |
89 rows = [] |
91 rows = [] |
90 # colors here are class names defined in cubicweb.css |
92 # colors here are class names defined in cubicweb.css |
91 colors = ["col%x" % i for i in xrange(12)] |
93 colors = ["col%x" % i for i in range(12)] |
92 next_color_index = 0 |
94 next_color_index = 0 |
93 |
95 |
94 visited_tasks = {} # holds a description of a task for a user |
96 visited_tasks = {} # holds a description of a task for a user |
95 task_colors = {} # remember a color assigned to a task |
97 task_colors = {} # remember a color assigned to a task |
96 for date in date_range(date_min, date_max + ONEDAY): |
98 for date in date_range(date_min, date_max + ONEDAY): |