Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Custom Columns using JSONFields #82

Open
mjducut-oe wants to merge 27 commits into
mainfrom
feat/custom-field-column
Open

Custom Columns using JSONFields #82
mjducut-oe wants to merge 27 commits into
mainfrom
feat/custom-field-column

Conversation

@mjducut-oe

Copy link
Copy Markdown
Collaborator

No description provided.

@mjducut-oe mjducut-oe requested a review from Yacobolo October 31, 2023 03:55
@mjducut-oe

mjducut-oe commented Nov 3, 2023

Copy link
Copy Markdown
Collaborator Author

#@Yacobolo, please see the changes below 😄:

CustomField Model

The CustomField model now contains:

  • field_name: The name of the custom field.
  • field_type: The type of the custom field with predefined choices.
  • related_model: The model to which the custom field is related, validated by validate_related_model.

Validations

  • The related_model field accepts only the names of existing models within the 'api' app. If a non-existent model name is provided, the system will return a validation error. Example for existing models are Item, Job, Task, etc.

  • The field_type is restricted to a set of predefined options. The valid field_type keys are:

    • text
    • number
    • date
    • boolean
    • datetime
    • time

Handling Migrations and Tests

  • To ensure that the custom field functionality is compatible with Django's migration framework and testing suite, a special provision is made. During migrations and test runs, querying the database for custom fields is not ideal because the database may be in an inconsistent state or may not be available.

  • To address this, when migrations or tests are detected (via checking environment variables or the migration state), the system does not attempt to query the database for custom fields. Instead, it returns a default Pydantic schema. This approach prevents potential errors during database operations like migrations and tests and allows the rest of the system to function without the need for a complete database schema in place.

Post-Merge Instructions

Update Local Repository:
Please ensure you pull/rebase the latest changes from the main branch after this PR is merged.

Reinstall Dependencies:
A couple of new modules have been introduced. Reinstall the backend requirements using the following command:

pip install -r requirements.txt

Newly added modules:

pytest-env==1.1.1
python-dotenv==1.0.0

Upgraded modules:
pytest==7.4.2 to pytest==7.4.3 for compatibility.

Please review the changes and provide your approval or request modifications. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant