Skip to content

Commit

Permalink
Improve before_create function
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Jun 7, 2024
1 parent 919bbe8 commit 5f4cbb1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions ckanext/validation/plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,15 @@ def _process_schema_fields(self, data_dict):

return data_dict

if ckan_2_10:
def before_resource_create(self, context, data_dict):
def before_resource_create(self, context, data_dict):

context["_resource_create_call"] = True
return self._process_schema_fields(data_dict)
context["_resource_create_call"] = True
return self._process_schema_fields(data_dict)

else:
def before_create(self, context, data_dict):
def before_create(self, context, data_dict):

is_dataset = self._data_dict_is_dataset(data_dict)
if not is_dataset:
context["_resource_create_call"] = True
return self._process_schema_fields(data_dict)
if not self._data_dict_is_dataset(data_dict):
return self.before_resource_create(context, data_dict)

def after_create(self, context, data_dict):

Expand Down

0 comments on commit 5f4cbb1

Please sign in to comment.