Skip to content

Commit

Permalink
Auth functions and add busoperator dataset button
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Jul 15, 2024
1 parent 8d3dd08 commit 9e87f22
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ckanext/bulkupload/auth.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
def bulk_resource_upload(context, data_dict):
return {'success': False}


def package_busoperator(context, data_dict):
return {'success': False}
1 change: 1 addition & 0 deletions ckanext/bulkupload/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def update_config(self, config_):
def get_auth_functions(self):
return {
"bulk_resource_upload": auth.bulk_resource_upload,
"package_busoperator": auth.package_busoperator,
}

# IBlueprint
Expand Down
9 changes: 9 additions & 0 deletions ckanext/bulkupload/templates/snippets/add_dataset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% set dataset_type = dataset_type if dataset_type else 'dataset' %}

{% if group %}
{% link_for _('Add Dataset'), named_route='dataset.new', group=group, class_='btn btn-primary', icon='plus-square' %}
{% link_for _('Add Dataset Busoperator'), group=group, named_route='bulkupload.package_busoperator', class_='btn btn-primary', icon='plus-square' %}
{% else %}
{% link_for _('Add ' + dataset_type.title()), named_route='%s.new' % dataset_type, class_='btn btn-primary', icon='plus-square' %}
{% link_for _('Add Dataset Busoperator'), named_route='bulkupload.package_busoperator', class_='btn btn-primary', icon='plus-square' %}
{% endif %}
8 changes: 4 additions & 4 deletions ckanext/bulkupload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
for your uploads''')


def busoperator():
def package_busoperator():

if flask.request.method == 'GET':
context = {
Expand All @@ -47,7 +47,7 @@ def busoperator():
org_list = tk.get_action("organization_list_for_user")(context, user_dict)

try:
tk.check_access("bulk_resource_upload", context)
tk.check_access("package_busoperator", context)
except:
return tk.abort(403)

Expand All @@ -65,7 +65,7 @@ def busoperator():
"auth_user_obj": g.userobj,
}
try:
tk.check_access("bulk_resource_upload", context)
tk.check_access("package_busoperator", context)
except:
return tk.abort(403)

Expand Down Expand Up @@ -169,7 +169,7 @@ def bulk_resource_upload(pkg_name):


bulkupload.add_url_rule("/dataset/new/busoperator",
view_func=busoperator,
view_func=package_busoperator,
methods=("GET", "POST"))

bulkupload.add_url_rule("/dataset/<pkg_name>/resource/new/bulkupload",
Expand Down

0 comments on commit 9e87f22

Please sign in to comment.