From 665aaf9c05a6c6a1d62a88d1b26a75621a0e1f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Messiant?= Date: Tue, 8 Oct 2013 15:10:55 +0200 Subject: [PATCH] Show organization's and root organization's name in position's full title --- src/collective/contact/core/content/position.py | 14 +++++++++++--- .../contact/core/tests/test_content_types.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/collective/contact/core/content/position.py b/src/collective/contact/core/content/position.py index bc3cbc7..e496bb9 100644 --- a/src/collective/contact/core/content/position.py +++ b/src/collective/contact/core/content/position.py @@ -69,10 +69,18 @@ class Position(Container): def get_full_title(self): """Returns the full title of the position - It is constituted by the name of the position and - the name of its organization in brackets + It is constituted by the name of the position, + the name of its organization and the name of the + root organization in brackets. """ - return u"%s (%s)" % (self.title, self.get_organization().title) + organization = self.get_organization() + root_organization = organization.get_root_organization() + if organization == root_organization: + return u"%s (%s)" % (self.title, organization.title) + else: + return u"%s, %s (%s)" % (self.title, organization.title, + root_organization.title) + def get_held_positions(self): """Returns the held position diff --git a/src/collective/contact/core/tests/test_content_types.py b/src/collective/contact/core/tests/test_content_types.py index 1bb8eb0..0aa3071 100644 --- a/src/collective/contact/core/tests/test_content_types.py +++ b/src/collective/contact/core/tests/test_content_types.py @@ -159,7 +159,7 @@ class TestPosition(TestContentTypes): self.assertEqual(self.general_adt.get_full_title(), u"Général de l'armée de terre (Armée de terre)") self.assertEqual(self.sergent_lh.get_full_title(), - u"Sergent de la brigade LH (Brigade LH)") + u"Sergent de la brigade LH, Brigade LH (Armée de terre)") class TestHeldPosition(TestContentTypes):