Changeset 3405
- Timestamp:
- 03/20/08 13:03:33 (9 months ago)
- Files:
-
- tracforgeplugin/0.11/tracforge/admin/__init__.py (modified) (1 diff)
- tracforgeplugin/0.11/tracforge/admin/model.py (modified) (1 diff)
- tracforgeplugin/0.11/tracforge/admin/prototypes_admin.py (modified) (4 diffs)
- tracforgeplugin/0.11/tracforge/templates/admin_tracforge_prototype.html (added)
- tracforgeplugin/0.11/tracforge/templates/admin_tracforge_prototypes.html (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tracforgeplugin/0.11/tracforge/admin/__init__.py
r3394 r3405 5 5 #import perm_admin 6 6 import prototypes 7 #import prototypes_admin7 import prototypes_admin 8 8 #import dispatch tracforgeplugin/0.11/tracforge/admin/model.py
r3394 r3405 303 303 """Return a prototype for the defaults on the new prototype screen.""" 304 304 proto = cls(env, '') 305 proto.append( {'action':'MakeTracEnvironment', 'args':''})305 proto.append(('MakeTracEnvironment', os.path.dirname(env.path))) 306 306 return proto 307 307 default = classmethod(default) tracforgeplugin/0.11/tracforge/admin/prototypes_admin.py
r3401 r3405 1 1 # TracForge prototype admin panel 2 import itertools 3 2 4 from trac.core import * 3 5 from trac.web.chrome import add_stylesheet, add_script … … 17 19 if 'TRACFORGE_ADMIN' in req.perm: 18 20 yield 'tracforge', 'TracForge', 'prototypes', 'Project Prototypes' 21 yield 'tracforge', 'TracForge', 'configset', 'Configset Management' 19 22 20 def process_admin_request(self, req, cat, page, path_info): 21 # Page locations 22 req.hdf['tracforge.href'] = { 23 'prototypes': req.href.admin(cat, page), 24 'configset': req.href.admin(cat, page, 'configset'), 25 'new': req.href.admin(cat, page, 'new'), 26 'htdocs': req.href.chrome('tracforge'), 27 } 23 def render_admin_panel(self, req, cat, page, path_info): 24 data = {} 28 25 29 26 # General stuff 30 27 add_stylesheet(req, 'tracforge/css/admin.css') 31 add_script(req, 'tracforge/js/jquery.js')32 req.cat = cat33 req.page = page34 28 35 29 # Subpage dispatchers 36 30 if path_info: 37 if path_info == 'configset': 38 return self.process_configset_admin_request(req, cat, page, path_info) 39 elif path_info == 'new': 31 if path_info == 'new': 40 32 return self._show_prototype(req, path_info, action='new') 41 33 else: 42 34 return self._show_prototype(req, path_info, action='edit') 43 35 44 45 req.hdf['tracforge.prototypes.tags'] = list(Prototype.select(self.env)) 46 47 return 'admin_tracforge_prototypes.cs', None 36 data['prototypes'] = Prototype.select(self.env) 37 return 'admin_tracforge_prototypes.html', data 48 38 49 39 def process_configset_admin_request(self, req, cat, page, path_info): … … 96 86 def _show_prototype(self, req, path_info, action): 97 87 """Handler for creating a new prototype.""" 98 add_stylesheet(req, 'tracforge/css/prototypes_new.css')99 add_script(req, 'tracforge/js/interface/iutil.js')100 add_script(req, 'tracforge/js/jquery.animatedswap.js')101 req.hdf['tracforge.prototypes.name'] = path_info.strip('/')88 data = { 89 'name': path_info, 90 'action': action, 91 } 102 92 93 proto = None 103 94 if req.method == 'POST': 104 if req.args.get('save'): # Save either a new prototype or a changed existing ones 105 name = req.args.get('name') 106 if action == 'edit': 107 name = path_info.strip('/') 108 if not name: 109 raise TracError('You must specify a name for the prototype') 110 if name in ('new', 'configset'): 111 raise TracError('"new" and "configset" are reserved names') 95 proto = Prototype(self.env, '') 96 for i in itertools.count(): 97 a = req.args.get('step%s'%i) 98 if a is not None: 99 proto.append((a, req.args[a])) 100 else: 101 break 112 102 113 data = req.args.get('data') 114 if not data: 115 raise TracError("Warning: Peguins on fire. You might have JavaScript off, don't do that") 116 data = data[4:] # Strip off the 'data' literal at the start 117 if not data: 118 raise TracError("You must have at least one step in a prototype") 119 120 proto = Prototype(self.env, name) 121 if action == 'new' and proto.exists: 122 raise TracError("Prototype %s already exists"%name) 123 del proto[:] 124 for x in data.split('|'): 125 proto.append(x.split(',',1)) 126 proto.save() 127 elif req.args.get('cancel'): 128 pass # This should just redirect back 129 elif req.args.get('delete') and action == 'edit': # Show the confirmation screen 130 return 'admin_tracforge_prototypes_delete.cs', None 131 elif req.args.get('reallydelete') and action == 'edit': # Actually delete this prototype 132 name = path_info.strip('/') 133 proto = Prototype(self.env, name) 134 if not proto.exists: 135 raise TracError('Prototype %s does not exist'%name) 136 proto.delete() 137 req.redirect(req.href.admin(req.cat, req.page)) 138 103 if 'movedown' in req.args: 104 i = int(req.args['movedown']) 105 x = proto.pop(i) 106 proto.insert(i+1, x) 107 108 139 109 #steps = {} 140 110 #for p in self.setup_participants: … … 144 114 # 'description': p.get_setup_action_description(a), 145 115 # } 146 steps= TracForgeAdminSystem(self.env).get_project_setup_participants()116 data['steps'] = TracForgeAdminSystem(self.env).get_project_setup_participants() 147 117 148 initial_steps = []149 118 if action == 'new': # For a new one, use the specified defaults 150 initial_steps = Prototype.default(self.env) # XXX: This should really read from trac.ini somehow 119 if proto is None: 120 proto = Prototype.default(self.env) # XXX: This should really read from trac.ini somehow 151 121 elif action == 'edit': 152 proto = Prototype(self.env, path_info.strip('/'))153 if not proto.exists:154 raise TracError('Unknown prototype %s'%proto.tag)155 initial_steps = proto122 if proto is None: 123 proto = Prototype(self.env, data['name']) 124 if not proto.exists: 125 raise TracError('Unknown prototype %s'%proto.tag) 156 126 else: 157 127 raise TracError('Invalid action %s'%action) 158 159 req.hdf['tracforge.prototypes.action'] = action 160 req.hdf['tracforge.prototypes.steps'] = steps 161 req.hdf['tracforge.prototypes.initialsteps'] = initial_steps 162 req.hdf['tracforge.prototypes.liststeps'] = [k for k in steps.iterkeys() if k not in initial_steps] 128 data['proto'] = proto 163 129 164 return 'admin_tracforge_prototypes_show.cs', None 130 add_stylesheet(req, 'tracforge/css/prototypes_new.css') 131 #add_script(req, 'tracforge/js/interface/iutil.js') 132 #add_script(req, 'tracforge/js/jquery.animatedswap.js') 133 return 'admin_tracforge_prototype.html', data
