equal
deleted
inserted
replaced
13 import random |
13 import random |
14 |
14 |
15 from logilab.mtconverter import xml_escape |
15 from logilab.mtconverter import xml_escape |
16 |
16 |
17 from cubicweb.utils import UStringIO |
17 from cubicweb.utils import UStringIO |
18 from cubicweb.uilib import toggle_action, limitsize, htmlescape |
18 from cubicweb.uilib import toggle_action, htmlescape |
19 from cubicweb.web import jsonize |
19 from cubicweb.web import jsonize |
20 |
20 |
21 # XXX HTMLWidgets should have access to req (for datadir / static urls, |
21 # XXX HTMLWidgets should have access to req (for datadir / static urls, |
22 # i18n strings, etc.) |
22 # i18n strings, etc.) |
23 class HTMLWidget(object): |
23 class HTMLWidget(object): |
314 for column in self.columns: |
314 for column in self.columns: |
315 attrs = ('%s="%s"' % (name, value) for name, value in column.cell_attrs.iteritems()) |
315 attrs = ('%s="%s"' % (name, value) for name, value in column.cell_attrs.iteritems()) |
316 self.w(u'<th %s>%s</th>' % (' '.join(attrs), column.name)) |
316 self.w(u'<th %s>%s</th>' % (' '.join(attrs), column.name)) |
317 self.w(u'</tr>') |
317 self.w(u'</tr>') |
318 self.w(u'</thead><tbody>') |
318 self.w(u'</thead><tbody>') |
319 for rowindex, row in enumerate(self.model.get_rows()): |
319 for rowindex in xrange(len(self.model.get_rows())): |
320 klass = (rowindex%2==1) and 'odd' or 'even' |
320 klass = (rowindex%2==1) and 'odd' or 'even' |
321 self.w(u'<tr class="%s" %s>' % (klass, self.highlight)) |
321 self.w(u'<tr class="%s" %s>' % (klass, self.highlight)) |
322 for column, sortvalue in self.itercols(rowindex): |
322 for column, sortvalue in self.itercols(rowindex): |
323 attrs = dict(column.cell_attrs) |
323 attrs = dict(column.cell_attrs) |
324 attrs["cubicweb:sortvalue"] = 'json:' + sortvalue |
324 attrs["cubicweb:sortvalue"] = 'json:' + sortvalue |
371 done = self.done |
371 done = self.done |
372 todo = self.todo |
372 todo = self.todo |
373 budget = self.budget |
373 budget = self.budget |
374 if budget == 0: |
374 if budget == 0: |
375 pourcent = 100 |
375 pourcent = 100 |
376 todo_pourcent = 0 |
|
377 else: |
376 else: |
378 pourcent = done*100./budget |
377 pourcent = done*100./budget |
379 todo_pourcent = min(todo*100./budget, 100-pourcent) |
|
380 bar_pourcent = pourcent |
|
381 if pourcent > 100.1: |
378 if pourcent > 100.1: |
382 color = 'red' |
379 color = 'red' |
383 bar_pourcent = 100 |
|
384 elif todo+done > self.red_threshold*budget: |
380 elif todo+done > self.red_threshold*budget: |
385 color = 'red' |
381 color = 'red' |
386 elif todo+done > self.orange_threshold*budget: |
382 elif todo+done > self.orange_threshold*budget: |
387 color = 'orange' |
383 color = 'orange' |
388 elif todo+done > self.yellow_threshold*budget: |
384 elif todo+done > self.yellow_threshold*budget: |