Chage url mem to memorize
This commit is contained in:
@@ -59,7 +59,7 @@ def initdb():
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
if session.get('logged_in'):
|
if session.get('logged_in'):
|
||||||
return redirect(url_for('mem', card_type="1"))
|
return redirect(url_for('memorize', card_type="1"))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
@@ -179,10 +179,10 @@ def delete(card_id):
|
|||||||
flash('Card deleted.')
|
flash('Card deleted.')
|
||||||
return redirect(url_for('cards'))
|
return redirect(url_for('cards'))
|
||||||
|
|
||||||
@app.route('/mem')
|
@app.route('/memorize')
|
||||||
@app.route('/mem/<card_id>')
|
@app.route('/memorize/<card_id>')
|
||||||
@app.route('/mem/<card_type>')
|
@app.route('/memorize/<card_type>')
|
||||||
def mem(card_type, card_id=None):
|
def memorize(card_type, card_id=None):
|
||||||
tag = getTag(card_type)
|
tag = getTag(card_type)
|
||||||
if tag is None:
|
if tag is None:
|
||||||
return redirect(url_for('cards'))
|
return redirect(url_for('cards'))
|
||||||
@@ -202,28 +202,6 @@ def mem(card_type, card_id=None):
|
|||||||
card_type=card_type,
|
card_type=card_type,
|
||||||
short_answer=short_answer, tags=tags)
|
short_answer=short_answer, tags=tags)
|
||||||
|
|
||||||
def memorize(card_type, card_id):
|
|
||||||
if card_type == "general":
|
|
||||||
type = 1
|
|
||||||
elif card_type == "code":
|
|
||||||
type = 2
|
|
||||||
else:
|
|
||||||
return redirect(url_for('cards'))
|
|
||||||
|
|
||||||
if card_id:
|
|
||||||
card = get_card_by_id(card_id)
|
|
||||||
else:
|
|
||||||
card = get_card(type)
|
|
||||||
if not card:
|
|
||||||
flash("You've learned all the " + card_type + " cards.")
|
|
||||||
return redirect(url_for('cards'))
|
|
||||||
short_answer = (len(card['back']) < 75)
|
|
||||||
tags = getAllTag()
|
|
||||||
return render_template('memorize.html',
|
|
||||||
card=card,
|
|
||||||
card_type=card_type,
|
|
||||||
short_answer=short_answer, tags=tags)
|
|
||||||
|
|
||||||
|
|
||||||
def get_card(type):
|
def get_card(type):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
@@ -267,7 +245,7 @@ def mark_known(card_id, card_type):
|
|||||||
db.execute('UPDATE cards SET known = 1 WHERE id = ?', [card_id])
|
db.execute('UPDATE cards SET known = 1 WHERE id = ?', [card_id])
|
||||||
db.commit()
|
db.commit()
|
||||||
flash('Card marked as known.')
|
flash('Card marked as known.')
|
||||||
return redirect(url_for('mem', card_type=card_type))
|
return redirect(url_for('memorize', card_type=card_type))
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
@@ -370,14 +348,6 @@ def init_tag():
|
|||||||
def show():
|
def show():
|
||||||
if not session.get('logged_in'):
|
if not session.get('logged_in'):
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
db = get_db()
|
|
||||||
# query = '''
|
|
||||||
# SELECT id, type, front, back, known
|
|
||||||
# FROM cards
|
|
||||||
# ORDER BY id DESC
|
|
||||||
# '''
|
|
||||||
# cur = db.execute(query)
|
|
||||||
# cards = cur.fetchall()
|
|
||||||
tags = getAllTag()
|
tags = getAllTag()
|
||||||
return render_template('show.html', tags=tags, filter_name="")
|
return render_template('show.html', tags=tags, filter_name="")
|
||||||
|
|
||||||
@@ -402,7 +372,7 @@ def bookmark(card_type, card_id):
|
|||||||
db.execute('UPDATE cards SET type = ? WHERE id = ?',[card_type,card_id])
|
db.execute('UPDATE cards SET type = ? WHERE id = ?',[card_type,card_id])
|
||||||
db.commit()
|
db.commit()
|
||||||
flash('Card saved.')
|
flash('Card saved.')
|
||||||
return redirect(url_for('mem', card_type=card_type))
|
return redirect(url_for('memorize', card_type=card_type))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0')
|
app.run(host='0.0.0.0')
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<div class="col-xs-12 text-center">
|
<div class="col-xs-12 text-center">
|
||||||
<div class="btn-group btn-group-lg" role="group" aria-label="card type">
|
<div class="btn-group btn-group-lg" role="group" aria-label="card type">
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<a href="{{ url_for('mem', card_type=tag.id) }}" class="btn btn-{{ "primary" if card_type == tag.id else "default" }}">{{tag.tagName}}</a>
|
<a href="{{ url_for('memorize', card_type=tag.id) }}" class="btn btn-{{ "primary" if card_type == tag.id else "default" }}">{{tag.tagName}}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<a href="{{ url_for('mem', card_type=card_type) }}" class="btn btn-primary btn-lg">
|
<a href="{{ url_for('memorize', card_type=card_type) }}" class="btn btn-primary btn-lg">
|
||||||
Next Card
|
Next Card
|
||||||
<i class="fa fa-arrow-right"></i>
|
<i class="fa fa-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user