diff --git a/queries.py b/queries.py index 9896add..a27d1da 100644 --- a/queries.py +++ b/queries.py @@ -106,8 +106,9 @@ def process_form(form, user): # creates a set owned by the given user using the cells = [] cell_fields = dict(filter(lambda elem: 'cell' in elem[0] and 'cell[0]' not in elem[0], form.items())) # non-"side name" cells for field in cell_fields: - card_index = int(field[5:6])-1 - side_index = int(field[-2:-1]) + card_index = int(field[5:-1:].split('][')[0]) - 1 + side_index = int(field[5:-1:].split('][')[1]) + cell = {'card_id': card_index+card_id, 'side_id': side_id+side_index, 'info': form[field]} cells.append(cell) cells_result = db.engine.execute(Cell_SQL.__table__.insert(), cells) diff --git a/static/javascript/set-study.js b/static/javascript/set-study.js index 4be8c11..1712cff 100644 --- a/static/javascript/set-study.js +++ b/static/javascript/set-study.js @@ -52,7 +52,8 @@ function shuffleArray(array) { $(document).ready(function(){ let pathArray = window.location.pathname.split('/'); - let set_id = pathArray[2]; + let max_occur = pathArray.length; + let set_id = pathArray[Number(max_occur-2)]; let total_sides, total_cards, sides, cards, cards_shuffled; let side_order = {}; $.get("../../api/set_info?set=" + set_id, function(data, status){ diff --git a/templates/base.html b/templates/base.html index 9885d29..cf050a7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -11,7 +11,7 @@
Public sets are viewable by anyone, while private sets can only be seen by you. Regardless of whether a set is public or private, only you can edit and delete it.
You can play around with adding or removing sides and cards - these are flexible flashcards!
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/set.html b/templates/set.html index c99fc44..2d0405c 100644 --- a/templates/set.html +++ b/templates/set.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block head %} {{ super() }} - + {% endblock %} {% block body %}In this view, you can see a quick overview of a set.
From here, you can study the set. If you own it, you can also edit or delete it.
-{% endblock %} \ No newline at end of file +{% endblock %}