7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
1 |
# Copyright 2010 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
"""Display `TranslationTemplateBuild`s."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
__all__ = [ |
|
8 |
'TranslationTemplatesBuildNavigation', |
|
9 |
'TranslationTemplatesBuildUrl', |
|
10 |
'TranslationTemplatesBuildView', |
|
11 |
]
|
|
12 |
||
13 |
from zope.component import getUtility |
|
14 |
||
7675.395.139
by Stuart Bishop
Fix import |
15 |
from lp.app.browser.tales import DateTimeFormatterAPI |
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
16 |
from lp.registry.interfaces.productseries import IProductSeriesSet |
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
17 |
from lp.services.webapp.publisher import LaunchpadView |
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
18 |
from lp.translations.model.translationtemplatesbuildjob import ( |
19 |
HARDCODED_TRANSLATIONTEMPLATESBUILD_SCORE, |
|
20 |
)
|
|
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
21 |
|
22 |
||
23 |
class TranslationTemplatesBuildView(LaunchpadView): |
|
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
24 |
"""View for `TranslationTemplatesBuild`."""
|
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
25 |
|
26 |
def getTargets(self): |
|
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
27 |
"""`ProducSeries` that will consume the generated templates."""
|
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
28 |
utility = getUtility(IProductSeriesSet) |
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
29 |
return list( |
30 |
utility.findByTranslationsImportBranch(self.context.branch)) |
|
31 |
||
32 |
def _renderTime(self, time): |
|
33 |
"""Represent `time` as HTML."""
|
|
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
34 |
formatter = DateTimeFormatterAPI(time) |
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
35 |
return """<span title="%s">%s</span>""" % ( |
36 |
formatter.datetime(), formatter.approximatedate()) |
|
37 |
||
38 |
def initalize(self): |
|
39 |
"""See `LaunchpadView`."""
|
|
40 |
self.last_score = HARDCODED_TRANSLATIONTEMPLATESBUILD_SCORE |
|
41 |
||
42 |
def renderDispatchTime(self): |
|
43 |
"""Give start-time information for this build, as HTML."""
|
|
44 |
# Once we do away with BuildQueue, and the relevant information
|
|
45 |
# is moved into the new model, we'll be able to give estimated
|
|
46 |
# start times as well.
|
|
7675.822.8
by Jeroen Vermeulen
Forgot to add files. |
47 |
if self.context.date_started is None: |
7675.822.11
by Jeroen Vermeulen
Support UI display of TranslationTemplatesBuild. |
48 |
return "Not started yet." |
49 |
else: |
|
50 |
return "Started " + self._renderTime(self.context.date_started) |
|
51 |
||
52 |
def renderFinishTime(self): |
|
53 |
"""Give completion time information for this build, as HTML."""
|
|
54 |
# Once we do away with BuildQueue, and the relevant information
|
|
55 |
# is moved into the new model, we'll be able to give estimated
|
|
56 |
# completion times as well.
|
|
57 |
if self.context.date_finished is None: |
|
58 |
if self.context.date_started is None: |
|
59 |
return '' |
|
60 |
else: |
|
61 |
return "Not finished yet." |
|
62 |
else: |
|
63 |
return "Finished " + self._renderTime(self.context.date_finished) |