Skip to content

Commit

Permalink
Merge branch 'feature-2375-demo-theme' of github.com:okfn/ckan into f…
Browse files Browse the repository at this point in the history
…eature-2375-demo-theme
  • Loading branch information
aron committed Jun 28, 2012
2 parents 407e610 + 0fd1ad6 commit 6c81922
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
21 changes: 13 additions & 8 deletions ckan/controllers/package.py
Expand Up @@ -480,7 +480,7 @@ def new(self, data=None, errors=None, error_summary=None):
def new_resource(self, id, data=None, errors=None, error_summary=None):
''' FIXME: This is a temporary action to allow styling of the
forms. '''
if request.method == 'POST':
if request.method == 'POST' and not data:
save_action = request.params.get('save')
if save_action in ['again', 'next'] and not data:
data = data or clean_dict(unflatten(tuplize_dict(parse_params(
Expand All @@ -492,7 +492,12 @@ def new_resource(self, id, data=None, errors=None, error_summary=None):
'api_version': 3,
'user': c.user or c.author,
'extras_as_string': True}
get_action('resource_create')(context, data)
try:
get_action('resource_create')(context, data)
except ValidationError, e:
errors = e.error_dict
error_summary = e.error_summary
return self.new_resource(id, data, errors, error_summary)
if save_action == 'next':
redirect(h.url_for(controller='package',
action='new_metadata', id=id))
Expand All @@ -504,12 +509,12 @@ def new_resource(self, id, data=None, errors=None, error_summary=None):
vars = {'data': data, 'errors': errors,
'error_summary': error_summary, 'action': 'new'}
vars['pkg_name'] = id
## FIXME Resources selector in side bar think, think, think
## context = {'model': model, 'session': model.Session,
## 'user': c.user or c.author, 'extras_as_string': True,}
## get_action('package_show')(context, {'id': id})
## # required for nav menu
## vars['pkg'] = context['package']
# get resources for sidebar
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'extras_as_string': True,}
pkg_dict = get_action('package_show')(context, {'id': id})
# required for nav menu
vars['pkg_dict'] = pkg_dict
return render('package/new_resource.html', extra_vars=vars)

def new_metadata(self, id, data=None, errors=None, error_summary=None):
Expand Down
3 changes: 2 additions & 1 deletion ckan/templates/package/new_resource.html
Expand Up @@ -14,5 +14,6 @@ <h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What
</div>
</section>

{{ self.resources_module() }}
{% snippet 'package/snippets/resources.html', pkg=pkg_dict %}

{% endblock %}
2 changes: 1 addition & 1 deletion ckan/templates/package/pages/form_page.html
Expand Up @@ -33,6 +33,6 @@ <h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What

{% block resources_module %}
{# TODO: Pass in a list of previously created resources and the current package dict #}
{% snippet "package/snippets/resources.html", resources=[], pkg={}, action='new_resource' %}
{% snippet "package/snippets/resources.html", pkg={}, action='new_resource' %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion ckan/templates/package/resource_read.html
Expand Up @@ -104,7 +104,7 @@ <h2 class="module-heading"><i class="icon-medium icon-info-sign"></i> Resource I
</ul>
</section>

{% snippet "package/snippets/resources.html", resources=pkg.resources, pkg=pkg, active=res.id %}
{% snippet "package/snippets/resources.html", pkg=pkg, active=res.id %}

{% snippet "snippets/social.html" %}
{% endblock %}
4 changes: 2 additions & 2 deletions ckan/templates/package/snippets/resources.html
Expand Up @@ -2,16 +2,16 @@
Displays a sidebard module with navigation containing the provided resources.
If no resources are provided then the module will not be displayed.

resources - A list of resource dicts to display.
pkg - The package dict that owns the resources.
active - The id of the currently displayed resource.
action - The controller action to use (default: 'resource_read').

Example:

{% snippet "package/snippets/resources.html", resources=pkg.resources, pkg=pkg, active=res.id %}
{% snippet "package/snippets/resources.html", pkg=pkg, active=res.id %}

#}
{% set resources = pkg.resources or [] %}
{% if resources %}
<section class="module module-narrow resources">
<h2 class="module-heading">{{ _("Resources") }}</h2>
Expand Down

0 comments on commit 6c81922

Please sign in to comment.