Skip to content

Commit

Permalink
[#4382] strip full URL before saving to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Aug 3, 2018
1 parent 7aa42d2 commit 110e43d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ckan/lib/dictization/model_save.py
Expand Up @@ -13,7 +13,9 @@

log = logging.getLogger(__name__)


def resource_dict_save(res_dict, context):

model = context["model"]
session = context["session"]

Expand All @@ -30,6 +32,11 @@ def resource_dict_save(res_dict, context):
table = class_mapper(model.Resource).mapped_table
fields = [field.name for field in table.c]

# Strip the full url for resources of type 'upload'
if res_dict.get('url_type') == u'upload':
url = res_dict.get('url')
res_dict[u'url'] = url[url.rfind(u"/")+1:]

# Resource extras not submitted will be removed from the existing extras
# dict
new_extras = {}
Expand Down

0 comments on commit 110e43d

Please sign in to comment.