Skip to content

Commit

Permalink
[#2375] fixes to add dataset form
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jun 25, 2012
1 parent 1243d15 commit 4cb3149
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 11 additions & 1 deletion ckan/controllers/package.py
Expand Up @@ -425,9 +425,18 @@ def new(self, data=None, errors=None, error_summary=None):
request.params, ignore_keys=CACHE_PARAMETERS))))
c.resources_json = json.dumps(data.get('resources',[]))

# convert tags if not supplied in data
if data and not data.get('tag_string'):
data['tag_string'] = ', '.join(h.dict_list_reduce(c.pkg_dict['tags'], 'name'))

errors = errors or {}
error_summary = error_summary or {}
vars = {'data': data, 'errors': errors, 'error_summary': error_summary, 'action': 'new'}
# in the phased add dataset we need to know that
# we have already completed stage 1
stage = 1
if c.form_style == 'new':
stage = 1
vars = {'data': data, 'errors': errors, 'error_summary': error_summary, 'action': 'new', 'stage' : stage}
c.errors_json = json.dumps(errors)

self._setup_template_variables(context, {'id': id})
Expand Down Expand Up @@ -528,6 +537,7 @@ def edit(self, id, data=None, errors=None, error_summary=None):
# are we doing a multiphase add?
if data['state'] == 'draft':
c.form_action = h.url_for(controller='package', action='new')
c.form_style = 'new'
return self.new(data=data)


Expand Down
9 changes: 5 additions & 4 deletions ckan/templates/package/new_package_form.html
@@ -1,23 +1,24 @@
{% extends 'package/pages/form.html' %}

{% set form_style = c.form_style or c.action %}
{% block metadata_fields %}
{% if c.action == 'edit' %}{{ super() }}{% endif %}
{% if form_style == 'edit' %}{{ super() }}{% endif %}
{% endblock %}

{% block disclaimer %}
{% if c.action != 'edit' %}{{ super() }}{% endif %}
{% if form_style != 'edit' %}{{ super() }}{% endif %}
{% endblock %}

{% block save_button_text %}
{% if c.action != 'edit' %}
{% if form_style != 'edit' %}
{{ super() }}
{% else %}
{{ _('Update Dataset') }}
{% endif %}
{% endblock %}

{% block cancel_button %}
{% if c.action != 'edit' %}
{% if form_style != 'edit' %}
{{ super() }}
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion ckan/templates/package/pages/form_page.html
Expand Up @@ -9,7 +9,7 @@
{% block primary_content %}
<section class="module">
<div class="module-content">
{% block stages %}{{ h.snippet('package/snippets/stages.html', stage=1) }}{% endblock %}
{% block stages %}{{ h.snippet('package/snippets/stages.html', stage=stage) }}{% endblock %}
{% block form %}{{ c.form | safe }}{% endblock %}
</div>
</section>
Expand Down

0 comments on commit 4cb3149

Please sign in to comment.