Mercurial > bitten > bitten-test
annotate bitten/admin.py @ 895:7d93d6358fe0
Use our own HTTPBasicAuthHandler under Python 2.6 to avoid issue http://bugs.python.org/issue8797. Fixes #658.
author | hodgestar |
---|---|
date | Wed, 09 Mar 2011 14:48:35 +0000 |
parents | 7c80375d4817 |
children |
rev | line source |
---|---|
429 | 1 # -*- coding: utf-8 -*- |
2 # | |
832 | 3 # Copyright (C) 2007-2010 Edgewall Software |
429 | 4 # All rights reserved. |
5 # | |
6 # This software is licensed as described in the file COPYING, which | |
7 # you should have received as part of this distribution. The terms | |
8 # are also available at http://bitten.edgewall.org/wiki/License. | |
9 | |
10 """Implementation of the web administration interface.""" | |
11 | |
432 | 12 from pkg_resources import require, DistributionNotFound |
429 | 13 import re |
14 | |
15 from trac.core import * | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
16 from trac.admin import IAdminPanelProvider |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
17 from trac.web.chrome import add_stylesheet, add_script, add_warning, add_notice |
429 | 18 |
19 from bitten.model import BuildConfig, TargetPlatform | |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
20 from bitten.recipe import Recipe, InvalidRecipeError |
429 | 21 from bitten.util import xmlio |
22 | |
23 | |
24 class BuildMasterAdminPageProvider(Component): | |
25 """Web administration panel for configuring the build master.""" | |
26 | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
27 implements(IAdminPanelProvider) |
429 | 28 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
29 # IAdminPanelProvider methods |
429 | 30 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
31 def get_admin_panels(self, req): |
429 | 32 if req.perm.has_permission('BUILD_ADMIN'): |
432 | 33 yield ('bitten', 'Builds', 'master', 'Master Settings') |
429 | 34 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
35 def render_admin_panel(self, req, cat, page, path_info): |
429 | 36 from bitten.master import BuildMaster |
37 master = BuildMaster(self.env) | |
38 | |
39 if req.method == 'POST': | |
433 | 40 self._save_config_changes(req, master) |
41 req.redirect(req.abs_href.admin(cat, page)) | |
429 | 42 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
43 data = {'master': master} |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
44 add_stylesheet(req, 'bitten/admin.css') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
45 return 'bitten_admin_master.html', data |
429 | 46 |
433 | 47 # Internal methods |
48 | |
49 def _save_config_changes(self, req, master): | |
50 changed = False | |
51 | |
52 build_all = 'build_all' in req.args | |
53 if build_all != master.build_all: | |
54 self.config['bitten'].set('build_all', | |
55 build_all and 'yes' or 'no') | |
56 changed = True | |
57 | |
58 adjust_timestamps = 'adjust_timestamps' in req.args | |
59 if adjust_timestamps != master.adjust_timestamps: | |
60 self.config['bitten'].set('adjust_timestamps', | |
61 adjust_timestamps and 'yes' or 'no') | |
62 changed = True | |
63 | |
468
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
64 stabilize_wait = int(req.args.get('stabilize_wait', 0)) |
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
65 if stabilize_wait != master.stabilize_wait: |
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
66 self.config['bitten'].set('stabilize_wait', str(stabilize_wait)) |
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
67 changed = True |
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
68 |
433 | 69 slave_timeout = int(req.args.get('slave_timeout', 0)) |
70 if slave_timeout != master.slave_timeout: | |
71 self.config['bitten'].set('slave_timeout', str(slave_timeout)) | |
72 changed = True | |
73 | |
557
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
74 quick_status = 'quick_status' in req.args |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
75 if quick_status != master.quick_status: |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
76 self.config['bitten'].set('quick_status', |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
77 quick_status and 'yes' or 'no') |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
78 changed = True |
b4d3d9cbf200
Alter the appearance of the ''Build Status'' button, to show the current build status [eblot] - fixes #373
dfraser
parents:
516
diff
changeset
|
79 |
516
2f3b7c17d3c3
Switch to storing log messages in files rather than in database rows:
dfraser
parents:
503
diff
changeset
|
80 logs_dir = req.args.get('logs_dir', None) |
2f3b7c17d3c3
Switch to storing log messages in files rather than in database rows:
dfraser
parents:
503
diff
changeset
|
81 if logs_dir != master.logs_dir: |
2f3b7c17d3c3
Switch to storing log messages in files rather than in database rows:
dfraser
parents:
503
diff
changeset
|
82 self.config['bitten'].set('logs_dir', str(logs_dir)) |
2f3b7c17d3c3
Switch to storing log messages in files rather than in database rows:
dfraser
parents:
503
diff
changeset
|
83 changed = True |
2f3b7c17d3c3
Switch to storing log messages in files rather than in database rows:
dfraser
parents:
503
diff
changeset
|
84 |
433 | 85 if changed: |
86 self.config.save() | |
87 | |
88 return master | |
89 | |
429 | 90 |
91 class BuildConfigurationsAdminPageProvider(Component): | |
92 """Web administration panel for configuring the build master.""" | |
93 | |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
94 implements(IAdminPanelProvider) |
429 | 95 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
96 # IAdminPanelProvider methods |
429 | 97 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
98 def get_admin_panels(self, req): |
429 | 99 if req.perm.has_permission('BUILD_MODIFY'): |
432 | 100 yield ('bitten', 'Builds', 'configs', 'Configurations') |
429 | 101 |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
102 def render_admin_panel(self, req, cat, page, path_info): |
429 | 103 data = {} |
104 | |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
105 # Analyze url |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
106 try: |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
107 config_name, platform_id = path_info.split('/', 1) |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
108 except: |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
109 config_name = path_info |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
110 platform_id = None |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
111 |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
112 if config_name: # Existing build config |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
113 warnings = [] |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
114 if platform_id or ( |
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
115 # Editing or creating one of the config's target platforms |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
116 req.method == 'POST' and 'new' in req.args): |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
117 |
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
118 if platform_id: # Editing target platform |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
119 platform_id = int(platform_id) |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
120 platform = TargetPlatform.fetch(self.env, platform_id) |
429 | 121 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
122 if req.method == 'POST': |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
123 if 'cancel' in req.args or \ |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
124 self._update_platform(req, platform): |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
125 req.redirect(req.abs_href.admin(cat, page, |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
126 config_name)) |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
127 else: # creating target platform |
607
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
128 platform = self._create_platform(req, config_name) |
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
129 req.redirect(req.abs_href.admin(cat, page, |
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
130 config_name, platform.id)) |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
131 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
132 # Set up template variables |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
133 data['platform'] = { |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
134 'id': platform.id, 'name': platform.name, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
135 'exists': platform.exists, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
136 'rules': [ |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
137 {'property': propname, 'pattern': pattern} |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
138 for propname, pattern in platform.rules |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
139 ] or [('', '')] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
140 } |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
141 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
142 else: # Editing existing build config itself |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
143 config = BuildConfig.fetch(self.env, config_name) |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
144 platforms = list(TargetPlatform.select(self.env, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
145 config=config.name)) |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
146 |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
147 if req.method == 'POST': |
607
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
148 if 'remove' in req.args: # Remove selected platforms |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
149 self._remove_platforms(req) |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
150 add_notice(req, "Target Platform(s) Removed.") |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
151 req.redirect(req.abs_href.admin(cat, page, config.name)) |
468
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
152 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
153 elif 'save' in req.args: # Save this build config |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
154 warnings = self._update_config(req, config) |
468
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
155 |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
156 if not warnings: |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
157 add_notice(req, "Configuration Saved.") |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
158 req.redirect(req.abs_href.admin(cat, page, config.name)) |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
159 |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
160 for warning in warnings: |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
161 add_warning(req, warning) |
468
44c2b4ac6157
Add stabilization time parameter to build master. Closes #189. Many thanks to Allen Bierbaum for the patch.
cmlenz
parents:
467
diff
changeset
|
162 |
683
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
163 # FIXME: Deprecation notice for old namespace. |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
164 # Remove notice code when migration to new namespace is complete |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
165 if 'http://bitten.cmlenz.net/tools/' in config.recipe: |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
166 add_notice(req, "Recipe uses a deprecated namespace. " |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
167 "Replace 'http://bitten.cmlenz.net/tools/' with " |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
168 "'http://bitten.edgewall.org/tools/'.") |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
169 |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
170 # Add a notice if configuration is not active |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
171 if not warnings and not config.active and config.recipe: |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
172 add_notice(req, "Configuration is not active. Activate " |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
173 "from main 'Configurations' listing to enable it.") |
0c4fec90c8e2
0.6dev: Update all tools and docs to use the new `http://bitten.edgewall.org/tools/` namespace as default. Old namespace will still work, but a notice appears when editing config if deprecated namespace is in use. Both will work for now, though.
osimons
parents:
631
diff
changeset
|
174 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
175 # Prepare template variables |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
176 data['config'] = { |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
177 'name': config.name, 'label': config.label or config.name, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
178 'active': config.active, 'path': config.path, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
179 'min_rev': config.min_rev, 'max_rev': config.max_rev, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
180 'description': config.description, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
181 'recipe': config.recipe, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
182 'platforms': [{ |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
183 'name': platform.name, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
184 'id': platform.id, |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
185 'href': req.href.admin('bitten', 'configs', config.name, |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
186 platform.id), |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
187 'rules': [{'property': propname, 'pattern': pattern} |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
188 for propname, pattern in platform.rules] |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
189 } for platform in platforms] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
190 } |
429 | 191 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
192 else: # At the top level build config list |
429 | 193 if req.method == 'POST': |
433 | 194 if 'add' in req.args: # Add build config |
195 config = self._create_config(req) | |
196 req.redirect(req.abs_href.admin(cat, page, config.name)) | |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
197 |
433 | 198 elif 'remove' in req.args: # Remove selected build configs |
199 self._remove_configs(req) | |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
200 |
433 | 201 elif 'apply' in req.args: # Update active state of configs |
202 self._activate_configs(req) | |
203 req.redirect(req.abs_href.admin(cat, page)) | |
429 | 204 |
467
5c9f34b18236
Apply patch that clarifies some code in the admin module. Closes #196. Thanks to David Abrahams.
cmlenz
parents:
455
diff
changeset
|
205 # Prepare template variables |
429 | 206 configs = [] |
207 for config in BuildConfig.select(self.env, include_inactive=True): | |
208 configs.append({ | |
209 'name': config.name, 'label': config.label or config.name, | |
210 'active': config.active, 'path': config.path, | |
211 'min_rev': config.min_rev, 'max_rev': config.max_rev, | |
212 'href': req.href.admin('bitten', 'configs', config.name), | |
572
1caaefd76375
0.6dev: Don't provide option to enable a build configuration without a recipe. Closes #168.
osimons
parents:
563
diff
changeset
|
213 'recipe': config.recipe and True or False |
429 | 214 }) |
743
5e274fc552c3
Sort the list of configurations by name in the administration panel.
wbell
parents:
683
diff
changeset
|
215 data['configs'] = sorted(configs, key=lambda x:x['label'].lower()) |
429 | 216 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
217 add_stylesheet(req, 'bitten/admin.css') |
563
a5a7e19399b5
Autocomplete path names in configuration using trac's autocompletion code (supports trac 0.11 and 0.12) (Emannuel Blot) - fixes #363
dfraser
parents:
557
diff
changeset
|
218 add_script(req, 'common/js/suggest.js') |
503
a7c795920c4a
Merging trac-0.11 branch to trunk. This revision is equivalent to [571].
wbell
parents:
468
diff
changeset
|
219 return 'bitten_admin_configs.html', data |
433 | 220 |
221 # Internal methods | |
222 | |
223 def _activate_configs(self, req): | |
434 | 224 req.perm.assert_permission('BUILD_MODIFY') |
225 | |
455
dc2c565600a9
Fix for deactivating all configurations on admin page. Closes #175.
cmlenz
parents:
436
diff
changeset
|
226 active = req.args.get('active') or [] |
dc2c565600a9
Fix for deactivating all configurations on admin page. Closes #175.
cmlenz
parents:
436
diff
changeset
|
227 active = isinstance(active, list) and active or [active] |
434 | 228 |
433 | 229 db = self.env.get_db_cnx() |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
230 for config in list(BuildConfig.select(self.env, db=db, |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
231 include_inactive=True)): |
433 | 232 config.active = config.name in active |
233 config.update(db=db) | |
234 db.commit() | |
235 | |
236 def _create_config(self, req): | |
237 req.perm.assert_permission('BUILD_CREATE') | |
434 | 238 |
433 | 239 config = BuildConfig(self.env) |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
240 warnings = self._update_config(req, config) |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
241 if warnings: |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
242 if len(warnings) == 1: |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
243 raise TracError(warnings[0], 'Add Configuration') |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
244 else: |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
245 raise TracError('Errors: %s' % ' '.join(warnings), |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
246 'Add Configuration') |
433 | 247 return config |
248 | |
249 def _remove_configs(self, req): | |
250 req.perm.assert_permission('BUILD_DELETE') | |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
251 |
433 | 252 sel = req.args.get('sel') |
253 if not sel: | |
254 raise TracError('No configuration selected') | |
255 sel = isinstance(sel, list) and sel or [sel] | |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
256 |
433 | 257 db = self.env.get_db_cnx() |
258 for name in sel: | |
259 config = BuildConfig.fetch(self.env, name, db=db) | |
260 if not config: | |
261 raise TracError('Configuration %r not found' % name) | |
262 config.delete(db=db) | |
263 db.commit() | |
264 | |
265 def _update_config(self, req, config): | |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
266 warnings = [] |
434 | 267 req.perm.assert_permission('BUILD_MODIFY') |
268 | |
433 | 269 name = req.args.get('name') |
270 if not name: | |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
271 warnings.append('Missing required field "name".') |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
272 if name and not re.match(r'^[\w.-]+$', name): |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
273 warnings.append('The field "name" may only contain letters, ' |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
274 'digits, periods, or dashes.') |
433 | 275 |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
276 repos = self.env.get_repository(authname=req.authname) |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
277 if not repos: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
278 warnings.append('No "(default)" Repository: Add a repository or ' |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
279 'alias named "(default)" to Trac.') |
433 | 280 path = req.args.get('path', '') |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
281 min_rev = req.args.get('min_rev') or None |
433 | 282 max_rev = req.args.get('max_rev') or None |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
283 |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
284 if repos: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
285 path = repos.normalize_path(path) |
433 | 286 try: |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
287 node = repos.get_node(path, max_rev) |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
288 assert node.isdir, '%s is not a directory' % node.path |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
289 except (AssertionError, TracError), e: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
290 warnings.append('Invalid Repository Path: "%s" does not exist ' |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
291 'within the "(default)" repository.' % path) |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
292 if min_rev: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
293 try: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
294 repos.get_node(path, min_rev) |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
295 except TracError, e: |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
296 warnings.append('Invalid Oldest Revision: %s.' % unicode(e)) |
433 | 297 |
298 recipe_xml = req.args.get('recipe', '') | |
299 if recipe_xml: | |
300 try: | |
301 Recipe(xmlio.parse(recipe_xml)).validate() | |
302 except xmlio.ParseError, e: | |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
303 warnings.append('Failure parsing recipe: %s.' % unicode(e)) |
433 | 304 except InvalidRecipeError, e: |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
305 warnings.append('Invalid Recipe: %s.' % unicode(e)) |
433 | 306 |
307 config.name = name | |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
308 config.path = path |
433 | 309 config.recipe = recipe_xml |
804
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
310 config.min_rev = min_rev |
4c73a3cea9f5
Basic Trac 0.12 support, supporting just a `(default)` repository - essentially Trac 0.11 behaviour. Thanks to those that have contributed to #480 to get this working and tested.
osimons
parents:
743
diff
changeset
|
311 config.max_rev = max_rev |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
312 config.label = req.args.get('label', config.name) |
433 | 313 config.description = req.args.get('description', '') |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
314 |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
315 if warnings: # abort |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
316 return warnings |
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
317 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
318 if config.exists: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
319 config.update() |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
320 else: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
321 config.insert() |
631
0c11c58d1985
0.6dev: Switch to use warnings in admin instead of raising error pages. Also adds some notices on successful actions. Closes #413.
osimons
parents:
609
diff
changeset
|
322 return [] |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
323 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
324 def _create_platform(self, req, config_name): |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
325 req.perm.assert_permission('BUILD_MODIFY') |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
326 |
607
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
327 name = req.args.get('platform_name') |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
328 if not name: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
329 raise TracError('Missing required field "name"', 'Missing field') |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
330 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
331 platform = TargetPlatform(self.env, config=config_name, name=name) |
607
5d396356bf7a
0.6dev: Reworked UI for adding Target Platform. Like elsewhere in Trac web admin, 'New Target Platform' is now a fieldset to the right of the listing. This fixes the issue discussed on #333.
osimons
parents:
572
diff
changeset
|
332 platform.insert() |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
333 return platform |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
334 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
335 def _remove_platforms(self, req): |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
336 req.perm.assert_permission('BUILD_MODIFY') |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
337 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
338 sel = req.args.get('sel') |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
339 if not sel: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
340 raise TracError('No platform selected') |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
341 sel = isinstance(sel, list) and sel or [sel] |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
342 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
343 db = self.env.get_db_cnx() |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
344 for platform_id in sel: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
345 platform = TargetPlatform.fetch(self.env, platform_id, db=db) |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
346 if not platform: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
347 raise TracError('Target platform %r not found' % platform_id) |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
348 platform.delete(db=db) |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
349 db.commit() |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
350 |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
351 def _update_platform(self, req, platform): |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
352 platform.name = req.args.get('name') |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
353 |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
354 properties = [int(key[9:]) for key in req.args.keys() |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
355 if key.startswith('property_')] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
356 properties.sort() |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
357 patterns = [int(key[8:]) for key in req.args.keys() |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
358 if key.startswith('pattern_')] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
359 patterns.sort() |
609
022bcceb90b7
0.6dev: Removing whitespace from target platform rules admin. Fixes #336.
osimons
parents:
607
diff
changeset
|
360 platform.rules = [(req.args.get('property_%d' % property).strip(), |
022bcceb90b7
0.6dev: Removing whitespace from target platform rules admin. Fixes #336.
osimons
parents:
607
diff
changeset
|
361 req.args.get('pattern_%d' % pattern).strip()) |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
362 for property, pattern in zip(properties, patterns) |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
363 if req.args.get('property_%d' % property)] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
364 |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
365 if platform.exists: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
366 platform.update() |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
367 else: |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
368 platform.insert() |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
369 |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
370 add_rules = [int(key[9:]) for key in req.args.keys() |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
371 if key.startswith('add_rule_')] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
372 if add_rules: |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
373 platform.rules.insert(add_rules[0] + 1, ('', '')) |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
374 return False |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
375 rm_rules = [int(key[8:]) for key in req.args.keys() |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
376 if key.startswith('rm_rule_')] |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
377 if rm_rules: |
436
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
378 if rm_rules[0] < len(platform.rules): |
cfbc9ee622d5
Finish the move of build configuration management into the admin interface.
cmlenz
parents:
435
diff
changeset
|
379 del platform.rules[rm_rules[0]] |
435
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
380 return False |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
381 |
8424a8afd1a1
Started implementing platform editing via admin interface.
cmlenz
parents:
434
diff
changeset
|
382 return True |