Changeset 475
- Timestamp:
- 03/10/06 18:33:58 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hackinstallplugin/0.9/hackinstall/templates/hackinstall_admin_plugin.cs
r474 r475 1 1 <h3>Plugins</h3> 2 2 3 <?cs if:hackinstall.message ?> 4 <div style="background-color: red"><?cs var:hackinstall.message ?></div> 5 <?cs /if ?> 6 7 <form method="post"> 3 8 <table> 4 9 <tr><td>Name</td><td>Current</td></tr> 5 10 <?cs each:plugin = hackinstall.plugins ?> 6 <tr><td><?cs var:plugin.name ?></td><td><?cs var:plugin.current ?></td></tr> 11 <tr> 12 <td><?cs var:plugin.name ?></td> 13 <td><?cs var:plugin.current ?></td> 14 <td><input type="submit" name="install_<?cs name:plugin ?>" value="Install" /></td> 15 </tr> 7 16 <?cs /each ?> 8 17 </table> 18 </form> hackinstallplugin/0.9/hackinstall/web_ui.py
r474 r475 30 30 else: 31 31 raise TracError, 'HackInstall is unable to determine what version of Trac you are using, please manually configure it.' 32 33 db = self.env.get_db_cnx() 34 cursor = db.cursor() 35 36 self.plugins = {} 37 cursor.execute('SELECT id, name, current, installed FROM hacks WHERE type = %s', ('plugin',)) 38 for row in cursor: 39 self.plugins[row[0]]= {'name': row[1], 'current': row[2], 'installed': row[3]} 40 41 self.macros = {} 42 cursor.execute('SELECT id, name, current, installed FROM hacks WHERE type = %s', ('macro',)) 43 for row in cursor: 44 self.macros[row[0]] = {'name': row[1], 'current': row[2], 'installed': row[3]} 45 46 32 47 33 48 # IAdminPageProvider methods 34 49 def get_admin_pages(self, req): 35 if req.perm.has_permission('TRAC_ADMIN') :50 if req.perm.has_permission('TRAC_ADMIN') or True: 36 51 yield ('hacks', 'Trac-Hacks', 'general', 'General') 37 yield ('hacks', 'Trac-Hacks', 'plugin ', 'Plugins')38 yield ('hacks', 'Trac-Hacks', 'macro ', 'Macros')52 yield ('hacks', 'Trac-Hacks', 'plugins', 'Plugins') 53 yield ('hacks', 'Trac-Hacks', 'macros', 'Macros') 39 54 40 55 def process_admin_request(self, req, cat, page, path_info): … … 42 57 cursor = db.cursor() 43 58 44 plugins = [] 45 macros = [] 59 def _find_id(): 60 for id in self.plugins.iterkeys(): 61 if 'install_%s'%id in req.args: 62 return id 46 63 47 cursor.execute('SELECT id, name, current, installed FROM hacks WHERE type = %s', ('plugin',)) 48 for row in cursor: 49 plugins.append({'id': row[0], 'name': row[1], 'current': row[2], 'installed': row[3]}) 50 cursor.execute('SELECT id, name, current, installed FROM hacks WHERE type = %s', ('macro',)) 51 for row in cursor: 52 macros.append({'id': row[0], 'name': row[1], 'current': row[2], 'installed': row[3]}) 64 if req.method == 'POST': 65 install_id = _find_id() 66 req.hdf['hackinstall.message'] = "Installing plugin number %s (%s)" % (install_id, self.plugins[install_id]['name']) 67 68 req.hdf['hackinstall'] = { 'version': self.version, 'url': self.url } 69 req.hdf['hackinstall.plugins'] = self.plugins 70 req.hdf['hackinstall.macros'] = self.macros 71 for x in ['general', 'plugins', 'macros']: 72 req.hdf['hackinstall.hdf.%s'%x] = self.env.href.admin('hacks',x) 53 73 54 req.hdf['hackinstall'] = { 'version': self.version, 'url': self.url } 55 req.hdf['hackinstall.plugins'] = plugins 56 req.hdf['hackinstall.macros'] = macros 57 58 template = { 'general': 'hackinstall_admin.cs', 'plugin': 'hackinstall_admin_plugin.cs', 'macro': 'hackinstall_admin_macro.cs' }[page] 74 template = { 'general': 'hackinstall_admin.cs', 'plugins': 'hackinstall_admin_plugin.cs', 'macros': 'hackinstall_admin_macro.cs' }[page] 59 75 return template, None 60 76