Skip to content

[OSDEV-2199] [Climate TRACE] Display partner field "label" and "unit" in Production Location Page#807

Merged
roman-stolar merged 14 commits intoOSDEV-2185-display-source-byfrom
OSDEV-2199-display-label-unit-partner-field
Nov 12, 2025
Merged

[OSDEV-2199] [Climate TRACE] Display partner field "label" and "unit" in Production Location Page#807
roman-stolar merged 14 commits intoOSDEV-2185-display-source-byfrom
OSDEV-2199-display-label-unit-partner-field

Conversation

@roman-stolar
Copy link
Contributor

@roman-stolar roman-stolar commented Nov 10, 2025

OSDEV-2199 [Climate TRACE] Display partner field "label" and "unit" in Production Location Page

  • Added unit and label metadata from PartnerField to the serialized partner fields payload.
  • Production Location detail pages now render the unit inline with field values and display custom partner field label.
Screenshot 2025-11-11 at 11 13 17

Depend on -> #792

@roman-stolar roman-stolar self-assigned this Nov 10, 2025
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:53 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 11:56 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Nov 10, 2025

React App | Jest test suite - Code coverage report

Total: 37.18%

Your code coverage diff: 0.09% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Nov 10, 2025

Countries App | Unittest test suite - Code coverage report

Total: 100%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Nov 10, 2025

Contricleaner App | Unittest test suite - Code coverage report

Total: 98.75%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 12:08 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Nov 10, 2025

Dedupe Hub App | Unittest test suite - Code coverage report

Total: 55.73%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@roman-stolar roman-stolar temporarily deployed to Quality Environment November 10, 2025 12:18 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Nov 10, 2025

Django App | Unittest test suite - Code coverage report

Total: 81.51%

Your code coverage diff: 0.01% ▴

✅ All code changes are covered

@roman-stolar roman-stolar temporarily deployed to Quality Environment November 11, 2025 08:46 — with GitHub Actions Inactive
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

📝 Walkthrough

Walkthrough

This PR extends the PartnerField model with a new RichTextField source_by field for documenting data sources, integrates CKEditor into the admin interface, updates cache key naming from PARTNER_FIELD_NAMES_LIST_KEY to PARTNER_FIELD_LIST_KEY, refactors serializers to propagate PartnerField objects instead of field names, and updates React components to render source_by and unit information.

Changes

Cohort / File(s) Summary
Database & Model Layer
src/django/api/migrations/0185_add_source_by_to_partner_field.py, src/django/api/models/partner_field.py
Adds new RichTextField source_by to PartnerField model with blank/null options and CKEditor config. Updates cache invalidation to use renamed constant PARTNER_FIELD_LIST_KEY.
Admin Interface & Configuration
src/django/api/admin.py
Introduces PartnerFieldAdminForm using CKEditorWidget for source_by field; adds source_by to PartnerFieldAdmin.list_display and search_fields.
Constants & Cache Management
src/django/api/constants.py
Renames public constant PARTNER_FIELD_NAMES_LIST_KEY to PARTNER_FIELD_LIST_KEY with value update from 'partner_field_names_list' to 'partner_field_list'.
Backend Serializers
src/django/api/serializers/facility/facility_index_extended_field_list_serializer.py
Adds source_by, unit, and label to public field list; introduces field_serializers dispatch and context_overrides for per-field serialization.
Serializer Refactoring
src/django/api/serializers/facility/facility_index_serializer.py
Renames __get_partner_field_names() to __get_partner_fields() and refactors to fetch PartnerField objects instead of field names. Updates __serialize_and_sort_partner_fields to extract and propagate source_by, unit, label properties into serializer context.
Django Configuration & Dependencies
src/django/oar/settings.py, src/django/requirements.txt
Adds django-ckeditor==6.5.1 dependency. Configures CKEDITOR_CONFIGS with default toolbar settings; adds INSTALLED_APPS entry for 'ckeditor'. Adds configuration constants for attachments, caching, and API key validation.
Backend Tests
src/django/api/tests/test_facility_index_serializer.py
Adds new tests validating serialization of source_by, unit, and label fields in FacilityIndexSerializer output.
Frontend Components
src/react/src/components/FacilityDetailsDetail.jsx
Adds sourceBy and unit props; renders unit inline with primary text and sourceBy content via dangerouslySetInnerHTML with new sourceText and unitText styles.
Frontend Component Updates
src/react/src/components/FacilityDetailsGeneralFields.jsx, src/react/src/components/FacilityDetailsItem.jsx, src/react/src/components/FacilityDetailsLocationFields.jsx
FacilityDetailsGeneralFields: updates partner field label to use topValue.label. FacilityDetailsItem: threads sourceBy and unit props to FacilityDetailsDetail. FacilityDetailsLocationFields: reorders address label prop for precedence.
Frontend Utilities
src/react/src/util/util.js
Extends formatExtendedField to accept and return source_by, unit, and label (as sourceBy) in addition to existing fields.
Frontend Tests
src/react/src/__tests__/components/FacilityDetailsDetail.test.js, src/react/src/__tests__/components/FacilityDetailsGeneralFields.test.js
Adds tests for sourceBy HTML rendering (with raw HTML and links), unit display inline and fallback behavior, and partner field label display with fallback.
Documentation
doc/release/RELEASE-NOTES.md
Documents new migration 0185_add_source_by_to_partner_field.py in Release 2.16.0 database changes section.

