Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/URBBDC-3225.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Introduce configurable title formatting for housing, division and urbanc ertificate

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix typo in the feature note.

urbanc ertificate should be urban certificate.

Proposed fix
-Introduce configurable title formatting for housing, division and urbanc ertificate
+Introduce configurable title formatting for housing, division and urban certificate
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Introduce configurable title formatting for housing, division and urbanc ertificate
Introduce configurable title formatting for housing, division and urban certificate
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@news/URBBDC-3225.feature` at line 1, Update the feature note text that
currently contains the typo "urbanc ertificate" to read "urban certificate";
locate the title/description line in the URBBDC-3225.feature content where
"Introduce configurable title formatting for housing, division and urbanc
ertificate" appears and correct that phrase to "Introduce configurable title
formatting for housing, division and urban certificate".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo mentioned by coderabbit

[WBoudabous]
9 changes: 9 additions & 0 deletions src/Products/urban/LicenceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@
multiValued=True,
vocabulary_factory="urban.licence_state",
),
StringField(
name="customTitle",
widget=StringField._properties["widget"](
size=100,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a description to specify that this field will be only useful for Housing, Division, CODT_UrbanCertificateBase

label=_("urban_label_customTitle", default="Custom title"),
),
schemata="public_settings",
),

),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Products/urban/content/licence/Division.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions src/Products/urban/content/licence/GenericLicence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,15 @@ def getLicenceConfig(self):

return config_folder

def _apply_custom_title(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will introduce duplicate titles because all licences will have exactly the same one.

licence_config = self.getLicenceConfig()
custom_title = licence_config.getCustomTitle()
if custom_title:
self.setTitle(custom_title)
self.reindexObject(idxs=("Title", "sortable_title"))
return True
Comment thread
mpeeters marked this conversation as resolved.
return False

security.declarePublic("attributeIsUsed")

def attributeIsUsed(self, name):
Expand Down
3 changes: 3 additions & 0 deletions src/Products/urban/content/licence/Housing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions src/Products/urban/locales/fr/LC_MESSAGES/urban.po
Original file line number Diff line number Diff line change
Expand Up @@ -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é"
6 changes: 6 additions & 0 deletions src/Products/urban/migration/update_290.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ def update_folder_manager_notice(context):
logger.info("manageableLicences updated for notice FolderManager")


def update_custom_titles(context):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will no do anything because the licences configs are not updated before.

catalog = api.portal.get_tool("portal_catalog")
brains = catalog(portal_type=["Housing", "Division","CODT_UrbanCertificateBase"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use plone.api.content.find instead

for brain in brains:
obj = brain.getObject()
obj.updateTitle()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank lines and your code should be the latest migration.

def setup_index_referenceDGATLP(context):
logger = logging.getLogger("urban: Set up `referenceDGATLP` index")

Expand Down
8 changes: 8 additions & 0 deletions src/Products/urban/migration/upgrades_290.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,12 @@
handler=".update_290.setup_index_referenceDGATLP"
profile="Products.urban:default" />

<gs:upgradeStep
title="Update titles for Housing, Division and Urbanncertificate"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix typo in upgrade-step title.

Urbanncertificate should be UrbanCertificate.

Proposed fix
-        title="Update titles for Housing, Division and Urbanncertificate"
+        title="Update titles for Housing, Division and UrbanCertificate"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title="Update titles for Housing, Division and Urbanncertificate"
title="Update titles for Housing, Division and UrbanCertificate"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Products/urban/migration/upgrades_290.zcml` at line 112, Fix the typo in
the upgrade step title attribute: change the title value that currently reads
"Update titles for Housing, Division and Urbanncertificate" to "Update titles
for Housing, Division and UrbanCertificate" by updating the title="..."
attribute on the upgrade-step (or related element) so the "Urbanncertificate"
token is corrected to "UrbanCertificate".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo Urbanncertificate -> UrbanCertificate

description=""
source="2913"
destination="2914"
handler=".update_290.update_custom_titles"
profile="Products.urban:default" />

</configure>
2 changes: 1 addition & 1 deletion src/Products/urban/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>2913</version>
<version>2914</version>
<dependencies>
<dependency>profile-Products.urban:preinstall</dependency>
</dependencies>
Expand Down