-
Notifications
You must be signed in to change notification settings - Fork 2k
/
delete.py
66 lines (53 loc) · 2.39 KB
/
delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from ckan.logic import check_access_old
from ckan.logic.auth import get_package_object, get_group_object
from ckan.logic.auth.create import package_relationship_create
from ckan.authz import Authorizer
from ckan.lib.base import _
def package_delete(context, data_dict):
model = context['model']
user = context['user']
package = get_package_object(context, data_dict)
authorized = check_access_old(package, model.Action.PURGE, context)
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to delete package %s') % (str(user),package.id)}
else:
return {'success': True}
def package_relationship_delete(context, data_dict):
can_edit_this_relationship = package_relationship_create(context, data_dict)
if not can_edit_this_relationship['success']:
return can_edit_this_relationship
model = context['model']
user = context['user']
relationship = context['relationship']
authorized = check_access_old(relationship, model.Action.PURGE, context)
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to delete relationship %s') % (str(user),relationship.id)}
else:
return {'success': True}
def group_delete(context, data_dict):
model = context['model']
user = context['user']
group = get_group_object(context, data_dict)
authorized = check_access_old(group, model.Action.PURGE, context)
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to delete group %s') % (str(user),group.id)}
else:
return {'success': True}
def revision_undelete(context, data_dict):
return {'success': False, 'msg': 'Not implemented yet in the auth refactor'}
def revision_delete(context, data_dict):
return {'success': False, 'msg': 'Not implemented yet in the auth refactor'}
def task_status_delete(context, data_dict):
model = context['model']
user = context['user']
authorized = Authorizer().is_sysadmin(unicode(user))
if not authorized:
return {'success': False, 'msg': _('User %s not authorized to delete task_status') % str(user)}
else:
return {'success': True}
def vocabulary_delete(context, data_dict):
user = context['user']
return {'success': Authorizer.is_sysadmin(user)}
def tag_delete(context, data_dict):
user = context['user']
return {'success': Authorizer.is_sysadmin(user)}