[Mpuls-commits] r2983 - in jmd/trunk/jmdweb: controllers lib templates

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jun 10 13:15:06 CEST 2010


Author: bh
Date: 2010-06-10 13:15:05 +0200 (Thu, 10 Jun 2010)
New Revision: 2983

Modified:
   jmd/trunk/jmdweb/controllers/jmdstruktur.py
   jmd/trunk/jmdweb/lib/validators.py
   jmd/trunk/jmdweb/templates/main.mako
Log:
* jmdweb/controllers/jmdstruktur.py
(JmdstrukturController.permission)
(JmdstrukturController.permissionAction): Use
jmdweb.model.struktur to access the struktur-permissions.  This
information is not stored in the agency settings anymore.

* jmdweb/lib/validators.py (PermissionForm.userid): The user ids
are now ints.

* jmdweb/templates/main.mako: Adapt logic to decide whether to
show the struktur links to jmdweb.model.struktur.


Modified: jmd/trunk/jmdweb/controllers/jmdstruktur.py
===================================================================
--- jmd/trunk/jmdweb/controllers/jmdstruktur.py	2010-06-10 10:56:41 UTC (rev 2982)
+++ jmd/trunk/jmdweb/controllers/jmdstruktur.py	2010-06-10 11:15:05 UTC (rev 2983)
@@ -39,6 +39,7 @@
 from mpulsweb.lib.security import checkRole
 
 from jmdweb.lib.validators import PermissionForm
+from jmdweb.model.struktur import get_struktur_users, set_struktur_users
 
 
 log = logging.getLogger(__name__)
@@ -52,23 +53,17 @@
 
     @checkRole('admin')
     def permission(self):
-        agency = Agency()
-        permission = agency.get_value('jmdstrukur_permission_userid',
-                                      []).split(',')
-        c.userlist = UserListObject().getUserList()
-        userlist = UserListObject().getUserList()
-        defaults = {'userid': permission}
-        page = render('jmdstruktur/permission.mako')
-        return formencode.htmlfill.render(page, defaults=defaults, errors={})
+        userlist = UserListObject()
+        c.userlist = userlist.getUserList(filter=[u.id for u in
+                                                  userlist.getAdminList()])
+        defaults = dict(userid=get_struktur_users())
+        return formencode.htmlfill.render(render('jmdstruktur/permission.mako'),
+                                          defaults=defaults)
 
     @checkRole('admin')
     def permissionAction(self):
-        agency = Agency()
-        validator = PermissionForm()
-        c.userlist = UserListObject().getUserList()
-        form_resut = validator.to_python(request.params)
-        agency.store({'jmdstrukur_permission_userid':
-                      ",".join(form_resut['userid'])})
+        form_result = PermissionForm().to_python(request.params)
+        set_struktur_users(form_result['userid'])
         c.status_msg = h.status_message("Berechtigung erfolgreich gesetzt.")
         return self.permission()
 

Modified: jmd/trunk/jmdweb/lib/validators.py
===================================================================
--- jmd/trunk/jmdweb/lib/validators.py	2010-06-10 10:56:41 UTC (rev 2982)
+++ jmd/trunk/jmdweb/lib/validators.py	2010-06-10 11:15:05 UTC (rev 2983)
@@ -37,7 +37,9 @@
     adresse_plz = String()
     statement_signed = Bool(if_missing=False)
 
+
 class PermissionForm(BaseFormValidator):
-    userid = ForEach(String(), convert_to_list=True)
 
+    userid = ForEach(Int(), convert_to_list=True)
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8

Modified: jmd/trunk/jmdweb/templates/main.mako
===================================================================
--- jmd/trunk/jmdweb/templates/main.mako	2010-06-10 10:56:41 UTC (rev 2982)
+++ jmd/trunk/jmdweb/templates/main.mako	2010-06-10 11:15:05 UTC (rev 2983)
@@ -133,26 +133,18 @@
       </div>
     </div>
     <%
-    from mpulsweb.model.agencysettings import Agency
-    permission = [int(id) for id in Agency().get_value('jmdstrukur_permission_userid', "").split(',') if id != '']
+    from jmdweb.model.struktur import is_struktur_user
     %>
-    % if session['USER_AUTHORIZED'].id in permission or h.hasRole(['admin']):
+    % if h.hasRole(['admin']) or is_struktur_user():
       <div class="menu">
         <div class="actions">
           <h1>${_('Strukturdaten')}</h1>
           <ul>
-            % if session['USER_AUTHORIZED'].id in permission:
-              <li>
-                <a href="${h.url_for(controller='/jmdstruktur')}">
-                  ${_('JMD-Fallakten')}
-                </a>
-              </li>
-              <li>
-                <a href="${h.url_for(controller='/jmdstruktur/new')}">
-                  ${_('JMD-Fallakte anlegen')}
-                </a>
-              </li>
-            %endif
+            <li>
+              ## hier kein url_for, da diese URL auf eine andere WSGI
+              ## Applikation verweist
+              <a href="/struktur">Zum Strukturteil wechseln</a>
+            </li>
             %if h.hasRole(['admin']):
             <li>
               <a href="${h.url_for(controller='/jmdstruktur/permission')}">



More information about the Mpuls-commits mailing list