31 persons = entity.reverse_primary_email |
31 persons = entity.reverse_primary_email |
32 except Unauthorized: |
32 except Unauthorized: |
33 persons = [] |
33 persons = [] |
34 if persons: |
34 if persons: |
35 emailof = persons[0] |
35 emailof = persons[0] |
36 self.field(display_name(self.req, 'primary_email', 'object'), emailof.view('oneline')) |
36 self.field(display_name(self._cw, 'primary_email', 'object'), emailof.view('oneline')) |
37 pemaileid = emailof.eid |
37 pemaileid = emailof.eid |
38 else: |
38 else: |
39 pemaileid = None |
39 pemaileid = None |
40 try: |
40 try: |
41 emailof = 'use_email' in self.schema and entity.reverse_use_email or () |
41 emailof = 'use_email' in self._cw.schema and entity.reverse_use_email or () |
42 emailof = [e for e in emailof if not e.eid == pemaileid] |
42 emailof = [e for e in emailof if not e.eid == pemaileid] |
43 except Unauthorized: |
43 except Unauthorized: |
44 emailof = [] |
44 emailof = [] |
45 if emailof: |
45 if emailof: |
46 emailofstr = ', '.join(e.view('oneline') for e in emailof) |
46 emailofstr = ', '.join(e.view('oneline') for e in emailof) |
47 self.field(display_name(self.req, 'use_email', 'object'), emailofstr) |
47 self.field(display_name(self._cw, 'use_email', 'object'), emailofstr) |
48 |
48 |
49 def render_entity_relations(self, entity): |
49 def render_entity_relations(self, entity): |
50 for i, email in enumerate(entity.related_emails(self.skipeids)): |
50 for i, email in enumerate(entity.related_emails(self.skipeids)): |
51 self.w(u'<div class="%s">' % (i%2 and 'even' or 'odd')) |
51 self.w(u'<div class="%s">' % (i%2 and 'even' or 'odd')) |
52 email.view('oneline', w=self.w, contexteid=entity.eid) |
52 email.view('oneline', w=self.w, contexteid=entity.eid) |
66 |
66 |
67 class EmailAddressOneLineView(baseviews.OneLineView): |
67 class EmailAddressOneLineView(baseviews.OneLineView): |
68 __select__ = implements('EmailAddress') |
68 __select__ = implements('EmailAddress') |
69 |
69 |
70 def cell_call(self, row, col, **kwargs): |
70 def cell_call(self, row, col, **kwargs): |
71 entity = self.rset.get_entity(row, col) |
71 entity = self.cw_rset.get_entity(row, col) |
72 if entity.reverse_primary_email: |
72 if entity.reverse_primary_email: |
73 self.w(u'<b>') |
73 self.w(u'<b>') |
74 if entity.alias: |
74 if entity.alias: |
75 self.w(u'%s <' % xml_escape(entity.alias)) |
75 self.w(u'%s <' % xml_escape(entity.alias)) |
76 self.w('<a href="%s">%s</a>' % (xml_escape(entity.absolute_url()), |
76 self.w('<a href="%s">%s</a>' % (xml_escape(entity.absolute_url()), |
87 |
87 |
88 __regid__ = 'mailto' |
88 __regid__ = 'mailto' |
89 __select__ = implements('EmailAddress') |
89 __select__ = implements('EmailAddress') |
90 |
90 |
91 def cell_call(self, row, col, **kwargs): |
91 def cell_call(self, row, col, **kwargs): |
92 entity = self.rset.get_entity(row, col) |
92 entity = self.cw_rset.get_entity(row, col) |
93 if entity.reverse_primary_email: |
93 if entity.reverse_primary_email: |
94 self.w(u'<b>') |
94 self.w(u'<b>') |
95 if entity.alias: |
95 if entity.alias: |
96 alias = entity.alias |
96 alias = entity.alias |
97 elif entity.reverse_use_email: |
97 elif entity.reverse_use_email: |
110 |
110 |
111 class EmailAddressTextView(baseviews.TextView): |
111 class EmailAddressTextView(baseviews.TextView): |
112 __select__ = implements('EmailAddress') |
112 __select__ = implements('EmailAddress') |
113 |
113 |
114 def cell_call(self, row, col, **kwargs): |
114 def cell_call(self, row, col, **kwargs): |
115 self.w(self.rset.get_entity(row, col).display_address()) |
115 self.w(self.cw_rset.get_entity(row, col).display_address()) |