Sequence Diagram(s)

sequenceDiagram
    participant DB as Database
    participant FS as FacilityIndexSerializer
    participant EC as ExtendedFieldListSerializer
    participant FD as FacilityDetailsDetail
    participant Client as React Client

    DB->>FS: Query PartnerField objects with source_by, unit, label
    FS->>FS: Build context: {source_by, unit, label} from PartnerField
    FS->>EC: Pass partner_fields list + context overrides
    EC->>EC: Map fields to serializers or context values
    EC->>FS: Return serialized partner fields
    FS->>Client: Send JSON with sourceBy, unit, label
    Client->>FD: Render with sourceBy (HTML), unit text
    FD->>FD: Render sourceBy via dangerouslySetInnerHTML
    FD->>FD: Render unit inline with primary value
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Specific areas requiring attention:
    • Serializer refactoring in facility_index_serializer.py: Logic change from field names to PartnerField objects requires verification of object attribute access and cache handling
    • Cache key renaming across constants.py, partner_field.py, and facility_index_serializer.py: Ensure all references updated consistently
    • Frontend HTML rendering via dangerouslySetInnerHTML in FacilityDetailsDetail.jsx: Confirm XSS mitigation strategy (CKEditor sanitization assumption)
    • Context propagation through serializers: Verify source_by, unit, label flow from model through both serializers to frontend

Possibly related PRs

  • PR #737: Introduced PartnerField model and contributor relations; this PR extends that model with source_by field and refactors serializer usage patterns accordingly.
  • PR #765: Prior partner field handling changes across backend and frontend; this PR extends those patterns with CKEditor integration and field property propagation.
  • PR #757: Previous PartnerField model and admin configuration changes; this PR adds complementary source_by field and admin visibility updates following the same pattern.

Suggested reviewers

  • protsack-stephan
  • vlad-shapik
  • VadimKovalenkoSNF

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main objective: displaying partner field 'label' and 'unit' in the Production Location Page, which aligns with the core changes across Django models, serializers, and React components.
Description check ✅ Passed The PR description clearly relates to the changeset by explaining the addition of 'unit' and 'label' metadata from PartnerField and how they are rendered on Production Location detail pages, matching the changes made.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch OSDEV-2199-display-label-unit-partner-field

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bffe5d2 and 729854d.

📒 Files selected for processing (1)
  • src/django/api/migrations/0185_add_source_by_to_partner_field.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.14.4)
