From f6eae9be743a93f3baf64f00f857e6dad5c3e7f4 Mon Sep 17 00:00:00 2001 From: Philippe Gross Date: Wed, 14 Aug 2019 15:57:01 +0200 Subject: [PATCH] Remove userid from the users fullname in all teamraum sources. The userid is not necessary in all the teamraum sources. --- docs/HISTORY.txt | 1 + opengever/ogds/base/sources.py | 11 +++++++++++ opengever/workspace/tests/test_workspace_sources.py | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index db08138f24..6bd83a5a81 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -5,6 +5,7 @@ Changelog ------------------------ - Update workflow security for opengever_workspace workflow to fix permission on existing workspaces. [elioschmutz] +- Remove userid from the users fullname in all teamraum sources. [phgross] - Move task reminders of responsibles to the successor, when accepting a multi admin unit task. [phgross] - Bump ftw.tabbedview version to 4.1.3 [njohner] diff --git a/opengever/ogds/base/sources.py b/opengever/ogds/base/sources.py index 6b7ae7696d..a04723ead7 100644 --- a/opengever/ogds/base/sources.py +++ b/opengever/ogds/base/sources.py @@ -608,6 +608,17 @@ def _extend_query_with_workspace_filter(self, query): query = query.filter(sql.false()) return query + def getTerm(self, value): + """We only need the user fullname as title without the userid in + brackets. + """ + try: + user = self.base_query.filter(User.userid == value).one() + except orm.exc.NoResultFound: + raise LookupError( + 'No row was found with userid: {}'.format(value)) + return SimpleTerm(value, value, user.fullname()) + @implementer(IContextSourceBinder) class ActualWorkspaceMembersSourceBinder(object): diff --git a/opengever/workspace/tests/test_workspace_sources.py b/opengever/workspace/tests/test_workspace_sources.py index dad5268761..8bd71096bd 100644 --- a/opengever/workspace/tests/test_workspace_sources.py +++ b/opengever/workspace/tests/test_workspace_sources.py @@ -171,3 +171,13 @@ def test_only_users_with_local_roles_with_view_permissions_are_found_by_search(s results = source.search(self.workspace_guest.id) self.assertEqual(0, len(results)) + + def test_title_is_fullname_only(self): + self.login(self.workspace_admin) + source = ActualWorkspaceMembersSource(self.workspace) + + term = source.search('beatrice')[0] + + self.assertEqual(self.workspace_member.id, term.token) + self.assertEqual(self.workspace_member.id, term.value) + self.assertEqual(u'Schr\xf6dinger B\xe9atrice', term.title)