Skip to content

[OSDEV-1411] Django admin: Fix editing of contributor list#418

Merged
VadimKovalenkoSNF merged 4 commits intomainfrom
OSDEV-1411-fix-editing-of-contributor-list
Nov 21, 2024
Merged

[OSDEV-1411] Django admin: Fix editing of contributor list#418
VadimKovalenkoSNF merged 4 commits intomainfrom
OSDEV-1411-fix-editing-of-contributor-list

Conversation

@VadimKovalenkoSNF
Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF commented Nov 19, 2024

Fix OSDEV-1411.

Previously, when a user enters [] (or leaves the field empty), Django Admin interpreted it as "empty input" and failed validation because the field is marked as required.

Update parsing_errors field:

  1. Set blank=True: Updated the model field to allow blank input in forms. This tells Django Admin to treat the field as optional.
  2. Set null=True: This allows the field to have a NULL value in the database if explicitly set to null in the request.

@VadimKovalenkoSNF VadimKovalenkoSNF self-assigned this Nov 19, 2024
@VadimKovalenkoSNF VadimKovalenkoSNF changed the title [OSDEV-1411] Fix editing of contributor list [OSDEV-1411] Django admin: Fix editing of contributor list Nov 19, 2024
@barecheck
Copy link

barecheck bot commented Nov 19, 2024

React App | Jest test suite - Code coverage report

Total: 26.93%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2024

Walkthrough

The pull request introduces updates to the RELEASE-NOTES.md file for version 1.25.0 of the Open Supply Hub project, detailing database changes, new API endpoints, bug fixes, and updated release instructions. Additionally, it includes a migration file that modifies the parsing_errors field in the facilitylist model to be a JSONField that accepts null values. The FacilityList model is also updated to reflect these changes.

Changes

File Path Change Summary
doc/release/RELEASE-NOTES.md Updated for version 1.25.0: added migration details, new API endpoints, bug fixes, and release instructions.
src/django/api/migrations/0160_allow_null_parsing_errors_in_facilitylist.py Introduced a migration to modify parsing_errors to a JSONField that allows null values and has a default of an empty list.
src/django/api/models/facility/facility_list.py Updated parsing_errors field in FacilityList model to accept null values and be left blank.

Possibly related PRs

Suggested reviewers

  • vladsha-dev
  • roman-stolar
  • mazursasha1990

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 30f427b and 40964b8.

📒 Files selected for processing (1)
  • doc/release/RELEASE-NOTES.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • doc/release/RELEASE-NOTES.md

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Outside diff range and nitpick comments (4)
src/django/api/migrations/0160_allow_null_parsing_errors_in_facilitylist.py (2)

3-3: Remove unused import

The django.contrib.postgres.indexes import is not used in this migration.

-import django.contrib.postgres.indexes
🧰 Tools
🪛 Ruff

3-3: django.contrib.postgres.indexes imported but unused

Remove unused import: django.contrib.postgres.indexes

(F401)


3-3: Remove unused import

The django.contrib.postgres.indexes import is not used in this migration.

-import django.contrib.postgres.indexes
🧰 Tools
🪛 Ruff

3-3: django.contrib.postgres.indexes imported but unused

Remove unused import: django.contrib.postgres.indexes

(F401)

src/django/api/models/facility/facility_list.py (1)

89-90: Consider documenting the error structure schema.

Since parsing_errors is a JSONField that can now be null or contain an empty list, it would be helpful to document the expected structure of error entries when they exist. This could help maintain consistency in error reporting across the application.

Consider adding a docstring or documentation that outlines:

  1. The expected JSON schema for error entries
  2. When null vs. empty list should be used
  3. Example error structures for common scenarios
doc/release/RELEASE-NOTES.md (1)

30-30: Consider enhancing the bug fix description

The current description could be more specific about the actual fix implemented. Consider updating it to:

-* [OSDEV-1411](https://opensupplyhub.atlassian.net/browse/OSDEV-1411) - Django admin: fixed issue when update facility list with empty array `Parsing errors` field.
+* [OSDEV-1411](https://opensupplyhub.atlassian.net/browse/OSDEV-1411) - Django admin: fixed validation issue by allowing empty arrays (`[]`) and null values in the `Parsing errors` field by adding `blank=True` and `null=True` attributes.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 39278f7 and 60b63cb.

📒 Files selected for processing (3)
  • doc/release/RELEASE-NOTES.md (1 hunks)
  • src/django/api/migrations/0160_allow_null_parsing_errors_in_facilitylist.py (1 hunks)
  • src/django/api/models/facility/facility_list.py (1 hunks)
🧰 Additional context used
🪛 Ruff
src/django/api/migrations/0160_allow_null_parsing_errors_in_facilitylist.py

3-3: django.contrib.postgres.indexes imported but unused

Remove unused import: django.contrib.postgres.indexes

(F401)

🔇 Additional comments (4)
src/django/api/migrations/0160_allow_null_parsing_errors_in_facilitylist.py (3)

14-18: LGTM! The field modifications address the validation issues.

The changes correctly implement the requirements by:

  1. Adding blank=True to allow empty input in forms
  2. Adding null=True to allow NULL values in database
  3. Including clear help text describing the field's purpose

13-19: Consider data migration needs

Since this migration modifies the parsing_errors field to allow null values, consider whether existing records need data migration (e.g., converting empty lists [] to NULL).


7-11: LGTM!

The migration class is properly defined with correct dependency chain.

src/django/api/models/facility/facility_list.py (1)

89-90: LGTM! The changes correctly address the validation issue.

The addition of null=True and blank=True to the parsing_errors JSONField appropriately resolves the Django Admin validation problem while maintaining backward compatibility.

Let's verify the usage of parsing_errors field in views and serializers:

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

Line range hint 1-1411: LGTM! Well-structured release notes

The release notes follow a consistent format and provide comprehensive documentation of changes across releases. The organization into clear sections (database changes, code changes, architecture changes, bug fixes, new features) makes it easy to track and understand the evolution of the project.

@VadimKovalenkoSNF VadimKovalenkoSNF force-pushed the OSDEV-1411-fix-editing-of-contributor-list branch from 60b63cb to 809c2f4 Compare November 19, 2024 10:34
Copy link
Contributor

@vladsha-dev vladsha-dev 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

Copy link
Contributor

@roman-stolar roman-stolar left a comment

Choose a reason for hiding this comment

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

LGTM

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