src/django/api/migrations/0185_add_source_by_to_partner_field.py

9-11: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


13-19: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: run-django-code-quality
  • GitHub Check: get-base-branch-countries-cov
  • GitHub Check: get-base-branch-dd-cov
  • GitHub Check: run-eslint-linter-and-prettier-formatter
  • GitHub Check: run-countries-code-quality
  • GitHub Check: run-fe-code-quality
  • GitHub Check: get-base-branch-fe-cov
🔇 Additional comments (1)
src/django/api/migrations/0185_add_source_by_to_partner_field.py (1)

1-20: Migration is correct and properly configured.

This Django migration correctly adds a CKEditor RichTextField to the PartnerField model. Verification confirms that:

  • django-ckeditor is properly listed in the project's requirements
  • CKEDITOR_CONFIGS is defined in the project settings
  • The migration correctly references the 'default' config

The nullable field configuration (blank=True, null=True) is appropriate for adding a new field to an existing model.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

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 (5)
src/react/src/components/FacilityDetailsGeneralFields.jsx (2)

151-159: Use fieldName in React key to avoid collisions.

If two partner fields share the same display label, keys collide. Prefer fieldName for uniqueness.

Apply:

-            <Grid item xs={12} md={6} key={`partner-${label}`}>
+            <Grid item xs={12} md={6} key={`partner-${fieldName}`}>

231-233: Hardcoded "Name" label — consider i18n.

If localization is planned, route this through your i18n/strings source.

Confirm whether this should use a translated string.

doc/release/RELEASE-NOTES.md (2)

6-26: Add static assets note for CKEditor.

Since django-ckeditor assets are new, confirm your deploy runs collectstatic or otherwise ships static files.

Does your pipeline already run collectstatic for Django static apps?


21-25: Fix markdown list indentation (MD007).

Indent sub-bullets by two spaces to satisfy markdownlint.

Apply:

-    * `migrate`
-    * `reindex_database`
+  * `migrate`
+  * `reindex_database`
src/django/oar/settings.py (1)

505-521: Tighten CKEditor toolbar (remove "Source").

Exposing Source increases risk of unsafe markup. Since rendering uses dangerouslySetInnerHTML, prefer removing it unless strictly needed.

Apply:

-            ['RemoveFormat', 'Source'],
+            ['RemoveFormat'],

Server-side sanitization is expected; confirm bleach cleaning is applied for PartnerField.source_by.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 639fc1f and 0d01b27.

