Changeset - d924b931b488
[Not reviewed]
default
0 6 2
marcink - 16 years ago 2010-04-07 16:42:11

Added managment pages.
+ fixed routing bug
done a lot in templates
8 files changed with 178 insertions and 82 deletions:
0 comments (0 inline, 0 general)
pylons_app/config/routing.py
Show inline comments
 
@@ -22,7 +22,8 @@ def make_map(config):
 
    with map.submapper(path_prefix='/_admin', controller='admin') as m:
 
        m.connect('admin_home', '/', action='index')#main page
 
        m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', action='add_repo')
 
        m.connect('admin_manage_users', '/manage_users', action='index')
 
        m.connect('admin_users_manage', '/repos_manage', action='users_manage')
 
        m.connect('admin_repos_manage', '/users_manage', action='repos_manage')
 
        
 
    map.connect('hg', '/{path_info:.*}', controller='hg',
 
                action="view", path_info='/')
pylons_app/controllers/admin.py
Show inline comments
 
@@ -8,6 +8,7 @@ import os
 
from mercurial import ui, hg
 
from mercurial.error import RepoError
 
from ConfigParser import ConfigParser
 
from pylons_app.lib import auth
 
log = logging.getLogger(__name__)
 

	
 
class AdminController(BaseController):
 
@@ -15,12 +16,21 @@ class AdminController(BaseController):
 

	
 
    def __before__(self):
 
        c.staticurl = g.statics
 
        c.admin_user = True
 
        
 
    def index(self):
 
        # Return a rendered template
 
        return render('/admin.html')
 

	
 

	
 
    def repos_manage(self):
 
        return render('/repos_manage.html')
 
    
 
    def users_manage(self):
 
        conn, cur = auth.get_sqlite_conn_cur()
 
        cur.execute('SELECT * FROM users')
 
        c.users_list = cur.fetchall()        
 
        return render('/users_manage.html')
 
                
 
    def manage_hgrc(self):
 
        pass
 

	
 
@@ -32,8 +42,8 @@ class AdminController(BaseController):
 
        
 

	
 
        #extra check it can be add since it's the command
 
        if new_repo == 'add':
 
            c.msg = 'you basstard ! this repo is a command'
 
        if new_repo == '_admin':
 
            c.msg = 'DENIED'
 
            c.new_repo = ''
 
            return render('add.html')
 

	
pylons_app/lib/auth.py
Show inline comments
 
@@ -8,13 +8,13 @@ import crypt
 
log = logging.getLogger(__name__)
 
ROOT = dn(dn(dn(os.path.realpath(__file__))))
 

	
 
def get_sqlite_cur_conn():
 
def get_sqlite_conn_cur():
 
    conn = sqlite3.connect(os.path.join(ROOT, 'auth.sqlite'))
 
    cur = conn.cursor()
 
    return conn, cur
 

	
 
def authfunc(environ, username, password):
 
    conn, cur = get_sqlite_cur_conn()
 
    conn, cur = get_sqlite_conn_cur()
 
    password_crypt = crypt.crypt(password, '6a')
 

	
 
    try:
 
@@ -59,7 +59,7 @@ def create_user_table():
 
    '''
 
    Create a auth database
 
    '''
 
    conn, cur = get_sqlite_cur_conn()
 
    conn, cur = get_sqlite_conn_cur()
 
    try:
 
        log.info('creating table %s', 'users')
 
        cur.execute('''DROP TABLE IF EXISTS users ''')
 
@@ -83,7 +83,7 @@ def create_user_table():
 
    cur.close()
 
    
 
def create_user(username, password):
 
    conn, cur = get_sqlite_cur_conn()    
 
    conn, cur = get_sqlite_conn_cur()    
 
    password_crypt = crypt.crypt(password, '6a')
 
    cur_date = datetime.now()
 
    log.info('creating user %s', username)
 
@@ -105,5 +105,6 @@ if __name__ == "__main__":
 
    create_user('bart', 'qweqwe')
 
    create_user('maho', 'qweqwe')
 
    create_user('michalg', 'qweqwe')
 
    create_user('admin', 'qwe123qwe')
 
    
 
    #authfunc('', 'marcink', 'qweqwe')
pylons_app/templates/admin.html
Show inline comments
 
## -*- coding: utf-8 -*-
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
    <link rel="icon" href="${c.staticurl}hgicon.png" type="image/png" />
 
    <meta name="robots" content="index, nofollow"/>
 
    <link rel="stylesheet" href="${c.staticurl}style-monoblue.css" type="text/css" />
 
       <title>Mercurial repositories Admin</title>
 
