Skip to content

Commit

Permalink
[#2712] fix group delete
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 19, 2012
1 parent 00573a7 commit bd3593f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions ckan/controllers/group.py
Expand Up @@ -255,8 +255,6 @@ def new(self, data=None, errors=None, error_summary=None):
return render(self._new_template(group_type))

def edit(self, id, data=None, errors=None, error_summary=None):
if 'delete' in request.params:
return self.delete(id)
group_type = self._get_group_type(id.split('@')[0])
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'extras_as_string': True,
Expand Down Expand Up @@ -384,19 +382,19 @@ def authz(self, id):
return render('group/authz.html')

def delete(self, id):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}

if 'cancel' in request.params:
h.redirect_to(controller='group', action='edit', id=id)

context = {'model': model, 'session': model.Session,
'user': c.user or c.author}

try:
check_access('group_delete', context, {'id': id})
except NotAuthorized:
abort(401, _('Unauthorized to delete group %s') % '')

try:
if request.params.get('confirm_delete') == 'yes':
if request.method == 'POST':
get_action('group_delete')(context, {'id': id})
h.flash_notice(_('Group has been deleted.'))
h.redirect_to(controller='group', action='index')
Expand Down
1 change: 0 additions & 1 deletion ckan/templates/group/confirm_delete.html
Expand Up @@ -12,7 +12,6 @@
<form action="{% url_for controller='group', action='delete', id=c.group_dict.name %}" method="post">
<button class="btn" type="submit" name="cancel" >{{ _('Cancel') }}</button>
<button class="btn btn-primary" type="submit" name="delete" >{{ _('Confirm Delete') }}</button>
<input type="hidden" name="confirm_delete" value="yes" />
</form>
</p>
</div>
Expand Down
3 changes: 1 addition & 2 deletions ckan/templates/group/snippets/group_form.html
Expand Up @@ -71,8 +71,7 @@
<div class="form-actions">
{% block delete_button %}
{% if h.check_access('group_delete', {'id': data.id}) %}
<button class="btn btn-danger pull-left" type="submit" name="delete">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</button>
<input type="hidden" name="confirm_delete" value="" />
<a class="btn btn-danger pull-left" href="{% url_for controller='group', action='delete', id=data.id %}">{% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
{% endif %}
{% endblock %}
<button class="btn btn-primary" name="save">{% block save_text %}{{ _('Save Group') }}{% endblock %}</button>
Expand Down

0 comments on commit bd3593f

Please sign in to comment.