📒 Files selected for processing (17)
  • doc/release/RELEASE-NOTES.md (1 hunks)
  • src/django/api/admin.py (3 hunks)
  • src/django/api/constants.py (1 hunks)
  • src/django/api/migrations/0184_add_source_by_to_partner_field.py (1 hunks)
  • src/django/api/models/partner_field.py (3 hunks)
  • src/django/api/serializers/facility/facility_index_extended_field_list_serializer.py (2 hunks)
  • src/django/api/serializers/facility/facility_index_serializer.py (5 hunks)
  • src/django/api/tests/test_facility_index_serializer.py (1 hunks)
  • src/django/oar/settings.py (2 hunks)
  • src/django/requirements.txt (1 hunks)
  • src/react/src/__tests__/components/FacilityDetailsDetail.test.js (1 hunks)
  • src/react/src/__tests__/components/FacilityDetailsGeneralFields.test.js (1 hunks)
  • src/react/src/components/FacilityDetailsDetail.jsx (3 hunks)
  • src/react/src/components/FacilityDetailsGeneralFields.jsx (2 hunks)
  • src/react/src/components/FacilityDetailsItem.jsx (3 hunks)
  • src/react/src/components/FacilityDetailsLocationFields.jsx (1 hunks)
  • src/react/src/util/util.js (2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2024-12-03T10:29:02.409Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 436
File: src/react/src/components/DialogTooltip.jsx:0-0
Timestamp: 2024-12-03T10:29:02.409Z
Learning: In the `DialogTooltip` component (`src/react/src/components/DialogTooltip.jsx`), there are existing tooltip tests that cover common cases, and further detailed tests are not necessary.

Applied to files:

  • src/react/src/__tests__/components/FacilityDetailsDetail.test.js
📚 Learning: 2025-01-17T16:12:18.285Z
Learnt from: Innavin369
Repo: opensupplyhub/open-supply-hub PR: 483
File: src/react/src/__tests__/components/SearchByNameAndAddressSuccessResult.test.js:0-0
Timestamp: 2025-01-17T16:12:18.285Z
Learning: In the SearchByNameAndAddressSuccessResult component's tests, attempting to test internal navigation logic through mocking useHistory is not feasible, and button presence/click events should be covered in the main rendering test case.

Applied to files:

  • src/react/src/__tests__/components/FacilityDetailsDetail.test.js
  • src/react/src/__tests__/components/FacilityDetailsGeneralFields.test.js
📚 Learning: 2025-06-02T13:24:57.659Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 641
File: doc/release/RELEASE-NOTES.md:6-35
Timestamp: 2025-06-02T13:24:57.659Z
Learning: The Open Supply Hub team keeps placeholders in release notes until code freeze, then fills in the actual content once all changes are finalized for the release.

Applied to files:

  • doc/release/RELEASE-NOTES.md
📚 Learning: 2024-12-10T07:09:35.641Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 436
File: src/react/src/components/Contribute/ProductionLocationDialog.jsx:33-181
Timestamp: 2024-12-10T07:09:35.641Z
Learning: In the `ProductionLocationDialog.jsx` component, hardcoded facility data is acceptable for now as per the project's requirements.

Applied to files:

  • src/react/src/components/FacilityDetailsGeneralFields.jsx
  • src/react/src/components/FacilityDetailsItem.jsx
  • src/react/src/components/FacilityDetailsDetail.jsx
  • src/react/src/components/FacilityDetailsLocationFields.jsx
📚 Learning: 2024-12-05T10:43:59.922Z
Learnt from: Innavin369
Repo: opensupplyhub/open-supply-hub PR: 437
File: src/react/src/components/Filters/StyledSelect.jsx:31-39
Timestamp: 2024-12-05T10:43:59.922Z
Learning: In the `StyledSelect` component (`src/react/src/components/Filters/StyledSelect.jsx`), the `label` prop is optional. The `InputLabel` should be conditionally rendered only when a label is provided to prevent unnecessary DOM elements, extra padding, and browser console warnings.

Applied to files:

  • src/react/src/components/FacilityDetailsGeneralFields.jsx
  • src/react/src/components/FacilityDetailsDetail.jsx
  • src/react/src/components/FacilityDetailsLocationFields.jsx
📚 Learning: 2024-11-28T11:29:28.139Z
Learnt from: Innavin369
Repo: opensupplyhub/open-supply-hub PR: 431
File: src/django/api/serializers/v1/opensearch_common_validators/countries_validator.py:23-24
Timestamp: 2024-11-28T11:29:28.139Z
Learning: The files `src/django/api/tests/test_facility_claim_view_set.py`, `src/django/api/views/facility/facilities_view_set.py`, and `src/django/api/facility_actions/processing_facility_api.py` are not part of the V1 codebase in the Open Supply Hub project.

Applied to files:

  • src/django/api/tests/test_facility_index_serializer.py
📚 Learning: 2024-12-10T15:07:54.819Z
Learnt from: roman-stolar
Repo: opensupplyhub/open-supply-hub PR: 448
File: src/react/src/util/util.js:1317-1317
Timestamp: 2024-12-10T15:07:54.819Z
Learning: Changes to date handling functions like `formatDate` in `src/react/src/util/util.js` should be made carefully, considering that different parts of the codebase may intentionally use local time instead of UTC, and broad changes to `moment()` usage may not be appropriate without context.

Applied to files:

  • src/react/src/components/FacilityDetailsDetail.jsx
  • src/react/src/util/util.js
📚 Learning: 2024-12-10T09:00:29.628Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 436
File: src/react/src/util/styles.js:567-571
Timestamp: 2024-12-10T09:00:29.628Z
Learning: In the Open Supply Hub project, when defining font sizes in styles (e.g., in `src/react/src/util/styles.js`), prefer using `px` units directly rather than using `theme.typography.pxToRem()` function, as `px` units are used consistently throughout the project.

Applied to files:

  • src/react/src/components/FacilityDetailsDetail.jsx
📚 Learning: 2025-02-12T11:45:01.562Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 511
File: src/react/src/util/util.js:1436-1447
Timestamp: 2025-02-12T11:45:01.562Z
Learning: The `generateRangeField` utility function in `src/react/src/util/util.js` is meant for data transformation only. Input validation is handled separately on the frontend for specific input fields.

Applied to files:

  • src/react/src/util/util.js
📚 Learning: 2025-01-29T09:00:01.638Z
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 470
File: src/react/src/util/util.js:1441-1472
Timestamp: 2025-01-29T09:00:01.638Z
Learning: The data passed to parseContribData() function in src/react/src/util/util.js is pre-parsed and validated before reaching the function, so additional type checking is not required.

Applied to files:

  • src/react/src/util/util.js
🧬 Code graph analysis (6)
src/react/src/__tests__/components/FacilityDetailsDetail.test.js (1)
src/react/src/components/FacilityDetailsDetail.jsx (1)
  • FacilityDetailsDetail (60-104)
src/django/api/admin.py (1)
src/django/api/models/partner_field.py (2)
  • Meta (24-25)
  • PartnerField (8-76)
src/django/api/tests/test_facility_index_serializer.py (3)
src/django/api/models/partner_field.py (1)
  • save (69-71)
src/django/api/models/extended_field.py (1)
  • ExtendedField (7-111)
src/django/api/serializers/facility/facility_index_serializer.py (1)
  • FacilityIndexSerializer (47-570)
src/react/src/components/FacilityDetailsDetail.jsx (1)
src/react/src/util/util.js (1)
  • primary (1791-1791)
src/django/api/serializers/facility/facility_index_extended_field_list_serializer.py (1)
src/react/src/util/util.js (1)
  • fields (1618-1618)
src/django/api/serializers/facility/facility_index_serializer.py (1)
src/django/api/models/partner_field.py (1)
  • PartnerField (8-76)
🪛 Biome (2.1.2)
src/react/src/components/FacilityDetailsDetail.jsx

[error] 94-94: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

🪛 markdownlint-cli2 (0.18.1)
doc/release/RELEASE-NOTES.md

23-23: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


24-24: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)

