Listing and editing cards.

This commit is contained in:
John Washam
2016-06-30 22:19:16 -07:00
parent 00281ca2bf
commit 8edeefbf74
6 changed files with 81 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
<div class="well">
<h2>Add a Card</h2>
<form action="{{ url_for('add_card') }}" method=post class=add-card>
<form action="{{ url_for('add_card') }}" method=post>
<div class="form-group">
<label for="general" class="toggleButton btn btn-default btn-lg">General &nbsp;
<input type="radio" name="type" value="1" id="general"/>
@@ -36,7 +36,10 @@
{% for card in cards %}
<div>
<h3>{{ card.front }}</h3>
<h3>
<a href="{{ url_for('edit', card_id=card.id) }}" class="btn btn-xs btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
{{ card.front }}
</h3>
{% if card.type == 1 %}
{{ card.back|replace("\n", "<br />") }}
{% else %}

40
templates/edit.html Normal file
View File

@@ -0,0 +1,40 @@
{% extends "layout.html" %}
{% block body %}
<div class="well">
<h2>Edit Card #{{ card.id }}</h2>
<form action="{{ url_for('edit_card') }}" method=post>
<div class="form-group">
<label for="general" class="btn btn-default btn-lg">General &nbsp;
<input type="radio" name="type" value="1"
id="general" {{ "checked" if (card.type == 1) else "" }} />
</label>
<label for="code" class="btn btn-default btn-lg">Code &nbsp;
<input type="radio" name="type" value="2" id="code" {{ "checked" if (card.type == 2) else "" }} />
</label>
</div>
<div class="form-group">
<label for="front">Front of Card</label>
<input type="text" name="front" class="form-control" value="{{ card.front|e }}">
</div>
<div class="form-group">
<label for="back">Back of Card</label>
<textarea name="back"
class="form-control"
id="back"
placeholder="back of card"
rows="12">{{ card.back|e }}</textarea>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="known"
value="1" {{ "checked" if (card.known == 1) else "" }} /> Known
</label>
</div>
<hr />
<div class="form-group">
<input type="hidden" name="card_id" value="{{ card.id|e }}" />
<button type="submit" class="saveButton btn btn-lg btn-primary">Save</button>
</div>
</form>
</div>
{% endblock %}

View File

@@ -6,6 +6,7 @@
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}" />
<!-- I know this doesn't belong in head, but I have script in a template that needs to have jQuery -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://use.fontawesome.com/8cea844162.js"></script>
</head>
<body>
<div class="container">