web/views/massmailing.py
changeset 3451 6b46d73823f5
parent 3377 dd9d292b6a6d
child 3457 0924d0d08d60
--- a/web/views/massmailing.py	Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/massmailing.py	Wed Sep 23 19:40:19 2009 +0200
@@ -31,9 +31,9 @@
 
     def url(self):
         params = {'vid': 'massmailing', '__force_display': 1}
-        if self.req.form.has_key('rql'):
-            params['rql'] = self.req.form['rql']
-        return self.build_url(self.req.relative_path(includeparams=False),
+        if self._cw.form.has_key('rql'):
+            params['rql'] = self._cw.form['rql']
+        return self.build_url(self._cw.relative_path(includeparams=False),
                               **params)
 
 
@@ -54,21 +54,21 @@
 
     def form_field_vocabulary(self, field):
         if field.name == 'recipient':
-            vocab = [(entity.get_email(), entity.eid) for entity in self.rset.entities()]
+            vocab = [(entity.get_email(), entity.eid) for entity in self.cw_rset.entities()]
             return [(label, value) for label, value in vocab if label]
         return super(MassMailingForm, self).form_field_vocabulary(field)
 
     def form_field_value(self, field, values):
         if field.name == 'recipient':
-            return [entity.eid for entity in self.rset.entities() if entity.get_email()]
+            return [entity.eid for entity in self.cw_rset.entities() if entity.get_email()]
         elif field.name == 'mailbody':
             field.widget.attrs['cubicweb:variables'] = ','.join(self.get_allowed_substitutions())
         return super(MassMailingForm, self).form_field_value(field, values)
 
     def get_allowed_substitutions(self):
         attrs = []
-        for coltype in self.rset.column_types(0):
-            eclass = self.vreg['etypes'].etype_class(coltype)
+        for coltype in self.cw_rset.column_types(0):
+            eclass = self._cw.vreg['etypes'].etype_class(coltype)
             attrs.append(eclass.allowed_massmail_keys())
         return sorted(reduce(operator.and_, attrs))
 
@@ -76,7 +76,7 @@
         insertLink = u'<a href="javascript: insertText(\'%%(%s)s\', \'emailarea\');">%%(%s)s</a>'
         substs = (u'<div class="substitution">%s</div>' % (insertLink % (subst, subst))
                   for subst in self.get_allowed_substitutions())
-        helpmsg = self.req._('You can use any of the following substitutions in your text')
+        helpmsg = self._cw._('You can use any of the following substitutions in your text')
         return u'<div id="substitutions"><span>%s</span>%s</div>' % (
             helpmsg, u'\n'.join(substs))
 
@@ -122,10 +122,10 @@
     __select__ = implements(IEmailable) & match_user_groups('managers', 'users')
 
     def call(self):
-        req = self.req
+        req = self._cw
         req.add_js('cubicweb.widgets.js', 'cubicweb.massmailing.js')
         req.add_css('cubicweb.mailform.css')
         from_addr = '%s <%s>' % (req.user.dc_title(), req.user.get_email())
-        form = self.vreg['forms'].select('massmailing', self.req, rset=self.rset,
+        form = self._cw.vreg['forms'].select('massmailing', self._cw, rset=self.cw_rset,
                                 action='sendmail', domid='sendmail')
         self.w(form.form_render(sender=from_addr))