🪛 Ruff (0.14.4)
src/django/api/migrations/0184_add_source_by_to_partner_field.py

9-11: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


13-19: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

src/django/api/admin.py

255-255: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: get-base-branch-dd-cov
  • GitHub Check: run-countries-code-quality
  • GitHub Check: run-eslint-linter-and-prettier-formatter
  • GitHub Check: run-integration-test-code-quality
  • GitHub Check: get-base-branch-contricleaner-cov
  • GitHub Check: run-django-code-quality
  • GitHub Check: run-flake8-linter
  • GitHub Check: run-dd-code-quality
  • GitHub Check: get-base-branch-fe-cov
  • GitHub Check: run-fe-code-quality
  • GitHub Check: get-base-branch-django-cov
🔇 Additional comments (8)
src/react/src/components/FacilityDetailsLocationFields.jsx (1)

75-85: Label precedence correctly ensures "Address" displays for the primary field while preserving partner field labels.

The change places label="Address" after {...addressField} to ensure the primary address always displays "Address" as its label. Partner address fields in otherAddresses are rendered separately in the drawer (line 109 of FacilityDetailsItem.jsx: <FacilityDetailsDetail {...item} />), preserving their custom labels through prop spreading.

src/react/src/components/FacilityDetailsGeneralFields.jsx (1)

