diff --git a/pylons_app/config/routing.py b/pylons_app/config/routing.py --- a/pylons_app/config/routing.py +++ b/pylons_app/config/routing.py @@ -22,8 +22,9 @@ 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_users_manage', '/repos_manage', action='users_manage') - m.connect('admin_repos_manage', '/users_manage', action='repos_manage') + + map.resource('repo', 'repos', path_prefix='/_admin') + map.resource('user', 'users', path_prefix='/_admin') map.connect('hg', '/{path_info:.*}', controller='hg', action="view", path_info='/') diff --git a/pylons_app/controllers/admin.py b/pylons_app/controllers/admin.py --- a/pylons_app/controllers/admin.py +++ b/pylons_app/controllers/admin.py @@ -52,18 +52,6 @@ class AdminController(BaseController): ) 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 - def hgrc(self, dirname): filename = os.path.join(dirname, '.hg', 'hgrc') return filename diff --git a/pylons_app/controllers/repos.py b/pylons_app/controllers/repos.py new file mode 100644 --- /dev/null +++ b/pylons_app/controllers/repos.py @@ -0,0 +1,57 @@ +import logging + +from pylons import request, response, session, tmpl_context as c, url, app_globals as g +from pylons.controllers.util import abort, redirect +from pylons_app.lib import auth +from pylons_app.lib.base import BaseController, render + +log = logging.getLogger(__name__) + +class ReposController(BaseController): + """REST Controller styled on the Atom Publishing Protocol""" + # To properly map this controller, ensure your config/routing.py + # file has a resource setup: + # map.resource('repo', 'repos') + def __before__(self): + c.staticurl = g.statics + c.admin_user = session.get('admin_user') + c.admin_username = session.get('admin_username') + + def index(self, format='html'): + """GET /repos: All items in the collection""" + # url('repos') + return render('/repos_manage.html') + + def create(self): + """POST /repos: Create a new item""" + # url('repos') + + def new(self, format='html'): + """GET /repos/new: Form to create a new item""" + # url('new_repo') + + def update(self, id): + """PUT /repos/id: Update an existing item""" + # Forms posted to this method should contain a hidden field: + # + # Or using helpers: + # h.form(url('repo', id=ID), + # method='put') + # url('repo', id=ID) + + def delete(self, id): + """DELETE /repos/id: Delete an existing item""" + # Forms posted to this method should contain a hidden field: + # + # Or using helpers: + # h.form(url('repo', id=ID), + # method='delete') + # url('repo', id=ID) + + def show(self, id, format='html'): + """GET /repos/id: Show a specific item""" + # url('repo', id=ID) + + def edit(self, id, format='html'): + """GET /repos/id/edit: Form to edit an existing item""" + # url('edit_repo', id=ID) diff --git a/pylons_app/controllers/users.py b/pylons_app/controllers/users.py new file mode 100644 --- /dev/null +++ b/pylons_app/controllers/users.py @@ -0,0 +1,60 @@ +import logging + +from pylons import request, response, session, tmpl_context as c, url, app_globals as g +from pylons.controllers.util import abort, redirect + +from pylons_app.lib.base import BaseController, render +from pylons_app.lib import auth +log = logging.getLogger(__name__) + +class UsersController(BaseController): + """REST Controller styled on the Atom Publishing Protocol""" + # To properly map this controller, ensure your config/routing.py + # file has a resource setup: + # map.resource('user', 'users') + def __before__(self): + c.staticurl = g.statics + c.admin_user = session.get('admin_user') + c.admin_username = session.get('admin_username') + + def index(self, format='html'): + """GET /users: All items in the collection""" + # url('users') + conn, cur = auth.get_sqlite_conn_cur() + cur.execute('SELECT * FROM users') + c.users_list = cur.fetchall() + return render('/users_manage.html') + + def create(self): + """POST /users: Create a new item""" + # url('users') + + def new(self, format='html'): + """GET /users/new: Form to create a new item""" + # url('new_user') + + def update(self, id): + """PUT /users/id: Update an existing item""" + # Forms posted to this method should contain a hidden field: + # + # Or using helpers: + # h.form(url('user', id=ID), + # method='put') + # url('user', id=ID) + + def delete(self, id): + """DELETE /users/id: Delete an existing item""" + # Forms posted to this method should contain a hidden field: + # + # Or using helpers: + # h.form(url('user', id=ID), + # method='delete') + # url('user', id=ID) + + def show(self, id, format='html'): + """GET /users/id: Show a specific item""" + # url('user', id=ID) + + def edit(self, id, format='html'): + """GET /users/id/edit: Form to edit an existing item""" + # url('edit_user', id=ID) diff --git a/pylons_app/public/hg_static/style-monoblue.css b/pylons_app/public/hg_static/style-monoblue.css --- a/pylons_app/public/hg_static/style-monoblue.css +++ b/pylons_app/public/hg_static/style-monoblue.css @@ -146,7 +146,9 @@ ul.submenu li { font-size: 1.2em; display: inline; } - +ul.submenu li.current_submenu { + border-bottom: 2px solid #006699; +} h2 { margin: 20px 0 10px; height: 30px; diff --git a/pylons_app/templates/admin.html b/pylons_app/templates/admin.html --- a/pylons_app/templates/admin.html +++ b/pylons_app/templates/admin.html @@ -25,10 +25,10 @@ %if c.admin_user:
Id | Username | Password | Active | -Admin | + %for i in c.users_list:
---|---|---|---|---|
${i[0]} | ${i[1]} | ${i[2]} | ${i[3]} | +${i[4]} |