-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathunpub.patch
49 lines (45 loc) · 2.38 KB
/
unpub.patch
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
diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py
index e3aa7c8..7a9d5ed 100644
--- a/ckan/controllers/package.py
+++ b/ckan/controllers/package.py
@@ -546,7 +546,10 @@ class PackageController(base.BaseController):
error_summary = error_summary or {}
# in the phased add dataset we need to know that
# we have already completed stage 1
- stage = ['active']
+ if 'unpublished' in data and data['unpublished'] == 'True':
+ stage = ['active', 'complete']
+ else:
+ stage = ['active']
if data.get('state', '').startswith('draft'):
stage = ['active', 'complete']
@@ -946,8 +949,9 @@ class PackageController(base.BaseController):
id=pkg_dict['name'])
redirect(url)
# Make sure we don't index this dataset
- if request.params['save'] not in ['go-resource', 'go-metadata']:
- data_dict['state'] = 'draft'
+ if 'unpublished' not in data_dict or data_dict['unpublished'] != 'True':
+ if request.params['save'] not in ['go-resource', 'go-metadata']:
+ data_dict['state'] = 'draft'
# allow the state to be changed
context['allow_state_change'] = True
@@ -956,10 +960,16 @@ class PackageController(base.BaseController):
pkg_dict = get_action('package_create')(context, data_dict)
if ckan_phase:
- # redirect to add dataset resources
- url = h.url_for(controller='package',
- action='new_resource',
- id=pkg_dict['name'])
+ if 'unpublished' in pkg_dict and pkg_dict['unpublished'] == 'True':
+ # redirect to add dataset resources
+ url = h.url_for(controller='package',
+ action='read',
+ id=pkg_dict['name'])
+ else:
+ # redirect to add dataset resources
+ url = h.url_for(controller='package',
+ action='new_resource',
+ id=pkg_dict['name'])
redirect(url)
self._form_save_redirect(pkg_dict['name'], 'new', package_type=package_type)