Skip to content

SUP-51436 toggle field visibility#548

Open
WBoudabous wants to merge 2 commits into
2.9.xfrom
SUP-51436_representative_field_visibility
Open

SUP-51436 toggle field visibility#548
WBoudabous wants to merge 2 commits into
2.9.xfrom
SUP-51436_representative_field_visibility

Conversation

@WBoudabous

@WBoudabous WBoudabous commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

This PR adds the ability to show or hide the "representativeContacts" field.

Summary by CodeRabbit

  • New Features

    • Added option to show or hide the representative contacts field.
  • Updates

    • Made the representative contacts field optional in the schema.

@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e5de887d-dbb1-47ae-9a5c-e3a0717d371f

📥 Commits

Reviewing files that changed from the base of the PR and between 8ebe581 and cde7b21.

📒 Files selected for processing (1)
  • news/SUP-51436.feature
✅ Files skipped from review due to trivial changes (1)
  • news/SUP-51436.feature

📝 Walkthrough

Walkthrough

The representativeContacts field in the BaseBuildLicence schema is marked as optional by adding it to the optional_fields list and setting optional=True on the ReferenceField definition. A feature changelog entry documents this modification.

Changes

Cohort / File(s) Summary
Schema Configuration
src/Products/urban/content/licence/BaseBuildLicence.py
Made representativeContacts field optional by adding it to optional_fields list and setting optional=True on the ReferenceField definition.
Feature Documentation
news/SUP-51436.feature
Added changelog entry describing the option to show or hide the representativeContacts field.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A field once bound, now free to roam,
Optional whispers find their home,
Contact representatives with choice,
The schema dances, gives them voice! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'SUP-51436 toggle field visibility' accurately captures the main change: making the representativeContacts field optional and toggleable, aligning with the PR's objective to add visibility control for this field.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SUP-51436_representative_field_visibility

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Products/urban/content/licence/BaseBuildLicence.py (1)

519-519: Avoid duplicating optionality configuration for representativeContacts.

At Line 519, optional=True duplicates what setOptionalAttributes(schema, optional_fields) already applies (including widget condition), creating two sources of truth for the same behavior.

Suggested cleanup
         ReferenceField(
             name="representativeContacts",
             widget=ReferenceBrowserWidget(
                 force_close_on_insert=1,
                 allow_search=1,
                 only_for_review_states="enabled",
                 allow_browse=0,
                 show_indexes=1,
                 available_indexes={"Title": "Nom"},
                 startup_directory="urban",
                 wild_card_search=True,
                 show_results_without_query=True,
                 restrict_browsing_to_startup_directory=False,
                 label=_(
                     "urban_label_representative_contacts",
                     default="RepresentativeContact(s)",
                 ),
                 popup_name="contact_reference_popup",
             ),
-            optional=True,
             schemata="urban_description",
             multiValued=1,
             relationship="basebuildlicenceRepresentativeContacts",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Products/urban/content/licence/BaseBuildLicence.py` at line 519, The
field definition for representativeContacts currently sets optional=True
redundantly; remove the explicit optional=True from the representativeContacts
declaration and rely on setOptionalAttributes(schema, optional_fields) to apply
optionality (and the widget condition) so there is a single source of truth;
leave representativeContacts name and type unchanged and ensure optional_fields
includes "representativeContacts" so setOptionalAttributes handles it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/CHANGES.rst`:
- Around line 13-16: Remove the direct entry from docs/CHANGES.rst (the "Add
option to show or hide the representativeContacts field [WBoudabous]
(SUP-51436)" line) and instead create a towncrier news fragment file named
SUP-51436.feature under the news/ directory containing the single line: "Add
option to show or hide the representativeContacts field [WBoudabous]". Ensure
the CHANGES.rst entry is deleted so towncrier can regenerate the changelog from
the new fragment.

---

Nitpick comments:
In `@src/Products/urban/content/licence/BaseBuildLicence.py`:
- Line 519: The field definition for representativeContacts currently sets
optional=True redundantly; remove the explicit optional=True from the
representativeContacts declaration and rely on setOptionalAttributes(schema,
optional_fields) to apply optionality (and the widget condition) so there is a
single source of truth; leave representativeContacts name and type unchanged and
ensure optional_fields includes "representativeContacts" so
setOptionalAttributes handles it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e46637c2-f5c7-4de4-b160-b531ca401156

📥 Commits

Reviewing files that changed from the base of the PR and between 5fabb4d and 8ebe581.

📒 Files selected for processing (2)
  • docs/CHANGES.rst
  • src/Products/urban/content/licence/BaseBuildLicence.py

Comment thread docs/CHANGES.rst Outdated
Comment on lines +13 to +16
New features:

-Add option to show or hide the representativeContacts field
[WBoudabous] (SUP-51436)

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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n docs/CHANGES.rst | head -50

Repository: IMIO/Products.urban

Length of output: 1223


🏁 Script executed:

head -20 docs/CHANGES.rst

Repository: IMIO/Products.urban

Length of output: 515


🏁 Script executed:

find . -type d -name "news*" -o -type d -name "changelog*" 2>/dev/null | head -20

Repository: IMIO/Products.urban

Length of output: 69


🏁 Script executed:

fd -type f -name "pyproject.toml" -o -name "setup.cfg" -o -name "towncrier.toml" | head -5

Repository: IMIO/Products.urban

Length of output: 233


🏁 Script executed:

ls -la news/ | head -20

Repository: IMIO/Products.urban

Length of output: 228


🏁 Script executed:

find . -name "pyproject.toml" -o -name "setup.cfg" -o -name "towncrier.toml" | xargs grep -l "towncrier" 2>/dev/null

Repository: IMIO/Products.urban

Length of output: 79


🏁 Script executed:

cat pyproject.toml | grep -A 20 "towncrier"

Repository: IMIO/Products.urban

Length of output: 646


Entry should not be directly added to docs/CHANGES.rst; create a news fragment instead.

This project uses towncrier for changelog management. Per the instructions in the file, new entries should not be added directly to docs/CHANGES.rst. Instead, create a news fragment file in the news/ directory named something like SUP-51436.feature containing:

Add option to show or hide the representativeContacts field [WBoudabous]

Then towncrier will automatically regenerate the changelog during the next release process. Remove the entry from lines 13-16 of docs/CHANGES.rst.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/CHANGES.rst` around lines 13 - 16, Remove the direct entry from
docs/CHANGES.rst (the "Add option to show or hide the representativeContacts
field [WBoudabous] (SUP-51436)" line) and instead create a towncrier news
fragment file named SUP-51436.feature under the news/ directory containing the
single line: "Add option to show or hide the representativeContacts field
[WBoudabous]". Ensure the CHANGES.rst entry is deleted so towncrier can
regenerate the changelog from the new fragment.

@WBoudabous WBoudabous requested a review from mpeeters April 17, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant