diff --git a/news/URBBDC-3225.feature b/news/URBBDC-3225.feature new file mode 100644 index 000000000..bc86f0ae3 --- /dev/null +++ b/news/URBBDC-3225.feature @@ -0,0 +1,2 @@ +Introduce configurable title formatting for housing, division and urbanc ertificate +[WBoudabous] \ No newline at end of file diff --git a/src/Products/urban/LicenceConfig.py b/src/Products/urban/LicenceConfig.py index f038e5a53..3363c06a6 100644 --- a/src/Products/urban/LicenceConfig.py +++ b/src/Products/urban/LicenceConfig.py @@ -240,6 +240,15 @@ multiValued=True, vocabulary_factory="urban.licence_state", ), + StringField( + name="customTitle", + widget=StringField._properties["widget"]( + size=100, + label=_("urban_label_customTitle", default="Custom title"), + ), + schemata="public_settings", +), + ), ) diff --git a/src/Products/urban/content/licence/CODT_UrbanCertificateBase.py b/src/Products/urban/content/licence/CODT_UrbanCertificateBase.py index 04492bf56..63df2f04a 100644 --- a/src/Products/urban/content/licence/CODT_UrbanCertificateBase.py +++ b/src/Products/urban/content/licence/CODT_UrbanCertificateBase.py @@ -62,9 +62,10 @@ class CODT_UrbanCertificateBase(BaseFolder, UrbanCertificateBase, BrowserDefault schemata_order = ["urban_description", "urban_road", "urban_location"] ##/code-section class-header - # Methods - # Manually created methods + def updateTitle(self): + if not self._apply_custom_title(): + super(CODT_UrbanCertificateBase, self).updateTitle() registerType(CODT_UrbanCertificateBase, PROJECTNAME) diff --git a/src/Products/urban/content/licence/Division.py b/src/Products/urban/content/licence/Division.py index 1efdbf167..bc19e0830 100644 --- a/src/Products/urban/content/licence/Division.py +++ b/src/Products/urban/content/licence/Division.py @@ -351,6 +351,8 @@ def updateTitle(self): """ Update the title to set a clearly identify the buildlicence """ + if self._apply_custom_title(): + return notaries = "" proprietaries = "" if self.getProprietaries: diff --git a/src/Products/urban/content/licence/GenericLicence.py b/src/Products/urban/content/licence/GenericLicence.py index d822c1e1b..a6cfad49d 100755 --- a/src/Products/urban/content/licence/GenericLicence.py +++ b/src/Products/urban/content/licence/GenericLicence.py @@ -1564,6 +1564,15 @@ def getLicenceConfig(self): return config_folder + def _apply_custom_title(self): + licence_config = self.getLicenceConfig() + custom_title = licence_config.getCustomTitle() + if custom_title: + self.setTitle(custom_title) + self.reindexObject(idxs=("Title", "sortable_title")) + return True + return False + security.declarePublic("attributeIsUsed") def attributeIsUsed(self, name): diff --git a/src/Products/urban/content/licence/Housing.py b/src/Products/urban/content/licence/Housing.py index fb3c3cc3d..d2424be37 100644 --- a/src/Products/urban/content/licence/Housing.py +++ b/src/Products/urban/content/licence/Housing.py @@ -93,6 +93,9 @@ def displayBuildingPart(self): """Return a list of selected buiding part""" return self.getValuesForTemplate("buildingPart") + def updateTitle(self): + if not self._apply_custom_title(): + super(Housing, self).updateTitle() registerType(Housing, PROJECTNAME) diff --git a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po index bb2a8e6ef..baf175133 100644 --- a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po +++ b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po @@ -5910,3 +5910,6 @@ msgstr "Partie de l'immeuble concernée" msgid "urban_label_buildingType" msgstr "Nature de l'immeuble" + +msgid "urban_label_customTitle" +msgstr "Libellé personnalisé" \ No newline at end of file diff --git a/src/Products/urban/migration/update_290.py b/src/Products/urban/migration/update_290.py index fc7104b68..9255b4c51 100644 --- a/src/Products/urban/migration/update_290.py +++ b/src/Products/urban/migration/update_290.py @@ -365,6 +365,12 @@ def update_folder_manager_notice(context): logger.info("manageableLicences updated for notice FolderManager") +def update_custom_titles(context): + catalog = api.portal.get_tool("portal_catalog") + brains = catalog(portal_type=["Housing", "Division","CODT_UrbanCertificateBase"]) + for brain in brains: + obj = brain.getObject() + obj.updateTitle() def setup_index_referenceDGATLP(context): logger = logging.getLogger("urban: Set up `referenceDGATLP` index") diff --git a/src/Products/urban/migration/upgrades_290.zcml b/src/Products/urban/migration/upgrades_290.zcml index 6c7a963f9..486a86343 100644 --- a/src/Products/urban/migration/upgrades_290.zcml +++ b/src/Products/urban/migration/upgrades_290.zcml @@ -108,4 +108,12 @@ handler=".update_290.setup_index_referenceDGATLP" profile="Products.urban:default" /> + + diff --git a/src/Products/urban/profiles/default/metadata.xml b/src/Products/urban/profiles/default/metadata.xml index bff06b1bb..d8a98afe5 100644 --- a/src/Products/urban/profiles/default/metadata.xml +++ b/src/Products/urban/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 2913 + 2914 profile-Products.urban:preinstall