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

3022 IDatasetForm fixes #233

Closed
wants to merge 23 commits into from
Closed

3022 IDatasetForm fixes #233

wants to merge 23 commits into from

Conversation

amercader
Copy link
Member

This pull request adds fixes and new functionality to properly support dataset types on 2.0.

Some highlights:

  • Packages have now a default 'dataset' type (up until now it was None). This makes much easier searching (see below), but I'm happy to discuss any implication I haven't think of.
  • On the search page (/dataset) only normal datasets are shown by default. This can be changed via a config option to show all dataset types. When visiting a particular type search page (/my-dataset-type), only datasets of this type are returned.
  • When registering a package type, all urls are named type_action (eg my-type_new, my-type_edit, ...) to allow generating the urls from extensions, etc. as a call to url_for with control, action etc did not generate a url for a non deafult type
  • facet_list template and the helper functions it uses have been modified to allow passing an alternative_url, otherwise the default url (/dataset) was always generated. (@tobes and @johnmartin let me know if you are happy with changes to facet_list.html and helpers)

As reference, this branch of ckanext-harvest is using these changes to handle dataset types for harvest sources, and has custom templates, etc:

https://github.com/okfn/ckanext-harvest/tree/2.0-dataset-sources

Routes have the form `dataset-type_action`, eg `harvest_source_read` or
`mydatasettype_edit`. This allows to build the url with url_for or
nav_named_link from the controllers or templates.
When visiting the search page of a custom dataset type (eg /<my-type>),
only datasets from this type are shown. On the main search page
(/dataset), only standard datasets are shown, unless the config option
`ckan.search.show_all_types` is set to True.
This allows custom URLs like the ones from dataset types. Private
function _url_with_params was duplicated on helpers.
This allows the Pager to generate URLs that point to the relevant
dataset type page, and not /dataset.
This allows dataset type pages to show their own facets and have links
pointing to the right direction.
@@ -273,7 +273,8 @@ def package_dictize(pkg, context):
result_dict['isopen'] = pkg.isopen if isinstance(pkg.isopen,bool) else pkg.isopen()

# type
result_dict['type']= pkg.type
# if null assign the default value to make searching easier
result_dict['type']= pkg.type if pkg.type else u'dataset'
Copy link
Contributor

Choose a reason for hiding this comment

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

how about this result_dict['type'] = pkg.type or u'dataset'

@tobes
Copy link
Contributor

tobes commented Jan 7, 2013

Apart from the minor fixes this looks good to me. Thanks for removing that duplicate code in lib/helpers.

I'll merge if you make the changes or tell me why they are a bad idea ;p

else:
# Unless changed via config options, don't show non standard
# dataset types on the default search page
if not asbool(config.get('ckan.search.show_all_types','False')):
Copy link
Contributor

Choose a reason for hiding this comment

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

pep8 if not asbool(config.get('ckan.search.show_all_types', 'False')): space after comma

@ghost ghost assigned tobes Jan 8, 2013
@amercader
Copy link
Member Author

@tobes I fixed the issues you mentioned, let me know if you find something else

tobes added a commit that referenced this pull request Jan 9, 2013
@tobes
Copy link
Contributor

tobes commented Jan 9, 2013

I had to rename your migration file due to a conflict. now merged

@tobes tobes closed this Jan 9, 2013
@tobes tobes deleted the 3022-IDatasetForm-fixes branch January 9, 2013 10:33
amercader referenced this pull request Feb 14, 2013
This is because package_type should not influence the page that is redirected to. The previous implementation had the problem that package_type is `package` by default which broke the redirection after editing the slug of a dataset.
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.

None yet

2 participants