-
Notifications
You must be signed in to change notification settings - Fork 163
/
logic.py
79 lines (63 loc) · 2.19 KB
/
logic.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
67
68
69
70
71
72
73
74
from ckantoolkit import get_or_bust, side_effect_free, ObjectNotFound
from ckanext.scheming.helpers import (
scheming_dataset_schemas, scheming_get_dataset_schema,
scheming_group_schemas, scheming_get_group_schema,
scheming_organization_schemas, scheming_get_organization_schema,
)
@side_effect_free
def scheming_dataset_schema_list(context, data_dict):
'''
Return a list of dataset types customized with the scheming extension
'''
return list(scheming_dataset_schemas())
@side_effect_free
def scheming_dataset_schema_show(context, data_dict):
'''
Return the scheming schema for a given dataset type
:param type: the dataset type
:param expanded: True to expand presets (default)
'''
t = get_or_bust(data_dict, 'type')
expanded = data_dict.get('expanded', True)
s = scheming_get_dataset_schema(t, expanded)
if s is None:
raise ObjectNotFound()
return s
@side_effect_free
def scheming_group_schema_list(context, data_dict):
'''
Return a list of group types customized with the scheming extension
'''
return list(scheming_group_schemas())
@side_effect_free
def scheming_group_schema_show(context, data_dict):
'''
Return the scheming schema for a given group type
:param type: the group type
:param expanded: True to expand presets (default)
'''
t = get_or_bust(data_dict, 'type')
expanded = data_dict.get('expanded', True)
s = scheming_get_group_schema(t, expanded)
if s is None:
raise ObjectNotFound()
return s
@side_effect_free
def scheming_organization_schema_list(context, data_dict):
'''
Return a list of organization types customized with the scheming extension
'''
return list(scheming_organization_schemas())
@side_effect_free
def scheming_organization_schema_show(context, data_dict):
'''
Return the scheming schema for a given organization type
:param type: the organization type
:param expanded: True to expand presets (default)
'''
t = get_or_bust(data_dict, 'type')
expanded = data_dict.get('expanded', True)
s = scheming_get_organization_schema(t, expanded)
if s is None:
raise ObjectNotFound()
return s