Skip to content

Commit

Permalink
update timeline search for event name display format (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Jan 2, 2025
1 parent a3d67db commit 4ff1d3c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Changed
- Capitalize event description in UI (#1522)
- Display event name in UI friendly format (#1524)
- Display search results with new layout (#1521)
- Enable search for display formatting of event name (#1525)


v1.0.3 (2024-12-12)
Expand Down
1 change: 1 addition & 0 deletions docs/source/major_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Release Highlights
==================

- Update timeline event displaying in UI
- Enable timeline search for display formatting of event name


v1.0.3 (2024-12-12)
Expand Down
1 change: 1 addition & 0 deletions timeline/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def find(self, search_terms, keywords=None):
term_query = Q()
for t in search_terms:
term_query.add(Q(event_name__icontains=t), Q.OR)
term_query.add(Q(event_name__icontains=t.replace(' ', '_')), Q.OR)
term_query.add(Q(description__icontains=t), Q.OR)
term_query.add(Q(event_objects__name__icontains=t), Q.OR)
items = (
Expand Down
19 changes: 18 additions & 1 deletion timeline/tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
SITE_PLUGIN_TITLE = 'Site-Wide Events'
ADMIN_PLUGIN_NAME = 'timeline_site_admin'
ADMIN_PLUGIN_TITLE = 'All Timeline Events'
EVENT_NAME = 'test_event'
SEARCH_TERMS = ['test']
SEARCH_RET_CAT = 'all'
SEARCH_RET_TITLE = 'Timeline Events'
Expand Down Expand Up @@ -89,7 +90,7 @@ def setUp(self):
'project': self.project,
'app_name': 'projectroles',
'user': self.user,
'event_name': 'test_event',
'event_name': EVENT_NAME,
'description': 'description',
}
self.timeline = get_backend_api('timeline_backend')
Expand Down Expand Up @@ -165,6 +166,22 @@ def test_search_events(self):
self.assertEqual(ret[0].items[0], event2)
self.assertEqual(ret[0].items[1], event)

def test_search_event_name(self):
"""Test search() with event name"""
event = self.timeline.add_event(**self.event_kw)
ret = self.plugin.search([EVENT_NAME], self.user)
self.assertEqual(len(ret), 1)
self.assertEqual(len(ret[0].items), 1)
self.assertEqual(ret[0].items[0], event)

def test_search_event_name_display(self):
"""Test search() with event name in display formatting"""
event = self.timeline.add_event(**self.event_kw)
ret = self.plugin.search(['Test Event'], self.user)
self.assertEqual(len(ret), 1)
self.assertEqual(len(ret[0].items), 1)
self.assertEqual(ret[0].items[0], event)

def test_search_invalid_terms(self):
"""Test search() with invalid terms"""
self.timeline.add_event(**self.event_kw)
Expand Down

0 comments on commit 4ff1d3c

Please sign in to comment.