Changeset 475

Show
Ignore:
Timestamp:
03/10/06 18:33:58 (1 year ago)
Author:
coderanger
Message:

HackInstallPlugin:

Basic interface stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hackinstallplugin/0.9/hackinstall/templates/hackinstall_admin_plugin.cs

    r474 r475  
    11<h3>Plugins</h3> 
    22 
     3<?cs if:hackinstall.message ?> 
     4<div style="background-color: red"><?cs var:hackinstall.message ?></div> 
     5<?cs /if ?> 
     6 
     7<form method="post"> 
    38<table> 
    49<tr><td>Name</td><td>Current</td></tr> 
    510<?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> 
    716<?cs /each ?> 
    817</table> 
     18</form> 
  • hackinstallplugin/0.9/hackinstall/web_ui.py

    r474 r475  
    3030            else: 
    3131                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 
    3247  
    3348    # IAdminPageProvider methods 
    3449    def get_admin_pages(self, req): 
    35         if req.perm.has_permission('TRAC_ADMIN')
     50        if req.perm.has_permission('TRAC_ADMIN') or True
    3651            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') 
    3954             
    4055    def process_admin_request(self, req, cat, page, path_info): 
     
    4257        cursor = db.cursor() 
    4358         
    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 
    4663         
    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) 
    5373         
    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] 
    5975        return template, None 
    6076