43 _('cost'), _('progress'), _('todo_by')) |
43 _('cost'), _('progress'), _('todo_by')) |
44 |
44 |
45 |
45 |
46 def call(self, columns=None): |
46 def call(self, columns=None): |
47 """displays all versions in a table""" |
47 """displays all versions in a table""" |
48 self.req.add_css('cubicweb.iprogress.css') |
48 self._cw.add_css('cubicweb.iprogress.css') |
49 _ = self.req._ |
49 _ = self._cw._ |
50 self.columns = columns or self.columns |
50 self.columns = columns or self.columns |
51 ecls = self.vreg['etypes'].etype_class(self.rset.description[0][0]) |
51 ecls = self._cw.vreg['etypes'].etype_class(self.cw_rset.description[0][0]) |
52 self.w(u'<table class="progress">') |
52 self.w(u'<table class="progress">') |
53 self.table_header(ecls) |
53 self.table_header(ecls) |
54 self.w(u'<tbody>') |
54 self.w(u'<tbody>') |
55 for row in xrange(self.rset.rowcount): |
55 for row in xrange(self.cw_rset.rowcount): |
56 self.cell_call(row=row, col=0) |
56 self.cell_call(row=row, col=0) |
57 self.w(u'</tbody>') |
57 self.w(u'</tbody>') |
58 self.w(u'</table>') |
58 self.w(u'</table>') |
59 |
59 |
60 def cell_call(self, row, col): |
60 def cell_call(self, row, col): |
61 _ = self.req._ |
61 _ = self._cw._ |
62 entity = self.rset.get_entity(row, col) |
62 entity = self.cw_rset.get_entity(row, col) |
63 infos = {} |
63 infos = {} |
64 for col in self.columns: |
64 for col in self.columns: |
65 meth = getattr(self, 'build_%s_cell' % col, None) |
65 meth = getattr(self, 'build_%s_cell' % col, None) |
66 # find the build method or try to find matching attribute |
66 # find the build method or try to find matching attribute |
67 if meth: |
67 if meth: |
81 |
81 |
82 ## header management ###################################################### |
82 ## header management ###################################################### |
83 |
83 |
84 def header_for_project(self, ecls): |
84 def header_for_project(self, ecls): |
85 """use entity's parent type as label""" |
85 """use entity's parent type as label""" |
86 return display_name(self.req, ecls.parent_type) |
86 return display_name(self._cw, ecls.parent_type) |
87 |
87 |
88 def header_for_milestone(self, ecls): |
88 def header_for_milestone(self, ecls): |
89 """use entity's type as label""" |
89 """use entity's type as label""" |
90 return display_name(self.req, ecls.id) |
90 return display_name(self._cw, ecls.id) |
91 |
91 |
92 def table_header(self, ecls): |
92 def table_header(self, ecls): |
93 """builds the table's header""" |
93 """builds the table's header""" |
94 self.w(u'<thead><tr>') |
94 self.w(u'<thead><tr>') |
95 _ = self.req._ |
95 _ = self._cw._ |
96 for column in self.columns: |
96 for column in self.columns: |
97 meth = getattr(self, 'header_for_%s' % column, None) |
97 meth = getattr(self, 'header_for_%s' % column, None) |
98 if meth: |
98 if meth: |
99 colname = meth(ecls) |
99 colname = meth(ecls) |
100 else: |
100 else: |
107 def build_project_cell(self, entity): |
107 def build_project_cell(self, entity): |
108 """``project`` column cell renderer""" |
108 """``project`` column cell renderer""" |
109 project = entity.get_main_task() |
109 project = entity.get_main_task() |
110 if project: |
110 if project: |
111 return project.view('incontext') |
111 return project.view('incontext') |
112 return self.req._('no related project') |
112 return self._cw._('no related project') |
113 |
113 |
114 def build_milestone_cell(self, entity): |
114 def build_milestone_cell(self, entity): |
115 """``milestone`` column cell renderer""" |
115 """``milestone`` column cell renderer""" |
116 return entity.view('incontext') |
116 return entity.view('incontext') |
117 |
117 |
118 def build_state_cell(self, entity): |
118 def build_state_cell(self, entity): |
119 """``state`` column cell renderer""" |
119 """``state`` column cell renderer""" |
120 return xml_escape(self.req._(entity.state)) |
120 return xml_escape(self._cw._(entity.state)) |
121 |
121 |
122 def build_eta_date_cell(self, entity): |
122 def build_eta_date_cell(self, entity): |
123 """``eta_date`` column cell renderer""" |
123 """``eta_date`` column cell renderer""" |
124 if entity.finished(): |
124 if entity.finished(): |
125 return self.format_date(entity.completion_date()) |
125 return self.format_date(entity.completion_date()) |
126 formated_date = self.format_date(entity.initial_prevision_date()) |
126 formated_date = self.format_date(entity.initial_prevision_date()) |
127 if entity.in_progress(): |
127 if entity.in_progress(): |
128 eta_date = self.format_date(entity.eta_date()) |
128 eta_date = self.format_date(entity.eta_date()) |
129 _ = self.req._ |
129 _ = self._cw._ |
130 if formated_date: |
130 if formated_date: |
131 formated_date += u' (%s %s)' % (_('expected:'), eta_date) |
131 formated_date += u' (%s %s)' % (_('expected:'), eta_date) |
132 else: |
132 else: |
133 formated_date = u'%s %s' % (_('expected:'), eta_date) |
133 formated_date = u'%s %s' % (_('expected:'), eta_date) |
134 return formated_date |
134 return formated_date |
137 """``todo_by`` column cell renderer""" |
137 """``todo_by`` column cell renderer""" |
138 return u', '.join(p.view('outofcontext') for p in entity.contractors()) |
138 return u', '.join(p.view('outofcontext') for p in entity.contractors()) |
139 |
139 |
140 def build_cost_cell(self, entity): |
140 def build_cost_cell(self, entity): |
141 """``cost`` column cell renderer""" |
141 """``cost`` column cell renderer""" |
142 _ = self.req._ |
142 _ = self._cw._ |
143 pinfo = entity.progress_info() |
143 pinfo = entity.progress_info() |
144 totalcost = pinfo.get('estimatedcorrected', pinfo['estimated']) |
144 totalcost = pinfo.get('estimatedcorrected', pinfo['estimated']) |
145 missing = pinfo.get('notestimatedcorrected', pinfo.get('notestimated', 0)) |
145 missing = pinfo.get('notestimatedcorrected', pinfo.get('notestimated', 0)) |
146 costdescr = [] |
146 costdescr = [] |
147 if missing: |
147 if missing: |
166 the ``project`` column |
166 the ``project`` column |
167 """ |
167 """ |
168 __regid__ = 'ic_progress_table_view' |
168 __regid__ = 'ic_progress_table_view' |
169 |
169 |
170 def call(self, columns=None): |
170 def call(self, columns=None): |
171 view = self.vreg['views'].select('progress_table_view', self.req, |
171 view = self._cw.vreg['views'].select('progress_table_view', self._cw, |
172 rset=self.rset) |
172 rset=self.cw_rset) |
173 columns = list(columns or view.columns) |
173 columns = list(columns or view.columns) |
174 try: |
174 try: |
175 columns.remove('project') |
175 columns.remove('project') |
176 except ValueError: |
176 except ValueError: |
177 self.info('[ic_progress_table_view] could not remove project from columns') |
177 self.info('[ic_progress_table_view] could not remove project from columns') |
183 __regid__ = 'progressbar' |
183 __regid__ = 'progressbar' |
184 title = _('progress bar') |
184 title = _('progress bar') |
185 __select__ = implements(IProgress) |
185 __select__ = implements(IProgress) |
186 |
186 |
187 def cell_call(self, row, col): |
187 def cell_call(self, row, col): |
188 self.req.add_css('cubicweb.iprogress.css') |
188 self._cw.add_css('cubicweb.iprogress.css') |
189 entity = self.rset.get_entity(row, col) |
189 entity = self.cw_rset.get_entity(row, col) |
190 widget = ProgressBarWidget(entity.done, entity.todo, |
190 widget = ProgressBarWidget(entity.done, entity.todo, |
191 entity.revised_cost) |
191 entity.revised_cost) |
192 self.w(widget.render()) |
192 self.w(widget.render()) |
193 |
193 |