Skip to content

Commit

Permalink
ref: introduce before_resource_create
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 25, 2024
1 parent 739b2f7 commit a975de4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions ckanext/dcor_schemas/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,8 @@ def get_user_dataset_labels(self, user_obj):
return labels

# IResourceController
def after_resource_create(self, context, resource):
"""Add custom jobs"""
# Make sure the resource has a mimetype if possible. This is a
# workaround for data uploaded via S3.
# TODO: Does it make more sense to put this in a different method
# of IResourceController?
def before_resource_create(self, context, resource):
"""Ran before creating the resource; changes will be in package dict"""
res_data_dict = {
"last_modified": datetime.datetime.now(datetime.timezone.utc)
}
Expand All @@ -427,12 +423,12 @@ def after_resource_create(self, context, resource):
res_data_dict["url"] = meta_url

resource.update(res_data_dict)
# Make sure the jobs have an updated version of the resource
jobs.patch_resource_noauth(
package_id=resource["package_id"],
resource_id=resource["id"],
data_dict=res_data_dict)


def after_resource_create(self, context, resource):
"""Add custom jobs"""
# Make sure the resource has a mimetype if possible. This is a
# workaround for data uploaded via S3.
depends_on = []
extensions = [common.config.get("ckan.plugins")]

Expand Down

0 comments on commit a975de4

Please sign in to comment.