1 """Specific views for entities implementing IProgress |
1 """Specific views for entities implementing IProgress |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 |
7 |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from logilab.mtconverter import html_escape |
10 from logilab.mtconverter import html_escape |
11 |
11 |
|
12 from cubicweb.selectors import implements, accept |
12 from cubicweb.interfaces import IProgress, IMileStone |
13 from cubicweb.interfaces import IProgress, IMileStone |
13 from cubicweb.schema import display_name |
14 from cubicweb.schema import display_name |
14 from cubicweb.common.view import EntityView |
15 from cubicweb.common.view import EntityView |
15 from cubicweb.common.selectors import implement_interface, accept |
|
16 from cubicweb.web.htmlwidgets import ProgressBarWidget |
16 from cubicweb.web.htmlwidgets import ProgressBarWidget |
17 |
17 |
18 |
18 |
19 class ProgressTableView(EntityView): |
19 class ProgressTableView(EntityView): |
20 """The progress table view is able to display progress information |
20 """The progress table view is able to display progress information |
33 header_for_COLNAME methods allow to customize header's label |
33 header_for_COLNAME methods allow to customize header's label |
34 """ |
34 """ |
35 |
35 |
36 id = 'progress_table_view' |
36 id = 'progress_table_view' |
37 title = _('task progression') |
37 title = _('task progression') |
38 __selectors__ = (accept, implement_interface) |
38 __selectors__ = implements(IMileStone) |
39 |
|
40 accepts_interfaces = (IMileStone,) |
|
41 |
39 |
42 # default columns of the table |
40 # default columns of the table |
43 columns = (_('project'), _('milestone'), _('state'), _('eta_date'), |
41 columns = (_('project'), _('milestone'), _('state'), _('eta_date'), |
44 _('cost'), _('progress'), _('todo_by')) |
42 _('cost'), _('progress'), _('todo_by')) |
45 |
43 |
180 |
178 |
181 class ProgressBarView(EntityView): |
179 class ProgressBarView(EntityView): |
182 """displays a progress bar""" |
180 """displays a progress bar""" |
183 id = 'progressbar' |
181 id = 'progressbar' |
184 title = _('progress bar') |
182 title = _('progress bar') |
185 __selectors__ = (accept, implement_interface) |
183 __selectors__ = implements(IProgress) |
186 |
|
187 accepts_interfaces = (IProgress,) |
|
188 |
184 |
189 def cell_call(self, row, col): |
185 def cell_call(self, row, col): |
190 self.req.add_css('cubicweb.iprogress.css') |
186 self.req.add_css('cubicweb.iprogress.css') |
191 entity = self.entity(row, col) |
187 entity = self.entity(row, col) |
192 widget = ProgressBarWidget(entity.done, entity.todo, |
188 widget = ProgressBarWidget(entity.done, entity.todo, |