Skip to content

Commit

Permalink
[#2939] Delete group/org action
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 3, 2012
1 parent 4422768 commit 70e7d09
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions ckan/logic/action/delete.py
Expand Up @@ -187,7 +187,7 @@ def member_delete(context, data_dict=None):
member.delete()
model.repo.commit()

def group_delete(context, data_dict):
def _group_or_org_delete(context, data_dict, is_org):
'''Delete a group.
You must be authorized to delete the group.
Expand All @@ -207,7 +207,15 @@ def group_delete(context, data_dict):

revisioned_details = 'Group: %s' % group.name

_check_access('group_delete', context, data_dict)
if is_org:
_check_access('organization_delete', context, data_dict)
else:
_check_access('group_delete', context, data_dict)

# organization delete will delete all datasets for that org
if is_org:
for pkg in group.active_packages().all():
_get_action('package_delete')(context, {id: pkg.id})

rev = model.repo.new_revision()
rev.author = user
Expand All @@ -224,6 +232,28 @@ def group_delete(context, data_dict):

model.repo.commit()

def group_delete(context, data_dict):
'''Delete a group.
You must be authorized to delete the group.
:param id: the name or id of the group
:type id: string
'''
return _group_or_org_delete(context, data_dict)

def organization_delete(context, data_dict):
'''Delete a organization.
You must be authorized to delete the organization.
:param id: the name or id of the organization
:type id: string
'''
return _group_or_org_delete(context, data_dict, is_org=True)

def task_status_delete(context, data_dict):
'''Delete a task status.
Expand Down

0 comments on commit 70e7d09

Please sign in to comment.