data = get_card_data(deck_id, card_id, None)
return dict(web_path=web_path,
deck_id=deck_id,
- card_type=data['type'],
- title=data['title'],
- paragraphs=data['paragraphs'],
- answers=data['answers'])
+ card=data)
@post(web_path + '/decks/<deck_id>/cards/<card_id>')
def update_card(deck_id, card_id):
os.makedirs(cards_dir)
path_card = cards_dir + '/' + card_id
card_type = request.forms.get('type')
- json_dict = {'type': request.forms.get('type'),
- 'title': '',
- 'answers': [],
- 'paragraphs': []}
+ json_dict = {'type': request.forms.get('type')}
if card_type == 'action':
json_dict['title'] = request.forms.get('title')
json_dict['paragraphs'] = request.forms.getall('paragraph')
return dict(web_path=web_path,
card_id=card_id,
deck_id=deck_id,
- card_type=data['type'],
- title=data['title'],
- paragraphs=data['paragraphs'],
- answers=data['answers'],
+ card=data,
deletable=deletable)
@get(web_path + '/decks/<deck_id>/cards/<card_id>/delete')
</style>
<body>
<div class="card">
- % if card_type == 'guilt':
+ % if card["type"] == 'guilt':
<h1 id="title">GUILT CARD</h1>
<p id="prompt">Choose at least one of these guilts as your own:</p>
<ul id="answers">
- % for answer in answers:
+ % for answer in card["answers"]:
<li>{{ answer }}</li>
% end
<ul/>
% end
- % if card_type == 'action':
- <h1 id="title">ACTION CARD<br />{{ title }}</h1>
- % for paragraph in paragraphs:
+ % if card["type"] == 'action':
+ <h1 id="title">ACTION CARD<br />{{ card["title"] }}</h1>
+ % for paragraph in card["paragraphs"]:
<p>{{ paragraph }}</p>
% end
% end
<!DOCTYPE HTML>
<html>
<body>
+<h1>Edit {{ card["type"] }} card</h1>
<form action="{{ web_path }}/decks/{{deck_id}}/cards/{{ card_id }}" method="POST">
-<input type="hidden" name="type" value="{{ card_type }}" /><br />
-% if card_type == 'guilt':
-% for answer in answers:
+<input type="hidden" name="type" value="{{ card["type"] }}" /><br />
+% if card["type"] == 'guilt':
+% for answer in card["answers"]:
answer: <input type="text" name="answer" value="{{ answer }}" /><br />
% end
answer: <input type="text" name="answer" value="" /><br />
answer: <input type="text" name="answer" value="" /><br />
answer: <input type="text" name="answer" value="" /><br />
% end
-% if card_type == 'action':
-title: <input type="text" name="title" value="{{ title }}" /><br />
-% for paragraph in paragraphs:
+% if card["type"] == 'action':
+title: <input type="text" name="title" value="{{ card["title"] }}" /><br />
+% for paragraph in card["paragraphs"]:
paragraph: <input type="text" name="paragraph" value="{{ paragraph }}" /><br />
% end
paragraph: <input type="text" name="paragraph" value="" /><br />