</head>
 

	
 
<body>
 
<div id="container">
 
    <div class="page-header">
 
        <h1><a href="/">Home</a> / Admin</h1>
 
        <ul class="page-nav">
 
        </ul>
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
	${h.link_to(u'Home',h.url('/'))}
 
	 / 
 
	${h.link_to(u'Admin',h.url('admin_home'))}
 
</%def>
 
<%def name="page_nav()">
 
<li>${h.link_to(u'Home',h.url('/'))}</li>
 
<li class="current">${_('Admin')}</li>
 
</%def>
 
<%def name="main()">
 
    %if c.admin_user:
 
    <ul class="submenu">
 
        <li>
 
            ${h.link_to(u'Repos managment',h.url('admin_repos_manage'))}
 
        </li>
 
        <li>
 
            ${h.link_to(u'Users managment',h.url('admin_users_manage'))}
 
        </li>
 
    </ul>
 
    <br/>
 
    <div>
 
    
 
        <h2>Hi !</h2>
 
    </div>
 
    <table cellspacing="0">
 
        <tr>
 
            <td>${h.link_to(u'Create "ccc" repository',h.url('admin_add_repo',new_repo='ccc'))}</td>
 
        </tr>
 
        <tr>
 
            <td>${h.link_to(u'Create "ccc" repository',h.url('admin_add_repo',new_repo='ccc'))}</td>
 
        </tr>
 
        <tr>
 
            <td>${h.link_to(u'Create "ccc" repository',h.url('admin_add_repo',new_repo='ccc'))}</td>
 
        </tr>
 
        <tr>
 
            <td><h2>${c.new_repo}</h2></td>
 
        </tr>
 
    </table>    
 
    <div class="page-footer">
 
        Mercurial Repository: admin
 
    </div>
 

	
 
    <div id="powered-by">
 
        <p>
 
        <a href="http://mercurial.selenic.com/" title="Mercurial">
 
            <img src="${c.staticurl}hglogo.png" width="75" height="90" alt="mercurial"></a>
 
        </p>
 
    </div>
 

	
 
    <div id="corner-top-left"></div>
 
    <div id="corner-top-right"></div>
 
    <div id="corner-bottom-left"></div>
 
    <div id="corner-bottom-right"></div>
 

	
 
</div>
 
</body>
 
</html>
 
        
 
\ No newline at end of file
 
    %else:
 
        <div>
 
        <br />
 
        <h2>${_('Login')}</h2>
 
        ${h.form(h.url.current())}
 
        <table>
 
            <tr>
 
                <td>${_('Username')}</td>
 
                <td>${h.text('username')}</td>
 
            </tr>
 
            <tr>
 
                <td>${_('Password')}</td>
 
                <td>${h.text('password')}</td>
 
            </tr>
 
            <tr>
 
                <td></td>
 
                <td>${h.submit('login','login')}</td>
 
            </tr>            
 
        </table>
 
        ${h.end_form()}
 
        </div>
 
    %endif
 
    
 
</%def>
 
\ No newline at end of file
pylons_app/templates/base/base.html
Show inline comments
 
@@ -2,33 +2,39 @@
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
  <style type="text/css">
 
  </style>
 
  <title>${next.page_title()}</title>
 
  <meta name="author" content=""/>
 
  <meta name="keywords" content=""/>
 
  <meta name="description" content=""/>
 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 
  <link rel="shortcut icon" type="image/x-icon" href="/images/sample.ico"/>
 
  <script src="/css_browser_selector.js" type="text/javascript"></script>
 
  <script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
 
  <link rel="stylesheet" type="text/css" href="/css/style.css"/>     
 

	
 
    <link rel="icon" href="${c.staticurl}hgicon.png" type="image/png" />
 
    <meta name="robots" content="index, nofollow"/>
 
    <link rel="stylesheet" href="${c.staticurl}style-monoblue.css" type="text/css" />
 
       <title>${next.title()}</title>
 
</head>
 
<body>
 

	
 
  <div id="top-glow"></div>
 

	
 
  <div id="container">
 
    ${next.body()}
 
<body>
 
