Skip to content

Commit

Permalink
[ckan#8308] empty resource add another error
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Oct 25, 2024
1 parent fe22f07 commit 5e3e86c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions ckan/tests/controllers/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def test_first_page_creates_draft_package(self, app, user):

def test_resource_required(self, app, user):
url = url_for("dataset.new")
name = "one-resource-required"
env = {"Authorization": user["token"]}
response = app.post(url, extra_environ=env, data={
name = "resource-data-required"
headers = {"Authorization": user["token"]}
response = app.post(url, headers=headers, data={
"name": name,
"save": "",
"_ckan_phase": 1
Expand All @@ -153,9 +153,9 @@ def test_resource_required(self, app, user):
response = app.post(location, extra_environ=env, data={
"id": "",
"url": "",
"save": "go-metadata",
"save": "again",
})
assert "You must add at least one data resource" in response
assert "No resource data entered" in response

def test_complete_package_with_one_resource(self, app, user):
url = url_for("dataset.new")
Expand Down
8 changes: 6 additions & 2 deletions ckan/views/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,12 @@ def post(self, package_type: str, id: str) -> Union[str, Response]:
data_provided = True
break

if not data_provided and save_action != u"go-dataset-complete":
if save_action == u'go-dataset':
if not data_provided and save_action != "go-dataset-complete":
if save_action == 'again':
errors: dict[str, Any] = {}
error_summary = {_('Error'): _('No resource data entered')}
return self.get(package_type, id, data, errors, error_summary)
if save_action == 'go-dataset':
# go to final stage of adddataset
return h.redirect_to(u'{}.edit'.format(package_type), id=id)
try:
Expand Down

0 comments on commit 5e3e86c

Please sign in to comment.