150 else: |
150 else: |
151 last_day_of_month = date(year, month + 1, 1) - timedelta(1) |
151 last_day_of_month = date(year, month + 1, 1) - timedelta(1) |
152 lastday = last_day_of_month + timedelta(6 - last_day_of_month.weekday()) |
152 lastday = last_day_of_month + timedelta(6 - last_day_of_month.weekday()) |
153 month_dates = list(date_range(firstday, lastday)) |
153 month_dates = list(date_range(firstday, lastday)) |
154 dates = {} |
154 dates = {} |
155 users = [] |
|
156 task_max = 0 |
155 task_max = 0 |
157 for row in xrange(self.rset.rowcount): |
156 for row in xrange(self.rset.rowcount): |
158 task = self.rset.get_entity(row, 0) |
157 task = self.rset.get_entity(row, 0) |
159 if len(self.rset[row]) > 1 and self.rset.description[row][1] == 'EUser': |
158 if len(self.rset[row]) > 1 and self.rset.description[row][1] == 'EUser': |
160 user = self.rset.get_entity(row, 1) |
159 user = self.rset.get_entity(row, 1) |
261 year=prevdate.year, month=prevdate.month) |
260 year=prevdate.year, month=prevdate.month) |
262 nextlink = ajax_replace_url('onemonthcalid', rql, 'onemonthcal', |
261 nextlink = ajax_replace_url('onemonthcalid', rql, 'onemonthcal', |
263 year=nextdate.year, month=nextdate.month) |
262 year=nextdate.year, month=nextdate.month) |
264 return prevlink, nextlink |
263 return prevlink, nextlink |
265 |
264 |
266 def _build_calendar_cell(self, date, rows, curdate): |
265 def _build_calendar_cell(self, celldate, rows, curdate): |
267 curmonth = curdate.month |
266 curmonth = curdate.month |
268 classes = "" |
267 classes = "" |
269 if date.month != curmonth: |
268 if celldate.month != curmonth: |
270 classes += " outOfRange" |
269 classes += " outOfRange" |
271 if date == datetime.today(): |
270 if celldate == date.today(): |
272 classes += " today" |
271 classes += " today" |
273 self.w(u'<td class="cell%s">' % classes) |
272 self.w(u'<td class="cell%s">' % classes) |
274 self.w(u'<div class="calCellTitle%s">' % classes) |
273 self.w(u'<div class="calCellTitle%s">' % classes) |
275 self.w(u'<div class="day">%s</div>' % date.day) |
274 self.w(u'<div class="day">%s</div>' % celldate.day) |
276 |
275 |
277 if len(self.rset.column_types(0)) == 1: |
276 if len(self.rset.column_types(0)) == 1: |
278 etype = list(self.rset.column_types(0))[0] |
277 etype = list(self.rset.column_types(0))[0] |
279 url = self.build_url(vid='creation', etype=etype, |
278 url = self.build_url(vid='creation', etype=etype, |
280 schedule=True, |
279 schedule=True, |
281 start=self.format_date(date), stop=self.format_date(date), |
280 start=self.format_date(celldate), stop=self.format_date(celldate), |
282 __redirectrql=self.rset.printable_rql(), |
281 __redirectrql=self.rset.printable_rql(), |
283 __redirectparams=self.req.build_url_params(year=curdate.year, month=curmonth), |
282 __redirectparams=self.req.build_url_params(year=curdate.year, month=curmonth), |
284 __redirectvid=self.id |
283 __redirectvid=self.id |
285 ) |
284 ) |
286 self.w(u'<div class="cmd"><a href="%s">%s</a></div>' % (html_escape(url), self.req._(u'add'))) |
285 self.w(u'<div class="cmd"><a href="%s">%s</a></div>' % (html_escape(url), self.req._(u'add'))) |
432 self.w(u'</tr>') |
431 self.w(u'</tr>') |
433 self.w(u'</table></div>') |
432 self.w(u'</table></div>') |
434 self.w(u'<div id="coord"></div>') |
433 self.w(u'<div id="coord"></div>') |
435 self.w(u'<div id="debug"> </div>') |
434 self.w(u'<div id="debug"> </div>') |
436 |
435 |
437 def _one_day_task(self, task): |
|
438 """ |
|
439 Return true if the task is a "one day" task; ie it have a start and a stop the same day |
|
440 """ |
|
441 if task.start and task.stop: |
|
442 if task.start.isocalendar() == task.stop.isocalendar(): |
|
443 return True |
|
444 return False |
|
445 |
|
446 def _build_calendar_cell(self, date, task_descrs): |
436 def _build_calendar_cell(self, date, task_descrs): |
447 inday_tasks = [t for t in task_descrs if t.is_one_day_task() and t.in_working_hours()] |
437 inday_tasks = [t for t in task_descrs if t.is_one_day_task() and t.in_working_hours()] |
448 wholeday_tasks = [t for t in task_descrs if not t.is_one_day_task()] |
438 wholeday_tasks = [t for t in task_descrs if not t.is_one_day_task()] |
449 inday_tasks.sort(key=lambda t:t.task.start) |
439 inday_tasks.sort(key=lambda t:t.task.start) |
450 sorted_tasks = [] |
440 sorted_tasks = [] |