annotate bitten/trac_ext/web_ui.py @ 64:de1a7499f4d6

Basic timeline provider for builds.
author cmlenz
date Tue, 28 Jun 2005 16:17:25 +0000
parents 055a6c666fa8
children 5f9bcb4966b7
rev   line source
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
1 # -*- coding: iso8859-1 -*-
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
2 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
3 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
4 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
5 # Bitten is free software; you can redistribute it and/or
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
6 # modify it under the terms of the GNU General Public License as
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
7 # published by the Free Software Foundation; either version 2 of the
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
8 # License, or (at your option) any later version.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
9 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
10 # Trac is distributed in the hope that it will be useful,
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
13 # General Public License for more details.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
14 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
18 #
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
19 # Author: Christopher Lenz <cmlenz@gmx.de>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
20
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
21 import re
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
22 from time import localtime, strftime
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
23
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
24 from trac.core import *
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
25 from trac.Timeline import ITimelineEventProvider
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
26 from trac.util import escape, pretty_timedelta
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
27 from trac.web.chrome import INavigationContributor
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
28 from trac.web.main import IRequestHandler
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
29 from trac.wiki import wiki_to_html
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
30 from bitten.model import Build, BuildConfig
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
31
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
32
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
33 class BuildModule(Component):
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
34
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
35 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
36
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
37 build_cs = """
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
38 <?cs include:"header.cs" ?>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
39 <div id="ctxtnav" class="nav"></div>
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
40 <div id="content" class="build">
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
41 <h1><?cs var:title ?></h1><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
42
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
43 if:build.mode == 'overview' ?><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
44 each:config = build.configs ?>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
45 <h2><a href="<?cs var:config.href ?>"><?cs var:config.label ?></a></h2><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
46 if:config.description ?><div class="description"><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
47 var:config.description ?></div><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
48 /if ?><?cs
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
49 /each ?><?cs
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
50 if:build.can_create ?><div class="buttons">
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
51 <form method="get" action=""><div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
52 <input type="hidden" name="action" value="new" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
53 <input type="submit" value="Add new configuration" />
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
54 </div></form><?cs
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
55 /if ?></div><?cs
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
56
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
57 elif:build.mode == 'edit_config' ?>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
58 <form method="post" action="">
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
59 <div class="field"><label>Name:<br />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
60 <input type="text" name="name" value="<?cs var:build.config.name ?>" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
61 </label></div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
62 <div class="field"><label>Label (for display):<br />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
63 <input type="text" name="label" size="32" value="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
64 var:build.config.label ?>" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
65 </label></div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
66 <div class="field"><label><input type="checkbox" name="active"<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
67 if:build.config.active ?> checked="checked" <?cs /if ?>/> Active
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
68 </label></div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
69 <div class="field"><label>Repository path:<br />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
70 <input type="text" name="path" size="48" value="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
71 var:build.config.path ?>" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
72 </label></div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
73 <div class="field"><fieldset class="iefix">
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
74 <label for="description">Description (you may use <a tabindex="42" href="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
75 var:trac.href.wiki ?>/WikiFormatting">WikiFormatting</a> here):</label>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
76 <p><textarea id="description" name="description" class="wikitext" rows="10" cols="78"><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
77 var:build.config.description ?></textarea></p>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
78 <script type="text/javascript" src="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
79 var:htdocs_location ?>js/wikitoolbar.js"></script>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
80 </fieldset></div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
81 <div class="buttons">
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
82 <input type="hidden" name="action" value="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
83 if:build.config.exists ?>edit<?cs else ?>new<?cs /if ?>" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
84 <input type="submit" name="cancel" value="Cancel" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
85 <input type="submit" value="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
86 if:build.config.exists ?>Save changes<?cs else ?>Create<?cs /if ?>" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
87 </div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
88 </form><?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
89
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
90 elif:build.mode == 'view_config' ?><ul>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
91 <li>Active: <?cs if:build.config.active ?>yes<?cs else ?>no<?cs /if ?></li>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
92 <li>Path: <?cs if:build.config.path ?><a href="<?cs
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
93 var:build.config.browser_href ?>"><?cs
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
94 var:build.config.path ?></a></li><?cs /if ?></ul><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
95 if:build.config.description ?><div class="description"><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
96 var:build.config.description ?></div><?cs /if ?>
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
97 <div id="builds"><h3>Builds</h3><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
98 if:len(build.config.builds) ?><ul><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
99 each:b = build.config.builds ?><li><a href="<?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
100 var:b.href ?>">[<?cs var:b.rev ?>]</a> built by <?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
101 var:len(b.slaves) ?> slave(s)<?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
102 if:len(b.slaves) ?>:<ul><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
103 each:slave = b.slaves ?><li><strong><?cs var:slave.name ?></strong>: <?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
104 var:slave.status ?> (started <?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
105 var:slave.started_delta ?> ago<?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
106 if:slave.stopped ?>, stopped <?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
107 var:slave.stopped_delta ?> ago, took <?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
108 var:slave.duration ?><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
109 /if ?>)</li><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
110 /each ?>
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
111 </ul><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
112 /if ?>
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
113 </li><?cs
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
114 /each ?>
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
115 </ul><?cs
56
033366d81def Build slave now executes the build. Closes #10.
cmlenz
parents: 50
diff changeset
116 else ?><p>(None)</p><?cs
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
117 /if ?></div><?cs
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
118 if:build.can_modify ?><div class="buttons">
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
119 <form method="get" action=""><div>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
120 <input type="hidden" name="action" value="edit" />
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
121 <input type="submit" value="Edit configuration" />
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
122 </div></form><?cs
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
123 /if ?></div><?cs
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
124 /if ?>
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
125
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
126 </div>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
127 <?cs include:"footer.cs" ?>
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
128 """
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
129
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
130 _status_label = {Build.IN_PROGRESS: 'in progress',
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
131 Build.SUCCESS: 'success',
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
132 Build.FAILURE: 'failed'}
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
133
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
134 # INavigationContributor methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
135
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
136 def get_active_navigation_item(self, req):
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
137 return 'build'
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
138
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
139 def get_navigation_items(self, req):
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
140 if not req.perm.has_permission('BUILD_VIEW'):
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
141 return
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
142 yield 'mainnav', 'build', \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
143 '<a href="%s" accesskey="5">Build Status</a>' \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
144 % self.env.href.build()
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
145
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
146 # IRequestHandler methods
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
147
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
148 def match_request(self, req):
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
149 match = re.match(r'/build(?:/([\w.-]+))?(?:/([\w+.-]))?', req.path_info)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
150 if match:
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
151 if match.group(1):
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
152 req.args['config'] = match.group(1)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
153 if match.group(2):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
154 req.args['id'] = match.group(2)
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
155 return True
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
156
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
157 def process_request(self, req):
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
158 req.perm.assert_permission('BUILD_VIEW')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
159
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
160 action = req.args.get('action')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
161 config = req.args.get('config')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
162 id = req.args.get('id')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
163
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
164 if req.method == 'POST':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
165 if not config and action == 'new':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
166 self._do_create(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
167 elif config and action == 'edit':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
168 self._do_save(req, config)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
169 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
170 if not config:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
171 if action == 'new':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
172 self._render_config_form(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
173 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
174 self._render_overview(req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
175 elif not id:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
176 if action == 'edit':
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
177 self._render_config_form(req, config)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
178 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
179 self._render_config(req, config)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
180 else:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
181 self._render_build(req, config, id)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
182
35
67631e1d4d45 Some stubbed out code for the Bitten/Trac-integration. This creates a {{{bitten_build}}} table on database upgrade after the plugin is enabled.
cmlenz
parents:
diff changeset
183 return req.hdf.parse(self.build_cs), None
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
184
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
185 # ITimelineEventProvider methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
186
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
187 def get_timeline_filters(self, req):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
188 if req.perm.has_permission('BUILD_VIEW'):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
189 yield ('build', 'Builds')
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
190
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
191 def get_timeline_events(self, req, start, stop, filters):
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
192 if 'build' in filters:
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
193 db = self.env.get_db_cnx()
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
194 cursor = db.cursor()
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
195 cursor.execute("SELECT name,label,rev,slave,time,status "
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
196 "FROM bitten_build "
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
197 " INNER JOIN bitten_config ON (name=config) "
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
198 "WHERE time>=%s AND time<=%s ORDER BY time",
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
199 (start, stop))
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
200 for name, label, rev, slave, time, status in cursor:
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
201 title = '<em>%s</em> [%s] built by %s' \
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
202 % (escape(label), escape(rev), escape(slave))
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
203 href = self.env.href.build(name)
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
204 message = self._status_label[status]
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
205 yield 'build', href, title, time, None, message
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
206
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
207 # Internal methods
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
208
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
209 def _do_create(self, req):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
210 """Create a new build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
211 req.perm.assert_permission('BUILD_CREATE')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
212
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
213 if 'cancel' in req.args.keys():
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
214 req.redirect(self.env.href.build())
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
215
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
216 config = BuildConfig(self.env)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
217 config.name = req.args.get('name')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
218 config.active = req.args.has_key('active')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
219 config.label = req.args.get('label', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
220 config.path = req.args.get('path', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
221 config.description = req.args.get('description', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
222 config.insert()
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
223
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
224 req.redirect(self.env.href.build(config.name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
225
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
226 def _do_save(self, req, config_name):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
227 """Save changes to a build configuration."""
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
228 req.perm.assert_permission('BUILD_MODIFY')
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
229
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
230 if 'cancel' in req.args.keys():
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
231 req.redirect(self.env.href.build(config_name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
232
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
233 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
234 config.name = req.args.get('name')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
235 config.active = req.args.has_key('active')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
236 config.label = req.args.get('label', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
237 config.path = req.args.get('path', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
238 config.description = req.args.get('description', '')
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
239 config.update()
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
240
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
241 req.redirect(self.env.href.build(config.name))
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
242
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
243 def _render_overview(self, req):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
244 req.hdf['title'] = 'Build Status'
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
245 configurations = BuildConfig.select(self.env, include_inactive=True)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
246 for idx, config in enumerate(configurations):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
247 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
248 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
249 description = wiki_to_html(description, self.env, req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
250 req.hdf['build.configs.%d' % idx] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
251 'name': config.name, 'label': config.label or config.name,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
252 'path': config.path, 'description': description,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
253 'href': self.env.href.build(config.name)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
254 }
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
255 req.hdf['build.mode'] = 'overview'
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
256 req.hdf['build.can_create'] = req.perm.has_permission('BUILD_CREATE')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
257
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
258 def _render_config(self, req, config_name):
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
259 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
260 req.hdf['title'] = 'Build Configuration "%s"' \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
261 % escape(config.label or config.name)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
262 description = config.description
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
263 if description:
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
264 description = wiki_to_html(description, self.env, req)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
265 req.hdf['build.config'] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
266 'name': config.name, 'label': config.label, 'path': config.path,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
267 'active': config.active, 'description': description,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
268 'browser_href': self.env.href.browser(config.path)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
269 }
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
270
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
271 builds = Build.select(self.env, config=config.name)
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
272 curr_rev = None
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
273 slave_idx = 0
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
274 for idx, build in enumerate(builds):
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
275 if build.rev != curr_rev:
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
276 slave_idx = 0
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
277 curr_rev = build.rev
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
278 req.hdf['build.config.builds.%d' % idx] = {
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
279 'rev': build.rev,
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
280 'href': self.env.href.changeset(build.rev)
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
281 }
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
282 if not build.slave:
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
283 continue
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
284 prefix = 'build.config.builds.%d.slaves.%d' % (idx, slave_idx)
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
285 req.hdf[prefix] = {'name': build.slave,
64
de1a7499f4d6 Basic timeline provider for builds.
cmlenz
parents: 60
diff changeset
286 'status': self._status_label[build.status]}
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
287 if build.time:
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
288 started = build.time
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
289 req.hdf[prefix + '.started'] = strftime('%x %X',
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
290 localtime(started))
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
291 req.hdf[prefix + '.started_delta'] = pretty_timedelta(started)
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
292 if build.duration:
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
293 stopped = build.time + build.duration
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
294 req.hdf[prefix + '.duration'] = pretty_timedelta(stopped,
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
295 build.time)
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
296 req.hdf[prefix + '.stopped'] = strftime('%x %X',
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
297 localtime(stopped))
47
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
298 req.hdf[prefix + '.stopped_delta'] = pretty_timedelta(stopped)
083e848088ee * Improvements to the model classes, and a couple of unit tests.
cmlenz
parents: 45
diff changeset
299
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
300 req.hdf['build.mode'] = 'view_config'
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
301 req.hdf['build.can_modify'] = req.perm.has_permission('BUILD_MODIFY')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
302
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
303 def _render_config_form(self, req, config_name=None):
45
80bc0fae3ed1 Renamed {{{Configuration}}} to {{{BuildConfig}}}.
cmlenz
parents: 41
diff changeset
304 config = BuildConfig(self.env, config_name)
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
305 if config.exists:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
306 req.perm.assert_permission('BUILD_MODIFY')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
307 req.hdf['title'] = 'Edit Build Configuration "%s"' \
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
308 % escape(config.label or config.name)
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
309 req.hdf['build.config'] = {
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
310 'name': config.name, 'label': config.label, 'path': config.path,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
311 'active': config.active, 'description': config.description,
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
312 'exists': config.exists
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
313 }
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
314 else:
50
0d5ad32948b7 Restrict access to web interface with custom permission actions.
cmlenz
parents: 47
diff changeset
315 req.perm.assert_permission('BUILD_CREATE')
41
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
316 req.hdf['title'] = 'Create Build Configuration'
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
317 req.hdf['build.mode'] = 'edit_config'
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
318
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
319 def _render_build(self, req, config_name, build_id):
16b30ffc5fb9 Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents: 35
diff changeset
320 raise NotImplementedError, 'Not implemented yet'
Copyright (C) 2012-2017 Edgewall Software