Mercurial > bitten > bitten-test
annotate bitten/trac_ext/web_ui.py @ 74:1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
author | cmlenz |
---|---|
date | Tue, 05 Jul 2005 11:12:17 +0000 |
parents | 6d7753ea1798 |
children | ffa1ffd8c7db |
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 | 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 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
27 from trac.web.chrome import INavigationContributor, ITemplateProvider, \ |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
28 add_link, add_stylesheet |
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
|
29 from trac.web.main import IRequestHandler |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
30 from trac.wiki import wiki_to_html |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
31 from bitten.model import Build, BuildConfig, TargetPlatform |
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
|
32 |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
33 |
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
|
34 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
|
35 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
36 implements(INavigationContributor, IRequestHandler, ITimelineEventProvider, |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
37 ITemplateProvider) |
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
|
38 |
64 | 39 _status_label = {Build.IN_PROGRESS: 'in progress', |
69 | 40 Build.SUCCESS: 'completed', |
64 | 41 Build.FAILURE: 'failed'} |
42 | |
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
|
43 # 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
|
44 |
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
|
45 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
|
46 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
|
47 |
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
|
48 def get_navigation_items(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
49 if not req.perm.has_permission('BUILD_VIEW'): |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
50 return |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
51 yield 'mainnav', 'build', \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
52 '<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
|
53 % 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
|
54 |
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
|
55 # 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
|
56 |
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
|
57 def match_request(self, req): |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
58 match = re.match(r'/build(?:/([\w.-]+))?(?:/([\d]+))?', 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
|
59 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
|
60 if match.group(1): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
61 req.args['config'] = match.group(1) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
62 if match.group(2): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
63 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
|
64 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
|
65 |
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
|
66 def process_request(self, req): |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
67 req.perm.assert_permission('BUILD_VIEW') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
68 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
69 action = req.args.get('action') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
70 config = req.args.get('config') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
71 id = req.args.get('id') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
72 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
73 if req.method == 'POST': |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
74 if config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
75 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
76 self._do_create_platform(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
77 else: |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
78 self.log.debug('Request args: %s', req.args.keys()) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
79 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
80 if platform_id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
81 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
82 self._do_save_platform(req, config, platform_id) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
83 elif 'delete' in req.args.keys(): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
84 self._do_delete_platforms(req) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
85 self._render_config_form(req, config) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
86 elif 'new' in req.args.keys(): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
87 platform = TargetPlatform(self.env) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
88 platform.config = config |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
89 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
90 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
91 self._do_save_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
92 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
93 if action == 'new': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
94 self._do_create_config(req) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
95 else: |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
96 if id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
97 self._render_build(req, id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
98 elif config: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
99 if action == 'edit': |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
100 platform_id = req.args.get('platform') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
101 if platform_id: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
102 platform = TargetPlatform(self.env, int(platform_id)) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
103 self._render_platform_form(req, platform) |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
104 elif 'new' in req.args.keys(): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
105 platform = TargetPlatform(self.env) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
106 self._render_platform_form(req, platform) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
107 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
108 self._render_config_form(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
109 else: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
110 self._render_config(req, config) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
111 else: |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
112 if action == 'new': |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
113 self._render_config_form(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
114 else: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
115 self._render_overview(req) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
116 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
117 add_stylesheet(req, 'build.css') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
118 return 'build.cs', None |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
119 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
120 # ITemplatesProvider methods |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
121 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
122 def get_htdocs_dir(self): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
123 return self.config.get('bitten', 'htdocs_dir') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
124 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
125 def get_templates_dir(self): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
126 return self.config.get('bitten', 'templates_dir') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
127 |
64 | 128 # ITimelineEventProvider methods |
129 | |
130 def get_timeline_filters(self, req): | |
131 if req.perm.has_permission('BUILD_VIEW'): | |
132 yield ('build', 'Builds') | |
133 | |
134 def get_timeline_events(self, req, start, stop, filters): | |
135 if 'build' in filters: | |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
136 add_stylesheet(req, 'build.css') |
64 | 137 db = self.env.get_db_cnx() |
138 cursor = db.cursor() | |
69 | 139 cursor.execute("SELECT id,config,label,rev,slave,stopped,status " |
64 | 140 "FROM bitten_build " |
141 " INNER JOIN bitten_config ON (name=config) " | |
69 | 142 "WHERE stopped>=%s AND stopped<=%s " |
143 "AND status IN (%s, %s) ORDER BY stopped", | |
67 | 144 (start, stop, Build.SUCCESS, Build.FAILURE)) |
65
5f9bcb4966b7
Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents:
64
diff
changeset
|
145 event_kinds = {Build.SUCCESS: 'successbuild', |
5f9bcb4966b7
Produce different kinds of events in the {{{ITimelineEventProvider}}} implementation, depending on whether the build failed or succeeded; for future use when Bitten provides its own CSS style sheet and images.
cmlenz
parents:
64
diff
changeset
|
146 Build.FAILURE: 'failedbuild'} |
69 | 147 for id, config, label, rev, slave, stopped, status in cursor: |
148 title = 'Build <em title="[%s] of %s">%s</em> by %s %s' \ | |
149 % (escape(rev), escape(label), escape(id), | |
150 escape(slave), self._status_label[status]) | |
151 href = self.env.href.build(config, id) | |
152 yield event_kinds[status], href, title, stopped, None, '' | |
64 | 153 |
154 # Internal methods | |
155 | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
156 def _do_create_config(self, req): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
157 """Create a new build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
158 req.perm.assert_permission('BUILD_CREATE') |
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 if 'cancel' in req.args.keys(): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
161 req.redirect(self.env.href.build()) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
162 |
45 | 163 config = BuildConfig(self.env) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
164 config.name = req.args.get('name') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
165 config.active = req.args.has_key('active') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
166 config.label = req.args.get('label', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
167 config.path = req.args.get('path', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
168 config.description = req.args.get('description', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
169 config.insert() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
170 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
171 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
|
172 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
173 def _do_save_config(self, req, config_name): |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
174 """Save changes to a build configuration.""" |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
175 req.perm.assert_permission('BUILD_MODIFY') |
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
176 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
177 if 'cancel' in req.args.keys(): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
178 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
|
179 |
45 | 180 config = BuildConfig(self.env, config_name) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
181 config.name = req.args.get('name') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
182 config.active = req.args.has_key('active') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
183 config.label = req.args.get('label', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
184 config.path = req.args.get('path', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
185 config.description = req.args.get('description', '') |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
186 config.update() |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
187 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
188 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
|
189 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
190 def _do_create_platform(self, req, config_name): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
191 """Create a new target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
192 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
193 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
194 if 'cancel' in req.args.keys(): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
195 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
196 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
197 platform = TargetPlatform(self.env) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
198 platform.config = config_name |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
199 platform.name = req.args.get('name') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
200 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
201 properties = [int(key[9:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
202 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
203 properties.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
204 patterns = [int(key[8:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
205 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
206 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
207 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
208 req.args.get('pattern_%d' % pattern)) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
209 for property, pattern in zip(properties, patterns)] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
210 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
211 add_rules = [int(key[9:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
212 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
213 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
214 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
215 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
216 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
217 rm_rules = [int(key[8:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
218 if key.startswith('rm_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
219 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
220 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
221 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
222 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
223 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
224 platform.insert() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
225 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
226 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
227 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
228 def _do_delete_platforms(self, req): |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
229 """Delete selected target platforms.""" |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
230 req.perm.assert_permission('BUILD_MODIFY') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
231 self.log.debug('_do_delete_platforms') |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
232 |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
233 db = self.env.get_db_cnx() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
234 for platform_id in [int(id) for id in req.args.get('delete_platform')]: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
235 platform = TargetPlatform(self.env, platform_id, db=db) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
236 self.log.info('Deleting target platform %s of configuration %s', |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
237 platform.name, platform.config) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
238 platform.delete(db=db) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
239 db.commit() |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
240 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
241 def _do_save_platform(self, req, config_name, platform_id): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
242 """Save changes to a target platform.""" |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
243 req.perm.assert_permission('BUILD_MODIFY') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
244 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
245 if 'cancel' in req.args.keys(): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
246 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
247 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
248 platform = TargetPlatform(self.env, platform_id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
249 platform.name = req.args.get('name') |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
250 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
251 properties = [int(key[9:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
252 if key.startswith('property_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
253 properties.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
254 patterns = [int(key[8:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
255 if key.startswith('pattern_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
256 patterns.sort() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
257 platform.rules = [(req.args.get('property_%d' % property), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
258 req.args.get('pattern_%d' % pattern)) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
259 for property, pattern in zip(properties, patterns)] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
260 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
261 add_rules = [int(key[9:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
262 if key.startswith('add_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
263 if add_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
264 platform.rules.insert(add_rules[0] + 1, ('', '')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
265 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
266 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
267 rm_rules = [int(key[8:]) for key in req.args.keys() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
268 if key.startswith('rm_rule_')] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
269 if rm_rules: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
270 del platform.rules[rm_rules[0]] |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
271 self._render_platform_form(req, platform) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
272 return |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
273 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
274 platform.update() |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
275 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
276 req.redirect(self.env.href.build(config_name, action='edit')) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
277 |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
278 def _render_overview(self, req): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
279 req.hdf['title'] = 'Build Status' |
45 | 280 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
|
281 for idx, config in enumerate(configurations): |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
282 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
283 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
284 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
|
285 req.hdf['build.configs.%d' % idx] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
286 '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
|
287 'path': config.path, 'description': description, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
288 'href': self.env.href.build(config.name) |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
289 } |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
290 req.hdf['build.mode'] = 'overview' |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
291 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
|
292 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
293 def _render_config(self, req, config_name): |
45 | 294 config = BuildConfig(self.env, config_name) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
295 req.hdf['title'] = 'Build Configuration "%s"' \ |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
296 % escape(config.label or config.name) |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
297 add_link(req, 'up', self.env.href.build(), 'Build Status') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
298 description = config.description |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
299 if description: |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
300 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
|
301 req.hdf['build.config'] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
302 '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
|
303 'active': config.active, 'description': description, |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
304 'browser_href': self.env.href.browser(config.path), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
305 '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
|
306 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
307 req.hdf['build.mode'] = 'view_config' |
47
083e848088ee
* Improvements to the model classes, and a couple of unit tests.
cmlenz
parents:
45
diff
changeset
|
308 |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
309 platforms = TargetPlatform.select(self.env, config=config_name) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
310 req.hdf['build.platforms'] = [platform.name for platform in platforms] |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
311 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
312 repos = self.env.get_repository(req.authname) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
313 root = repos.get_node(config.path) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
314 num = 0 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
315 for idx, (path, rev, chg) in enumerate(root.get_history()): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
316 prefix = 'build.config.builds.%d' % rev |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
317 for build in Build.select(self.env, config=config.name, rev=rev): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
318 req.hdf[prefix + '.' + build.slave] = self._build_to_hdf(build) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
319 if idx > 5: |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
320 break |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
321 |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
322 def _render_config_form(self, req, config_name=None): |
45 | 323 config = BuildConfig(self.env, config_name) |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
324 if config.exists: |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
325 req.perm.assert_permission('BUILD_MODIFY') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
326 req.hdf['build.config'] = { |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
327 '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
|
328 'active': config.active, 'description': config.description, |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
329 'exists': config.exists |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
330 } |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
331 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
332 req.hdf['title'] = 'Edit Build Configuration "%s"' \ |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
333 % escape(config.label or config.name) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
334 for idx, platform in enumerate(TargetPlatform.select(self.env, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
335 config_name)): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
336 req.hdf['build.platforms.%d' % idx] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
337 'id': platform.id, 'name': platform.name, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
338 'href': self.env.href.build(config_name, action='edit', |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
339 platform=platform.id) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
340 } |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
341 else: |
50
0d5ad32948b7
Restrict access to web interface with custom permission actions.
cmlenz
parents:
47
diff
changeset
|
342 req.perm.assert_permission('BUILD_CREATE') |
41
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
343 req.hdf['title'] = 'Create Build Configuration' |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
344 req.hdf['build.mode'] = 'edit_config' |
16b30ffc5fb9
Add web interface for viewing and managing build configurations. Closes #9.
cmlenz
parents:
35
diff
changeset
|
345 |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
346 def _render_platform_form(self, req, platform): |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
347 req.perm.assert_permission('BUILD_MODIFY') |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
348 if platform.exists: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
349 req.hdf['title'] = 'Edit Target Platform "%s"' \ |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
350 % escape(platform.name) |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
351 else: |
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
352 req.hdf['title'] = 'Add Target Platform' |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
353 req.hdf['build.platform'] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
354 'name': platform.name, 'id': platform.id, 'exists': platform.exists, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
355 'rules': [{'property': propname, 'pattern': pattern} |
74
1d4fa4c32afa
Add template and static resources, hooked up using the new {{{ITemplateProvider}}} extension point in Trac.
cmlenz
parents:
73
diff
changeset
|
356 for propname, pattern in platform.rules] + [('', '')] |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
357 } |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
358 req.hdf['build.mode'] = 'edit_platform' |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
359 |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
360 def _render_build(self, req, build_id): |
69 | 361 build = Build(self.env, build_id) |
362 assert build.exists | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
363 add_link(req, 'up', self.env.href.build(build.config), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
364 'Build Configuration') |
69 | 365 status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure'} |
366 req.hdf['title'] = 'Build %s - %s' % (build_id, | |
367 status2title[build.status]) | |
368 req.hdf['build'] = self._build_to_hdf(build) | |
369 req.hdf['build.mode'] = 'view_build' | |
370 | |
371 config = BuildConfig(self.env, build.config) | |
372 req.hdf['build.config'] = { | |
373 'name': config.label, | |
374 'href': self.env.href.build(config.name) | |
375 } | |
376 | |
377 def _build_to_hdf(self, build): | |
378 hdf = {'name': build.slave, 'status': self._status_label[build.status], | |
379 'rev': build.rev, | |
380 'chgset_href': self.env.href.changeset(build.rev)} | |
381 if build.started: | |
382 hdf['started'] = strftime('%x %X', localtime(build.started)) | |
383 hdf['started_delta'] = pretty_timedelta(build.started) | |
384 if build.stopped: | |
385 hdf['stopped'] = strftime('%x %X', localtime(build.stopped)) | |
386 hdf['stopped_delta'] = pretty_timedelta(build.stopped) | |
387 hdf['duration'] = pretty_timedelta(build.stopped, build.started) | |
73
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
388 hdf['slave'] = { |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
389 'name': build.slave, |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
390 'ip_address': build.slave_info.get(Build.IP_ADDRESS), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
391 'os': build.slave_info.get(Build.OS_NAME), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
392 'os.family': build.slave_info.get(Build.OS_FAMILY), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
393 'os.version': build.slave_info.get(Build.OS_VERSION), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
394 'machine': build.slave_info.get(Build.MACHINE), |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
395 'processor': build.slave_info.get(Build.PROCESSOR) |
6d7753ea1798
Implemented basic management of target platforms. Closes #14.
cmlenz
parents:
69
diff
changeset
|
396 } |
69 | 397 return hdf |