From 27f6e406df3d975cee26bb1daacb277e6a59dc42 Mon Sep 17 00:00:00 2001 From: blagoja Date: Tue, 16 Jul 2024 14:29:13 +0200 Subject: [PATCH] Restructure templates and modify auth functions --- ckanext/bulkupload/auth.py | 9 +++++++++ .../templates/{ => package}/package_busoperator.html | 2 +- ckanext/bulkupload/views.py | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) rename ckanext/bulkupload/templates/{ => package}/package_busoperator.html (98%) diff --git a/ckanext/bulkupload/auth.py b/ckanext/bulkupload/auth.py index 66aac40..c06d566 100644 --- a/ckanext/bulkupload/auth.py +++ b/ckanext/bulkupload/auth.py @@ -1,6 +1,15 @@ +import ckan.plugins.toolkit as toolkit + + def bulk_resource_upload(context, data_dict): + userobj = context.get('auth_user_obj') + if not userobj: + raise toolkit.NotAuthorized return {'success': False} def package_busoperator(context, data_dict): + userobj = context.get('auth_user_obj') + if not userobj: + raise toolkit.NotAuthorized return {'success': False} diff --git a/ckanext/bulkupload/templates/package_busoperator.html b/ckanext/bulkupload/templates/package/package_busoperator.html similarity index 98% rename from ckanext/bulkupload/templates/package_busoperator.html rename to ckanext/bulkupload/templates/package/package_busoperator.html index 1d4236d..3dcdf28 100644 --- a/ckanext/bulkupload/templates/package_busoperator.html +++ b/ckanext/bulkupload/templates/package/package_busoperator.html @@ -10,7 +10,7 @@ {{ form.input('date-start', type='date', id='field-date-start', label=_('Date start'), value='', error='') }}
{{ form.info('Date start') }}
{{ form.input('date-end', type='date', id='field-date-end', label=_('Date end'), value='', error='') }} -
{{ form.info('Date start') }}
+
{{ form.info('Date end') }}
diff --git a/ckanext/bulkupload/views.py b/ckanext/bulkupload/views.py index cabcdb1..974d3bb 100644 --- a/ckanext/bulkupload/views.py +++ b/ckanext/bulkupload/views.py @@ -55,7 +55,7 @@ def package_busoperator(): 'org_list': org_list, } - return base.render('package_busoperator.html', extra_var) + return base.render('package/package_busoperator.html', extra_var) elif flask.request.method == 'POST': context = { @@ -80,6 +80,8 @@ def package_busoperator(): 'private': False, 'status': 'active', 'owner_org': form_data['owner_org'], + 'dataset_start_date': form_data['date-start'], + 'dataset_end_date': form_data['date-end'], } try: x = tk.get_action("package_create")(context, data_dict)