Add ability to filter Send Messages by recipient name
This commit is contained in:
parent
def2931ba6
commit
38aaebe08f
|
@ -176,24 +176,28 @@ class MessagesView(MasterView):
|
||||||
.outerjoin(model.MessageRecipient)\
|
.outerjoin(model.MessageRecipient)\
|
||||||
.filter(model.MessageRecipient.recipient == self.request.user)
|
.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.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,
|
g.filters['sender'] = g.make_filter('sender', model.Person.display_name,
|
||||||
default_active=True, default_verb='contains')
|
default_active=True, default_verb='contains')
|
||||||
g.sorters['sender'] = g.make_sorter(model.Person.display_name)
|
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_active = True
|
||||||
g.filters['subject'].default_verb = 'contains'
|
g.filters['subject'].default_verb = 'contains'
|
||||||
|
g.subject.set(renderer=SubjectFieldRenderer)
|
||||||
|
|
||||||
|
g.recipients.set(label="To", renderer=TerseRecipientsFieldRenderer)
|
||||||
|
|
||||||
g.default_sortkey = 'sent'
|
g.default_sortkey = 'sent'
|
||||||
g.default_sortdir = 'desc'
|
g.default_sortdir = 'desc'
|
||||||
|
|
||||||
|
def configure_grid(self, g):
|
||||||
g.configure(
|
g.configure(
|
||||||
include=[
|
include=[
|
||||||
g.subject.with_renderer(SubjectFieldRenderer),
|
g.subject,
|
||||||
g.sender.with_renderer(SenderFieldRenderer).label("From"),
|
g.sender,
|
||||||
g.recipients.with_renderer(TerseRecipientsFieldRenderer).label("To"),
|
g.recipients,
|
||||||
g.sent,
|
g.sent,
|
||||||
],
|
],
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
@ -476,9 +480,14 @@ class SentView(MessagesView):
|
||||||
return session.query(model.Message)\
|
return session.query(model.Message)\
|
||||||
.filter(model.Message.sender == self.request.user)
|
.filter(model.Message.sender == self.request.user)
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def _preconfigure_grid(self, g):
|
||||||
super(SentView, self).configure_grid(g)
|
super(SentView, self)._preconfigure_grid(g)
|
||||||
g.filters['sender'].default_active = False
|
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):
|
def includeme(config):
|
||||||
|
|
Loading…
Reference in a new issue