<div id="container">
 
    <div class="page-header">
 
        <h1>
 
            ${next.breadcrumbs()}
 
        </h1>
 
        <ul class="page-nav">
 
            ${next.page_nav()}
 
        </ul>
 
    </div>
 
    ${next.main()}
 
    <div class="page-footer">
 
        Mercurial Repository: ${c.repo_name}
 
    </div>   
 

	
 
  <div id="footer" class="clearfix">
 
    ${next.footer()}
 
  </div><!-- /footer -->
 
    <div id="powered-by">
 
        <p>
 
        <a href="http://mercurial.selenic.com/" title="Mercurial">
 
            <img src="${c.staticurl}hglogo.png" width="75" height="90" alt="mercurial"></a>
 
        </p>
 
    </div>
 

	
 
  </div><!-- /container -->
 
    <div id="corner-top-left"></div>
 
    <div id="corner-top-right"></div>
 
    <div id="corner-bottom-left"></div>
 
    <div id="corner-bottom-right"></div>
 

	
 
  <div id="bottom-glow"></div>
 

	
 
 </body>
 
 </html>
 
\ No newline at end of file
 
</div>
 
</body>
 
</html>
 
\ No newline at end of file
pylons_app/templates/monoblue_custom/index.tmpl
Show inline comments
 
@@ -8,6 +8,8 @@
 
    <div class="page-header">
 
        <h1>${c.repos_prefix} Mercurial Repositories</h1>
 
        <ul class="page-nav">
 
            <li class="current">Home</li>
 
            <li>${h.link_to(u'Admin',h.url('admin_home'))}</li>
 
        </ul>
 
    </div>
 
    
pylons_app/templates/repos_manage.html
Show inline comments
 
new file 100644
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    / 
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Repos managment',h.url('admin_repos_manage'))}
 
</%def>
 
<%def name="page_nav()">
 
	<li>${h.link_to(u'Home',h.url('/'))}</li>
 
	<li class="current">${_('Admin')}</li>
 
</%def>
 
<%def name="main()">
 

	
 

	
 
<div class="twocol-form">
 
        <h2>Create new repository</h2>
 
        <form method="post" action="/repo/create/">
 
            <table>
 
                <tbody><tr><th><label for="id_name">Name:</label></th><td><input type="text" maxlength="255" name="name" id="id_name"></td></tr>
 
<tr><th><label for="id_description">Description:</label></th><td><textarea name="description" cols="40" rows="10" id="id_description"></textarea></td></tr>
 
<tr><th><label for="id_website">Website:</label></th><td><input type="text" maxlength="128" name="website" id="id_website"></td></tr>
 
<tr><th><label for="id_is_private">Private:</label></th><td><input type="checkbox" id="id_is_private" name="is_private"></td></tr>
 
<tr><th><label for="id_has_issues">Issue tracking:</label></th><td><input type="checkbox" id="id_has_issues" name="has_issues" checked="checked"></td></tr>
 
<tr><th><label for="id_has_wiki">Wiki:</label></th><td><input type="checkbox" id="id_has_wiki" name="has_wiki" checked="checked"></td></tr>
 
                
 
                
 
                <tr><td colspan="2">&nbsp;</td></tr>
 
                <tr>
 
                    <td colspan="2">
 
                        <input type="submit" class="primary-button" value="Create repository"> <input type="reset" onclick="document.location='http://bitbucket.org/';" class="secondary-button secondary-button-darkbg" value="Cancel">
 
                    </td>
 
                </tr>
 
            </tbody></table>
 
        </form>
 
    </div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/users_manage.html
Show inline comments
 
new file 100644
 
<%inherit file="base/base.html"/>
 
<%def name="title()">
 
    ${_('Repository managment')}
 
</%def>
 
<%def name="breadcrumbs()">
 
    ${h.link_to(u'Home',h.url('/'))}
 
    / 
 
    ${h.link_to(u'Admin',h.url('admin_home'))}
 
    /
 
    ${h.link_to(u'Users managment',h.url('admin_users_manage'))}
 
</%def>
 
<%def name="page_nav()">
 
    <li>${h.link_to(u'Home',h.url('/'))}</li>
 
    <li class="current">${_('Admin')}</li>
 
</%def>
 
<%def name="main()">
 

	
 
        <table cellspacing="0">
 
         <tr>
 
            <th>Id</th>
 
            <th>Username</th>
 
            <th>Password</th>
 
            <th>Active</th>
 
         </tr>    
 
            %for i in c.users_list:
 
                <tr>
 
                    <td>${i[0]}</td>
 
                    <td>${i[1]}</td>
 
                    <td>${i[2]}</td>
 
                    <td>${i[3]}</td>
 
                </tr>
 
            %endfor
 
        </table>
 
</%def>    
 
\ No newline at end of file
0 comments (0 inline, 0 general)