diff --git a/tailbone/views/messages.py b/tailbone/views/messages.py index 2b3d556d..28461fed 100644 --- a/tailbone/views/messages.py +++ b/tailbone/views/messages.py @@ -176,24 +176,28 @@ class MessagesView(MasterView): .outerjoin(model.MessageRecipient)\ .filter(model.MessageRecipient.recipient == self.request.user) - def configure_grid(self, g): - + def _preconfigure_grid(self, g): g.joiners['sender'] = lambda q: q.join(model.User, model.User.uuid == model.Message.sender_uuid).outerjoin(model.Person) g.filters['sender'] = g.make_filter('sender', model.Person.display_name, default_active=True, default_verb='contains') g.sorters['sender'] = g.make_sorter(model.Person.display_name) + g.sender.set(label="From", renderer=SenderFieldRenderer) g.filters['subject'].default_active = True g.filters['subject'].default_verb = 'contains' + g.subject.set(renderer=SubjectFieldRenderer) + + g.recipients.set(label="To", renderer=TerseRecipientsFieldRenderer) g.default_sortkey = 'sent' g.default_sortdir = 'desc' + def configure_grid(self, g): g.configure( include=[ - g.subject.with_renderer(SubjectFieldRenderer), - g.sender.with_renderer(SenderFieldRenderer).label("From"), - g.recipients.with_renderer(TerseRecipientsFieldRenderer).label("To"), + g.subject, + g.sender, + g.recipients, g.sent, ], readonly=True) @@ -476,9 +480,14 @@ class SentView(MessagesView): return session.query(model.Message)\ .filter(model.Message.sender == self.request.user) - def configure_grid(self, g): - super(SentView, self).configure_grid(g) + def _preconfigure_grid(self, g): + super(SentView, self)._preconfigure_grid(g) g.filters['sender'].default_active = False + g.joiners['recipients'] = lambda q: q.join(model.MessageRecipient)\ + .join(model.User, model.User.uuid == model.MessageRecipient.recipient_uuid)\ + .join(model.Person) + g.filters['recipients'] = g.make_filter('recipients', model.Person.display_name, + default_active=True, default_verb='contains') def includeme(config):