Skip to content

Commit

Permalink
Update delete action docstrings
Browse files Browse the repository at this point in the history
Pinched from release-v1.8
  • Loading branch information
icmurray committed Nov 6, 2012
1 parent 69f387f commit 268cc9b
Showing 1 changed file with 76 additions and 14 deletions.
90 changes: 76 additions & 14 deletions ckan/logic/action/delete.py
Expand Up @@ -10,7 +10,14 @@
check_access = ckan.logic.check_access

def package_delete(context, data_dict):
'''Delete a dataset (package).
You must be authorized to delete the dataset.
:param id: the id or name of the dataset to delete
:type id: string
'''
model = context['model']
user = context['user']
id = data_dict['id']
Expand All @@ -33,7 +40,21 @@ def package_delete(context, data_dict):


def package_relationship_delete(context, data_dict):
'''Delete a dataset (package) relationship.
You must be authorised to delete dataset relationships, and to edit both
the subject and the object datasets.
:param subject: the id or name of the dataset that is the subject of the
relationship
:type subject: string
:param object: the id or name of the dataset that is the object of the
relationship
:type object: string
:param type: the type of the relationship
:type type: string
'''
model = context['model']
user = context['user']
id = data_dict['subject']
Expand Down Expand Up @@ -65,6 +86,14 @@ def package_relationship_delete(context, data_dict):
model.repo.commit()

def related_delete(context, data_dict):
'''Delete a related item from a dataset.
You must be a sysadmin or the owner of the related item to delete it.
:param id: the id of the related item
:type id: string
'''
model = context['model']
user = context['user']
id = data_dict['id']
Expand All @@ -81,20 +110,19 @@ def related_delete(context, data_dict):


def member_delete(context, data_dict=None):
"""
Removes an object as a member of a group. If the membership already exists
and is active then it will be deleted.
context:
model - The CKAN model module
user - The name of the current user
data_dict:
id - The ID of the group from which we want to remove object
object - The ID of the object being removed as a member
object_type - The name of the type being removed, all lowercase,
e.g. package, or user
"""
'''Remove an object (e.g. a user, dataset or group) from a group.
You must be authorized to edit a group to remove objects from it.
:param id: the id of the group
:type id: string
:param object: the id of the object to be removed
:type object: string
:param object_type: the type of the object to be removed, e.g. ``package``
or ``user``
:type object_type: string
'''
model = context['model']
user = context['user']

Expand All @@ -115,7 +143,14 @@ def member_delete(context, data_dict=None):
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
'''
model = context['model']
user = context['user']
id = data_dict['id']
Expand All @@ -140,6 +175,14 @@ def group_delete(context, data_dict):
model.repo.commit()

def task_status_delete(context, data_dict):
'''Delete a task status.
You must be a sysadmin to delete task statuses.
:param id: the id of the task status to delete
:type id: string
'''
model = context['model']
user = context['user']
id = data_dict['id']
Expand All @@ -157,6 +200,14 @@ def task_status_delete(context, data_dict):
model.Session.commit()

def vocabulary_delete(context, data_dict):
'''Delete a tag vocabulary.
You must be a sysadmin to delete vocabularies.
:param id: the id of the vocabulary
:type id: string
'''
model = context['model']

vocab_id = data_dict.get('id')
Expand All @@ -173,6 +224,17 @@ def vocabulary_delete(context, data_dict):
model.repo.commit()

def tag_delete(context, data_dict):
'''Delete a tag.
You must be a sysadmin to delete tags.
:param id: the id or name of the tag
:type id: string
:param vocabulary_id: the id or name of the vocabulary that the tag belongs
to (optional, default: None)
:type vocabulary_id: string
'''
model = context['model']

if not data_dict.has_key('id') or not data_dict['id']:
Expand Down

0 comments on commit 268cc9b

Please sign in to comment.