154-156: Partner label fallback LGTM.

Using topValue.label with a fallback is correct and matches UX.

src/react/src/__tests__/components/FacilityDetailsGeneralFields.test.js (1)

315-376: Tests cover label override and fallback well.

Good coverage for partner field label behavior. No changes requested.

src/django/oar/settings.py (1)

138-139: Enable CKEditor app — OK.

App registration looks correct and matches requirements.

Confirm no need for ckeditor_uploader (uploads are disabled in config).

src/django/requirements.txt (1)

21-21: Add django-ckeditor — OK.

Pinned version aligns with Django 3.2 usage.

src/django/api/migrations/0184_add_source_by_to_partner_field.py (1)

13-19: Migration for PartnerField.source_by — OK.

Field type and options look correct; aligns with CKEditor default config.

src/django/api/constants.py (1)

302-302: Constant rename verification complete — no issues found.

The codebase contains no stale references to PARTNER_FIELD_NAMES_LIST_KEY. The new constant PARTNER_FIELD_LIST_KEY is properly defined at line 302 in src/django/api/constants.py and correctly imported and used in all locations: facility_index_serializer.py and partner_field.py.

src/react/src/__tests__/components/FacilityDetailsDetail.test.js (1)

50-166: Sanitization not applied to sourceBy—XSS vulnerability.

Backend sends source_by (RichTextField in PartnerField) unsanitized through the API. Frontend renders it with dangerouslySetInnerHTML, creating an HTML injection vulnerability. Although django_bleach is available in the codebase, it's not applied to this field.

Convert PartnerField.source_by to BleachField or sanitize in the serializer before response.

⛔ Skipped due to learnings
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 391
File: src/django/api/views/v1/opensearch_query_builder/opensearch_query_director.py:25-31
Timestamp: 2024-11-13T07:17:11.796Z
Learning: In the Open Supply Hub project, query parameters used in OpenSearch queries are properly sanitized in related serializers and validators, ensuring protection against injection attacks.
Learnt from: VadimKovalenkoSNF
Repo: opensupplyhub/open-supply-hub PR: 436
File: src/react/src/components/DialogTooltip.jsx:0-0
Timestamp: 2024-12-03T10:29:02.409Z
Learning: In the `DialogTooltip` component (`src/react/src/components/DialogTooltip.jsx`), there are existing tooltip tests that cover common cases, and further detailed tests are not necessary.
Learnt from: Innavin369
Repo: opensupplyhub/open-supply-hub PR: 483
File: src/react/src/__tests__/components/SearchByNameAndAddressSuccessResult.test.js:0-0
Timestamp: 2025-01-17T16:12:18.285Z
Learning: In the SearchByNameAndAddressSuccessResult component's tests, attempting to test internal navigation logic through mocking useHistory is not feasible, and button presence/click events should be covered in the main rendering test case.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d01b27 and 20f9510.

📒 Files selected for processing (1)
  • src/django/api/serializers/facility/facility_index_extended_field_list_serializer.py (2 hunks)
🔇 Additional comments (2)
src/django/api/serializers/facility/facility_index_extended_field_list_serializer.py (2)

21-22: LGTM: New fields added correctly.

The additions of source_by, unit, and label align with the PR objectives to display PartnerField metadata in the serialized output.


32-40: Excellent refactoring to dispatch table.

The refactoring from explicit conditionals to a field_serializers dispatch table significantly improves code maintainability. The separation between dedicated serializers and context-driven overrides is clear and logical.

Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF left a comment

Choose a reason for hiding this comment

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

Pls, apply minor fix for tests.

Copy link
Contributor

@vlad-shapik vlad-shapik left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

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.

3 participants