[cleanup selectors] use authenticated_user, check for form params instead of handling potential key error on missing params
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 12 Mar 2010 15:00:25 +0100
changeset 4894 41c28ddca055
parent 4886 18a1735c283c
child 4895 7003912cec86
[cleanup selectors] use authenticated_user, check for form params instead of handling potential key error on missing params
web/views/basecontrollers.py
--- a/web/views/basecontrollers.py	Fri Mar 12 11:49:05 2010 +0100
+++ b/web/views/basecontrollers.py	Fri Mar 12 15:00:25 2010 +0100
@@ -17,9 +17,10 @@
 from logilab.common.decorators import cached
 from logilab.common.date import strptime
 
-from cubicweb import NoSelectableObject, ValidationError, ObjectNotFound, typed_eid
+from cubicweb import (NoSelectableObject, ValidationError, ObjectNotFound,
+                      typed_eid)
 from cubicweb.utils import CubicWebJsonEncoder
-from cubicweb.selectors import yes, match_user_groups
+from cubicweb.selectors import authenticated_user, match_form_params
 from cubicweb.mail import format_mail
 from cubicweb.web import ExplicitLogin, Redirect, RemoteCallFailed, json_dumps
 from cubicweb.web.controller import Controller
@@ -548,7 +549,7 @@
 
 class SendMailController(Controller):
     __regid__ = 'sendmail'
-    __select__ = match_user_groups('managers', 'users')
+    __select__ = authenticated_user() & match_form_params('recipient', 'mailbody', 'subject')
 
     def recipients(self):
         """returns an iterator on email's recipients as entities"""
@@ -596,7 +597,7 @@
 
 class MailBugReportController(SendMailController):
     __regid__ = 'reportbug'
-    __select__ = yes()
+    __select__ = match_form_params('description')
 
     def publish(self, rset=None):
         body = self._cw.form['description']