Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check schema name/version if no catalog #2970

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Organization can nom define a custom metadata of a choosen type
- Dataset belonging to the organization can assign a value to the defined metadata
- Metadata value must match the choosen type by the organization
- Harvest DCAT conformsTo into schemas for resources and datasets
- Harvest DCAT conformsTo into schemas for resources and datasets[#2949](https://github.com/opendatateam/udata/pull/2949) [#2970](https://github.com/opendatateam/udata/pull/2970)
- Better reporting in spam detection (show the writer of the discussion/message) [#2965](https://github.com/opendatateam/udata/pull/2965)
- Fix: spam lang detection not lowering input resulting in false positives [#2965](https://github.com/opendatateam/udata/pull/2965)
- Fix: do not send mail about discussions when there is no owner / no organisation members [#2962](https://github.com/opendatateam/udata/pull/2962)
Expand Down
10 changes: 9 additions & 1 deletion udata/core/dataset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,21 @@ def clean(self):
# Nothing more to do since an URL can point to anywhere and have a random name/version
return

# All the following checks are only run if there is
# some schemas in the catalog. If there is no catalog
# or no schema in the catalog we do not check the validity
# of the name and version
catalog_schemas = ResourceSchema.all()
if not catalog_schemas:
return

# We know this schema so we can do some checks
existing_schema = ResourceSchema.get_schema_by_name(self.name)
if not existing_schema:
message = _('Schema name "{schema}" is not an allowed value. Allowed values: {values}')
raise FieldValidationError(message.format(
schema=self.name,
values=', '.join(map(lambda schema: schema['name'], ResourceSchema.all()))
values=', '.join(map(lambda schema: schema['name'], catalog_schemas))
), field='name')

if self.version:
Expand Down