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

Display warning when creating dataset without organizations #3054

Conversation

k-nut
Copy link
Contributor

@k-nut k-nut commented May 25, 2016

Fixes #3046, #2767

Proposed fixes:

As discussed in #3046 already this now checks if there are organizations to which the dataset can be added or not. If there are non it checks if the user is allowed to create on or not and depending on the answer provides them with a link.

The tests are failing right now unfortunately. When either one of them is commented out they both pass but the first one fails when run together. Any idea what this could be? Also I feel bad for having to introduce patch in those tests again, maybe there is a better way to do it?

Features:

  • includes tests covering changes
  • includes updated documentation
  • includes user-visible changes
  • includes API changes
  • includes bugfix for possible backport

@amercader amercader self-assigned this May 26, 2016
@@ -27,7 +27,7 @@ def owner_org_validator(key, data, errors, context):

if value is missing or value is None:
if not authz.check_config_permission('create_unowned_dataset'):
raise Invalid(_('A organization must be supplied'))
raise Invalid(_('An organization must be provided'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break a bunch of existing translations. Just flagging it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is something that I though about to. But there is no way to avoid it, is there?

@k-nut k-nut force-pushed the 3046-display-warning-when-creating-dataset-without-organizations branch from 6a29f20 to ff93ffb Compare June 6, 2016 13:14
@k-nut
Copy link
Contributor Author

k-nut commented Jun 7, 2016

@amercader The problem with the tests that make each other fail is now fixed.

I documented the reasoning for this rather uncommon patching / cache invalidation in the code so that future readers understand what is going on and so that we have a "complex" tests that we could potentially copy from in the future if similar things come up.

@k-nut
Copy link
Contributor Author

k-nut commented Jun 7, 2016

I'll make this into a decorator.

@k-nut
Copy link
Contributor Author

k-nut commented Jun 7, 2016

@wardi see 71ee7c1 where I created a new helpers.mock_auth function similar to the existing mock_action method. This works as a decorator and replaces the setup and teardown at begging and end of the test itself.

@amercader amercader merged commit 8a38230 into ckan:master Jun 14, 2016
@amercader
Copy link
Member

Great stuff @k-nut, love mock_auth 👍

@k-nut k-nut deleted the 3046-display-warning-when-creating-dataset-without-organizations branch June 14, 2016 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creation of datasets/harvest sources with no organization specified
4 participants