Added item counts in user_items response. Moved more app config options to config.py.

This commit is contained in:
neviyn 2015-10-05 16:06:10 +01:00
parent 870bcf26e6
commit 67fa43dd8c
2 changed files with 11 additions and 3 deletions

View File

@ -2,3 +2,5 @@
# Change as required.
SQLALCHEMY_DATABASE_URI = 'sqlite:///wanikani.db'
SECRET_KEY = "putabettersecretkeyhere"
DEBUG = False
SERVER_NAME = '127.0.0.1:5000'

View File

@ -143,12 +143,16 @@ def show_quiz():
@login_required
def get_items():
items = []
radical_count = 0
for item in json.loads(current_user.radicals):
radical_count += 1
if item['image']:
items.append({'item_type': 'radical', 'question': item['image'], 'answer': item['meaning']})
else:
items.append({'item_type': 'radical', 'question': item['character'], 'answer': item['meaning']})
kanji_count = 0
for item in json.loads(current_user.kanji):
kanji_count += 1
made_answer = ""
if item['onyomi'] and item['kunyomi']:
made_answer = item['onyomi'] + ',' + item['kunyomi'].replace('.*', '')
@ -158,10 +162,13 @@ def get_items():
made_answer = item['kunyomi'].replace('.*', '')
items.append({'item_type': 'kanji', 'question': item['character'], 'answer': made_answer,
'answer_meaning': item['meaning']})
vocabulary_count = 0
for item in json.loads(current_user.vocabulary):
vocabulary_count += 1
items.append({'item_type': 'vocabulary', 'question': item['character'], 'answer': item['kana'],
'answer_meaning': item['meaning']})
return jsonify(item_list=items)
return jsonify(radical_count=radical_count, kanji_count=kanji_count, vocabulary_count=vocabulary_count,
item_list=items)
@app.route('/refresh', methods=['POST'])
@ -182,5 +189,4 @@ def unauthorized():
if __name__ == '__main__':
db.create_all()
app.debug = True
app.run()
app.run(threaded=True)