Add ability to filter Send Messages by recipient name

This commit is contained in:
Lance Edgar 2017-02-17 14:24:30 -06:00
parent def2931ba6
commit 38aaebe08f

View file

@ -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):