141 finder = self.vreg['components'].select('recipients_finder', self.req, |
141 finder = self.vreg['components'].select('recipients_finder', self.req, |
142 rset=self.rset) |
142 rset=self.rset) |
143 return finder.recipients() |
143 return finder.recipients() |
144 |
144 |
145 def subject(self): |
145 def subject(self): |
146 entity = self.entity(self.row or 0, self.col or 0) |
146 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
147 subject = self.req._(self.message) |
147 subject = self.req._(self.message) |
148 etype = entity.dc_type() |
148 etype = entity.dc_type() |
149 eid = entity.eid |
149 eid = entity.eid |
150 login = self.user_login() |
150 login = self.user_login() |
151 return self.req._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals() |
151 return self.req._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals() |
154 # req is actually a session (we are on the server side), and we have to |
154 # req is actually a session (we are on the server side), and we have to |
155 # prevent nested internal session |
155 # prevent nested internal session |
156 return self.req.actual_session().user.login |
156 return self.req.actual_session().user.login |
157 |
157 |
158 def context(self, **kwargs): |
158 def context(self, **kwargs): |
159 entity = self.entity(self.row or 0, self.col or 0) |
159 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
160 for key, val in kwargs.iteritems(): |
160 for key, val in kwargs.iteritems(): |
161 if val and isinstance(val, unicode) and val.strip(): |
161 if val and isinstance(val, unicode) and val.strip(): |
162 kwargs[key] = self.req._(val) |
162 kwargs[key] = self.req._(val) |
163 kwargs.update({'user': self.user_login(), |
163 kwargs.update({'user': self.user_login(), |
164 'eid': entity.eid, |
164 'eid': entity.eid, |
185 warn('recipients should now return a list of 2-uple (email, language)', |
185 warn('recipients should now return a list of 2-uple (email, language)', |
186 DeprecationWarning, stacklevel=1) |
186 DeprecationWarning, stacklevel=1) |
187 lang = self.vreg.property_value('ui.language') |
187 lang = self.vreg.property_value('ui.language') |
188 recipients = zip(recipients, repeat(lang)) |
188 recipients = zip(recipients, repeat(lang)) |
189 if self.rset is not None: |
189 if self.rset is not None: |
190 entity = self.entity(self.row or 0, self.col or 0) |
190 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
191 # if the view is using timestamp in message ids, no way to reference |
191 # if the view is using timestamp in message ids, no way to reference |
192 # previous email |
192 # previous email |
193 if not self.msgid_timestamp: |
193 if not self.msgid_timestamp: |
194 refs = [self.construct_message_id(eid) |
194 refs = [self.construct_message_id(eid) |
195 for eid in entity.notification_references(self)] |
195 for eid in entity.notification_references(self)] |
282 |
282 |
283 url: %(url)s |
283 url: %(url)s |
284 """ |
284 """ |
285 |
285 |
286 def context(self, **kwargs): |
286 def context(self, **kwargs): |
287 entity = self.entity(self.row or 0, self.col or 0) |
287 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
288 content = entity.printable_value(self.content_attr, format='text/plain') |
288 content = entity.printable_value(self.content_attr, format='text/plain') |
289 if content: |
289 if content: |
290 contentformat = getattr(entity, self.content_attr + '_format', 'text/rest') |
290 contentformat = getattr(entity, self.content_attr + '_format', 'text/rest') |
291 content = normalize_text(content, 80, rest=contentformat=='text/rest') |
291 content = normalize_text(content, 80, rest=contentformat=='text/rest') |
292 return super(ContentAddedView, self).context(content=content, **kwargs) |
292 return super(ContentAddedView, self).context(content=content, **kwargs) |
293 |
293 |
294 def subject(self): |
294 def subject(self): |
295 entity = self.entity(self.row or 0, self.col or 0) |
295 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
296 return u'%s #%s (%s)' % (self.req.__('New %s' % entity.e_schema), |
296 return u'%s #%s (%s)' % (self.req.__('New %s' % entity.e_schema), |
297 entity.eid, self.user_login()) |
297 entity.eid, self.user_login()) |
298 |
298 |
299 NormalizedTextView = class_renamed('NormalizedTextView', ContentAddedView) |
299 NormalizedTextView = class_renamed('NormalizedTextView', ContentAddedView) |