Skip to content

Commit

Permalink
[#2743] add dataset to group functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 24, 2012
1 parent 0161238 commit 2c1c4c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -444,9 +444,8 @@ def new(self, data=None, errors=None, error_summary=None):
return self._save_new(context)

data = data or clean_dict(unflatten(tuplize_dict(parse_params(
request.params, ignore_keys=CACHE_PARAMETERS))))
request.POST, 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(
Expand All @@ -462,6 +461,11 @@ def new(self, data=None, errors=None, error_summary=None):
elif data.get('state') == 'draft-complete':
stage = ['active', 'complete', 'complete']

# if we are creating from a group then this allows the group to be
# set automatically
data['group_id'] = request.params.get('group') or \
request.params.get('groups__0__id')

vars = {'data': data, 'errors': errors,
'error_summary': error_summary,
'action': 'new', 'stage': stage}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/group/read.html
Expand Up @@ -9,7 +9,7 @@

{% block actions_content %}
{% if h.check_access('group_update', {'id': c.group.id}) %}
<li>{% link_for _('Add Dataset'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='plus' %}</li>
<li>{% link_for _('Add Dataset to Group'), controller='package', action='new', group=c.group_dict.id, class_='btn', icon='plus' %}</li>
<li>{% link_for _('Edit'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='cog' %}</li>
{% endif %}
{# <li>{% link_for _('History'), controller='group', action='history', id=c.group_dict.name, class_='btn', icon='undo' %}</li> #}
Expand Down
5 changes: 5 additions & 0 deletions ckan/templates/package/snippets/package_basic_fields.html
Expand Up @@ -32,3 +32,8 @@
</span>
</div>
</div>

{# if we have a default group then this wants remembering #}
{% if data.group_id %}
<input type="hidden" name="groups__0__id" value="{{ data.group_id }}" />
{% endif %}

0 comments on commit 2c1c4c7

Please sign in to comment.