changeset 230:d982ed8e32d8

Admin templating updates, added rest permission controllers
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 27 May 2010 00:44:49 +0200
parents 69a29242ba61
children a7b0814267cb
files pylons_app/config/routing.py pylons_app/controllers/permissions.py pylons_app/public/css/monoblue_custom.css pylons_app/templates/admin/admin.html pylons_app/templates/admin/permissions/permissions.html pylons_app/templates/admin/repos/repo_add.html pylons_app/templates/admin/repos/repo_edit.html pylons_app/templates/admin/repos/repos.html pylons_app/templates/admin/users/user_add.html pylons_app/templates/admin/users/user_edit.html pylons_app/templates/admin/users/users.html pylons_app/tests/functional/test_permissions.py
diffstat 12 files changed, 127 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/config/routing.py	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/config/routing.py	Thu May 27 00:44:49 2010 +0200
@@ -25,6 +25,7 @@
     #REST controllers
     map.resource('repo', 'repos', path_prefix='/_admin')
     map.resource('user', 'users', path_prefix='/_admin')
+    map.resource('permission', 'permissions', path_prefix='/_admin')
     
     #ADMIN
     with map.submapper(path_prefix='/_admin', controller='admin') as m:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/controllers/permissions.py	Thu May 27 00:44:49 2010 +0200
@@ -0,0 +1,53 @@
+import logging
+
+from pylons import request, response, session, tmpl_context as c, url
+from pylons.controllers.util import abort, redirect
+
+from pylons_app.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class PermissionsController(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('permission', 'permissions')
+
+    def index(self, format='html'):
+        """GET /permissions: All items in the collection"""
+        # url('permissions')
+        return render('admin/permissions/permissions.html')
+
+    def create(self):
+        """POST /permissions: Create a new item"""
+        # url('permissions')
+
+    def new(self, format='html'):
+        """GET /permissions/new: Form to create a new item"""
+        # url('new_permission')
+
+    def update(self, id):
+        """PUT /permissions/id: Update an existing item"""
+        # Forms posted to this method should contain a hidden field:
+        #    <input type="hidden" name="_method" value="PUT" />
+        # Or using helpers:
+        #    h.form(url('permission', id=ID),
+        #           method='put')
+        # url('permission', id=ID)
+
+    def delete(self, id):
+        """DELETE /permissions/id: Delete an existing item"""
+        # Forms posted to this method should contain a hidden field:
+        #    <input type="hidden" name="_method" value="DELETE" />
+        # Or using helpers:
+        #    h.form(url('permission', id=ID),
+        #           method='delete')
+        # url('permission', id=ID)
+
+    def show(self, id, format='html'):
+        """GET /permissions/id: Show a specific item"""
+        # url('permission', id=ID)
+
+    def edit(self, id, format='html'):
+        """GET /permissions/id/edit: Form to edit an existing item"""
+        # url('edit_permission', id=ID)
--- a/pylons_app/public/css/monoblue_custom.css	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/public/css/monoblue_custom.css	Thu May 27 00:44:49 2010 +0200
@@ -121,12 +121,12 @@
 	font-weight: bold;
 	font-family: sans-serif;
 	letter-spacing: 1px;
-	color: #DDD;
+	color: #FFFFFF;
 }
 
 div.page-header h1 a {
 	font-weight: bold;
-	color: #FFF;
+	color: #FFFFFF;
 }
 
 div.page-header a {
--- a/pylons_app/templates/admin/admin.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/admin.html	Thu May 27 00:44:49 2010 +0200
@@ -6,7 +6,6 @@
 </%def>
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
-	 /  
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/templates/admin/permissions/permissions.html	Thu May 27 00:44:49 2010 +0200
@@ -0,0 +1,21 @@
+## -*- coding: utf-8 -*-
+<%inherit file="/base/base.html"/>
+
+<%def name="title()">
+    ${_('Permissions administration')}
+</%def>
+<%def name="breadcrumbs()">
+	${h.link_to(u'Admin',h.url('admin_home'))}
+	 /  
+	 ${_('Permissions')}
+</%def>
+<%def name="page_nav()">
+	${self.menu('admin')}
+	${self.submenu('permissions')}
+</%def>
+<%def name="main()">
+	<div>
+	<h2>${_('Permissions')}</h2>
+	todo :) 
+    </div>
+</%def>    
--- a/pylons_app/templates/admin/repos/repo_add.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/repos/repo_add.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	${_('Repos')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- a/pylons_app/templates/admin/repos/repo_edit.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/repos/repo_edit.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	 ${_('Repos')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
@@ -15,7 +16,7 @@
 <%def name="main()">
 	<div>
         <h2>${_('Repositories')} - ${_('edit')}</h2>
-        ${h.form(url('repo', id=ID),method='put'))}
+        ${h.form(url('repo', id=c.new_repo),method='put')}
         <table>
         	<tr>
         		<td>${_('Name')}</td>
--- a/pylons_app/templates/admin/repos/repos.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/repos/repos.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	 ${_('Repos')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- a/pylons_app/templates/admin/users/user_add.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/users/user_add.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	 ${_('Users')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- a/pylons_app/templates/admin/users/user_edit.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/users/user_edit.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	${_('Users')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- a/pylons_app/templates/admin/users/users.html	Thu May 27 00:26:02 2010 +0200
+++ b/pylons_app/templates/admin/users/users.html	Thu May 27 00:44:49 2010 +0200
@@ -7,6 +7,7 @@
 <%def name="breadcrumbs()">
 	${h.link_to(u'Admin',h.url('admin_home'))}
 	 /  
+	 ${_('Users')}
 </%def>
 <%def name="page_nav()">
 	${self.menu('admin')}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/tests/functional/test_permissions.py	Thu May 27 00:44:49 2010 +0200
@@ -0,0 +1,43 @@
+from pylons_app.tests import *
+
+class TestPermissionsController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url('permissions'))
+        # Test response...
+
+    def test_index_as_xml(self):
+        response = self.app.get(url('formatted_permissions', format='xml'))
+
+    def test_create(self):
+        response = self.app.post(url('permissions'))
+
+    def test_new(self):
+        response = self.app.get(url('new_permission'))
+
+    def test_new_as_xml(self):
+        response = self.app.get(url('formatted_new_permission', format='xml'))
+
+    def test_update(self):
+        response = self.app.put(url('permission', id=1))
+
+    def test_update_browser_fakeout(self):
+        response = self.app.post(url('permission', id=1), params=dict(_method='put'))
+
+    def test_delete(self):
+        response = self.app.delete(url('permission', id=1))
+
+    def test_delete_browser_fakeout(self):
+        response = self.app.post(url('permission', id=1), params=dict(_method='delete'))
+
+    def test_show(self):
+        response = self.app.get(url('permission', id=1))
+
+    def test_show_as_xml(self):
+        response = self.app.get(url('formatted_permission', id=1, format='xml'))
+
+    def test_edit(self):
+        response = self.app.get(url('edit_permission', id=1))
+
+    def test_edit_as_xml(self):
+        response = self.app.get(url('formatted_edit_permission', id=1, format='xml'))