forked from PnX-SI/GeoNature
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import): dynamic form on default values
- Loading branch information
Showing
10 changed files
with
179 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../geonature/migrations/versions/imports/a94bea44ab56_type_field_conforms_to_type_widget.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""bib_field.type_field conforms to dynamic_form.type_widget | ||
Revision ID: a94bea44ab56 | ||
Revises: e43b01a18850 | ||
Create Date: 2024-12-11 15:44:52.912515 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a94bea44ab56" | ||
down_revision = "e43b01a18850" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
""" | ||
ALTER TABLE gn_imports.bib_fields ADD type_field_params jsonb NULL; | ||
""" | ||
) | ||
op.execute( | ||
""" | ||
UPDATE gn_imports.bib_fields | ||
SET type_field = | ||
case | ||
-- mnemonique is handled front side | ||
WHEN mnemonique IS NOT NULL AND mnemonique != '' THEN NULL | ||
-- multi is handled front side | ||
WHEN multi = true THEN null | ||
WHEN type_field IN ('integer', 'real') THEN 'number' | ||
WHEN type_field IN ('geometry', 'jsonb', 'json', 'wkt') THEN 'textarea' | ||
WHEN type_field LIKE 'timestamp%' THEN 'date' | ||
WHEN type_field ~ '^character varying\((\d+)\)$' | ||
AND COALESCE(substring(type_field FROM '\d+')::int, 0) > 68 THEN 'textarea' | ||
-- Default: garder la valeur actuelle. | ||
ELSE NULL | ||
END; | ||
""" | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
""" | ||
ALTER TABLE gn_imports.bib_fields DROP COLUMN type_field_params; | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.