Display public games on /home/
This commit is contained in:
parent
81c18b5c7c
commit
6c244b084c
|
@ -3,7 +3,7 @@ from flask_login import login_required, current_user
|
|||
|
||||
from amanuensis.config import json_ro, json_rw
|
||||
from amanuensis.lexicon import LexiconModel
|
||||
from amanuensis.lexicon.manage import create_lexicon, get_user_lexicons
|
||||
from amanuensis.lexicon.manage import create_lexicon, get_all_lexicons
|
||||
from amanuensis.server.forms import LexiconCreateForm
|
||||
from amanuensis.server.helpers import admin_required
|
||||
from amanuensis.user import UserModel
|
||||
|
@ -15,10 +15,17 @@ def get_bp():
|
|||
|
||||
@bp.route('/', methods=['GET'])
|
||||
def home():
|
||||
lexicons = []
|
||||
if current_user.is_authenticated:
|
||||
lexicons = get_user_lexicons(current_user)
|
||||
return render_template('home/home.html', lexicons=lexicons)
|
||||
user_lexicons = []
|
||||
public_lexicons = []
|
||||
for lexicon in get_all_lexicons():
|
||||
if current_user.in_lexicon(lexicon):
|
||||
user_lexicons.append(lexicon)
|
||||
elif lexicon.join.public:
|
||||
public_lexicons.append(lexicon)
|
||||
return render_template(
|
||||
'home/home.html',
|
||||
user_lexicons=user_lexicons,
|
||||
public_lexicons=public_lexicons)
|
||||
|
||||
@bp.route('/admin/', methods=['GET'])
|
||||
@login_required
|
||||
|
|
|
@ -13,14 +13,24 @@
|
|||
|
||||
{% if current_user.is_authenticated %}
|
||||
<h2>Your games</h2>
|
||||
{% if lexicons %}
|
||||
{% for lexicon in lexicons %}
|
||||
{% if user_lexicons %}
|
||||
{% for lexicon in user_lexicons %}
|
||||
{{ macros.dashboard_lexicon_item(lexicon) }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>You haven't joined a game yet.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<h2>Public games</h2>
|
||||
{% if public_lexicons %}
|
||||
{% for lexicon in public_lexicons %}
|
||||
{{ macros.dashboard_lexicon_item(lexicon) }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>No public games available.</p>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
{% set template_content_blocks = [self.main()] %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue