Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya-Oladazimi committed Jan 26, 2022
2 parents d4ff7ae + 957546c commit 7677099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions ckanext/semantic_media_wiki/controllers/media_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ckan.lib.helpers as h



class MediaWikiController():

def machines_view(id):
Expand All @@ -27,13 +26,12 @@ def machines_view(id):

def save_machines():
package_name = request.form.get('package')
resources_len = 0
machine_count = request.form.get('machine_count')
if package_name == None:
return toolkit.abort(403, "bad request")

try:
package = toolkit.get_action('package_show')({}, {'name_or_id': package_name})
resources_len = len(package['resources'])

except:
return toolkit.abort(400, "Package not found")
Expand All @@ -46,7 +44,7 @@ def save_machines():
return redirect(h.url_for('dataset.read', id=str(package_name) , _external=True))

if action == 'finish_machine':
result = Helper.add_machine_links(request, resources_len)
result = Helper.add_machine_links(request, int(machine_count))
if result != false:
return redirect(h.url_for('dataset.read', id=str(package_name) , _external=True))

Expand All @@ -59,7 +57,7 @@ def edit_machines_view(id):
if not Helper.check_access_edit_package(id):
return toolkit.abort(403, "You are not authorized to access this function" )

package = toolkit.get_action('package_show')({}, {'name_or_id': id})
package = toolkit.get_action('package_show')({}, {'name_or_id': id})
machines, machine_imageUrl = Helper.get_machines_list()
resource_machine_data = {}
machine_link_name = {}
Expand All @@ -84,17 +82,17 @@ def edit_machines_view(id):

def edit_save():
package_name = request.form.get('package')
machine_count = request.form.get('machine_count')
package = toolkit.get_action('package_show')({}, {'name_or_id': package_name})
if not Helper.check_access_edit_package(package['id']):
return toolkit.abort(403, "You are not authorized to access this function" )

resources_len = int(request.form.get('resources_length'))
action = request.form.get('save_btn')
if action == 'go-dataset-veiw': # cancel button
return redirect(h.url_for('dataset.read', id=str(package_name) , _external=True))

if action == 'update_machine':
result = Helper.update_resource_machine(request, resources_len, package)
result = Helper.update_resource_machine(request, int(machine_count), package)
if result:
return redirect(h.url_for('dataset.read', id=str(package_name) , _external=True))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% for res in resources %}
{% set machine_count = resources|length + 10 %}
{% for res in range(machine_count) %}
<input type="hidden" name="machine_count" value="{{machine_count}}">
<input type="hidden" name={{ 'machine_name_' ~ (loop.index + offset) }} id={{ 'machine_name_' ~ (loop.index + offset) }} >
<div class="row machine-box" id={{'machine_box_id_' ~ (loop.index + offset)}}>
{% snippet 'snippets/semantic_media_wiki_resources_modal.html',
Expand Down

0 comments on commit 7677099

Please sign in to comment.