# HG changeset patch # User marcink # Date 1270651331 -7200 # Node ID d924b931b4887efbba5a3ced63e4be8fada8ba9c # Parent 2e1247e62c5bd4872df614b7519b6762ff181de8 Added managment pages. + fixed routing bug done a lot in templates diff -r 2e1247e62c5b -r d924b931b488 pylons_app/config/routing.py --- a/pylons_app/config/routing.py Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/config/routing.py Wed Apr 07 16:42:11 2010 +0200 @@ -22,7 +22,8 @@ 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='/') diff -r 2e1247e62c5b -r d924b931b488 pylons_app/controllers/admin.py --- a/pylons_app/controllers/admin.py Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/controllers/admin.py Wed Apr 07 16:42:11 2010 +0200 @@ -8,6 +8,7 @@ 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 @@ 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 @@ #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') diff -r 2e1247e62c5b -r d924b931b488 pylons_app/lib/auth.py --- a/pylons_app/lib/auth.py Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/lib/auth.py Wed Apr 07 16:42:11 2010 +0200 @@ -8,13 +8,13 @@ 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 @@ ''' 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 @@ 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 @@ create_user('bart', 'qweqwe') create_user('maho', 'qweqwe') create_user('michalg', 'qweqwe') + create_user('admin', 'qwe123qwe') #authfunc('', 'marcink', 'qweqwe') diff -r 2e1247e62c5b -r d924b931b488 pylons_app/templates/admin.html --- a/pylons_app/templates/admin.html Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/templates/admin.html Wed Apr 07 16:42:11 2010 +0200 @@ -1,51 +1,53 @@ ## -*- coding: utf-8 -*- - - - - - - - Mercurial repositories Admin - - - -
- - - - \ No newline at end of file + %else: +
+
+

${_('Login')}

+ ${h.form(h.url.current())} + + + + + + + + + + + + + +
${_('Username')}${h.text('username')}
${_('Password')}${h.text('password')}
${h.submit('login','login')}
+ ${h.end_form()} +
+ %endif + + \ No newline at end of file diff -r 2e1247e62c5b -r d924b931b488 pylons_app/templates/base/base.html --- a/pylons_app/templates/base/base.html Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/templates/base/base.html Wed Apr 07 16:42:11 2010 +0200 @@ -2,33 +2,39 @@ - - ${next.page_title()} - - - - - - - - - + + + + ${next.title()} - -
- -
- ${next.body()} + +
+ + ${next.main()} + - +
+

+ + mercurial +

+
-
+
+
+
+
-
- - - \ No newline at end of file +
+ + \ No newline at end of file diff -r 2e1247e62c5b -r d924b931b488 pylons_app/templates/monoblue_custom/index.tmpl --- a/pylons_app/templates/monoblue_custom/index.tmpl Wed Apr 07 15:28:50 2010 +0200 +++ b/pylons_app/templates/monoblue_custom/index.tmpl Wed Apr 07 16:42:11 2010 +0200 @@ -8,6 +8,8 @@ diff -r 2e1247e62c5b -r d924b931b488 pylons_app/templates/repos_manage.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/templates/repos_manage.html Wed Apr 07 16:42:11 2010 +0200 @@ -0,0 +1,40 @@ +<%inherit file="base/base.html"/> +<%def name="title()"> + ${_('Repository managment')} + +<%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 name="page_nav()"> +
  • ${h.link_to(u'Home',h.url('/'))}
  • +
  • ${_('Admin')}
  • + +<%def name="main()"> + + +
    +

    Create new repository

    +
    + + + + + + + + + + + + + +
     
    + +
    +
    +
    + \ No newline at end of file diff -r 2e1247e62c5b -r d924b931b488 pylons_app/templates/users_manage.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylons_app/templates/users_manage.html Wed Apr 07 16:42:11 2010 +0200 @@ -0,0 +1,34 @@ +<%inherit file="base/base.html"/> +<%def name="title()"> + ${_('Repository managment')} + +<%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 name="page_nav()"> +
  • ${h.link_to(u'Home',h.url('/'))}
  • +
  • ${_('Admin')}
  • + +<%def name="main()"> + + + + + + + + + %for i in c.users_list: + + + + + + + %endfor +
    IdUsernamePasswordActive
    ${i[0]}${i[1]}${i[2]}${i[3]}
    + \ No newline at end of file