4921: Want a "Main Participants" entry in sidebar eventfilter
svn: r17539
This commit is contained in:
parent
654fb81665
commit
fabbb30970
@ -35,6 +35,7 @@ from gen.ggettext import gettext as _
|
||||
import DateHandler
|
||||
from gen.lib import EventType
|
||||
from Filters.Rules import Rule
|
||||
from Utils import get_participant_from_event
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -48,7 +49,8 @@ class HasEventBase(Rule):
|
||||
labels = [ _('Event type:'),
|
||||
_('Date:'),
|
||||
_('Place:'),
|
||||
_('Description:') ]
|
||||
_('Description:'),
|
||||
_('Main Participants') ]
|
||||
name = _('Events matching parameters')
|
||||
description = _("Matches events with particular parameters")
|
||||
category = _('Event filters')
|
||||
@ -86,4 +88,9 @@ class HasEventBase(Rule):
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
if self.list[4] and get_participant_from_event(db, event.get_handle(),
|
||||
all_=True).upper().find(self.list[4].upper()) == -1:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -69,6 +69,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
self.filter_event.set_type,
|
||||
self.filter_event.get_type)
|
||||
|
||||
self.filter_mainparts = gtk.Entry()
|
||||
self.filter_date = gtk.Entry()
|
||||
self.filter_place = gtk.Entry()
|
||||
self.filter_note = gtk.Entry()
|
||||
@ -90,6 +91,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
self.add_text_entry(_('ID'), self.filter_id)
|
||||
self.add_text_entry(_('Description'), self.filter_desc)
|
||||
self.add_entry(_('Type'), self.etype)
|
||||
self.add_text_entry(_('Main Participants'), self.filter_mainparts)
|
||||
self.add_text_entry(_('Date'), self.filter_date)
|
||||
self.add_text_entry(_('Place'), self.filter_place)
|
||||
self.add_text_entry(_('Note'), self.filter_note)
|
||||
@ -99,6 +101,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
def clear(self, obj):
|
||||
self.filter_id.set_text(u'')
|
||||
self.filter_desc.set_text(u'')
|
||||
self.filter_mainparts.set_text(u'')
|
||||
self.filter_date.set_text(u'')
|
||||
self.filter_place.set_text(u'')
|
||||
self.filter_note.set_text(u'')
|
||||
@ -108,6 +111,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
def get_filter(self):
|
||||
gid = unicode(self.filter_id.get_text()).strip()
|
||||
desc = unicode(self.filter_desc.get_text()).strip()
|
||||
mainparts = unicode(self.filter_mainparts.get_text()).strip()
|
||||
date = unicode(self.filter_date.get_text()).strip()
|
||||
place = unicode(self.filter_place.get_text()).strip()
|
||||
note = unicode(self.filter_note.get_text()).strip()
|
||||
@ -115,7 +119,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
generic = self.generic.get_active() > 0
|
||||
etype = self.filter_event.get_type().xml_str()
|
||||
|
||||
empty = not (gid or desc or date or place or note
|
||||
empty = not (gid or desc or mainparts or date or place or note
|
||||
or etype or regex or generic)
|
||||
if empty:
|
||||
generic_filter = None
|
||||
@ -128,7 +132,7 @@ class EventSidebarFilter(SidebarFilter):
|
||||
rule = HasIdOf([gid])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
rule = HasEvent([etype, date, place, desc])
|
||||
rule = HasEvent([etype, date, place, desc, mainparts])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
if note:
|
||||
|
16
src/Utils.py
16
src/Utils.py
@ -1291,13 +1291,13 @@ def update_constants():
|
||||
# Function to return the name of the main participant of an event
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
def get_participant_from_event(db, event_handle):
|
||||
def get_participant_from_event(db, event_handle, all_=False):
|
||||
"""
|
||||
Obtain the first primary or family participant to an event we find in the
|
||||
database. Note that an event can have more than one primary or
|
||||
family participant, only one is returned, adding ellipses if there are
|
||||
more.
|
||||
more. If the all_ parameter is true a comma-space separated string with
|
||||
the names of all primary participants is returned and no ellipses is used.
|
||||
"""
|
||||
participant = ""
|
||||
ellipses = False
|
||||
@ -1314,7 +1314,10 @@ def get_participant_from_event(db, event_handle):
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role().is_primary():
|
||||
if participant:
|
||||
ellipses = True
|
||||
if all_:
|
||||
participant += ', %s' % name_displayer.display(person)
|
||||
else:
|
||||
ellipses = True
|
||||
else:
|
||||
participant = name_displayer.display(person)
|
||||
break
|
||||
@ -1329,7 +1332,10 @@ def get_participant_from_event(db, event_handle):
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role().is_family():
|
||||
if participant:
|
||||
ellipses = True
|
||||
if all_:
|
||||
participant += ', %s' % family_name(family, db)
|
||||
else:
|
||||
ellipses = True
|
||||
else:
|
||||
participant = family_name(family, db)
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user