Update the welcome page with actual numbers

This commit is contained in:
Gergely Polonkai 2018-07-17 09:52:50 +02:00
parent 43a90a237f
commit 372a1f756a
3 changed files with 16 additions and 6 deletions

View File

@ -164,6 +164,7 @@ class CalendarSocialApp(Flask):
""" """
from .calendar_system.gregorian import GregorianCalendar from .calendar_system.gregorian import GregorianCalendar
from .models import User, Event
try: try:
timestamp = datetime.fromtimestamp(float(request.args.get('date'))) timestamp = datetime.fromtimestamp(float(request.args.get('date')))
@ -175,10 +176,15 @@ class CalendarSocialApp(Flask):
if not current_user.is_authenticated: if not current_user.is_authenticated:
login_form_class = current_app.extensions['security'].login_form login_form_class = current_app.extensions['security'].login_form
login_form = login_form_class() login_form = login_form_class()
user_count = User.query.count()
event_count = Event.query.count()
return render_template('welcome.html', return render_template('welcome.html',
calendar=calendar, calendar=calendar,
user_only=False, user_only=False,
login_form=login_form) login_form=login_form,
user_count=user_count,
event_count=event_count)
return render_template('index.html', calendar=calendar, user_only=True) return render_template('index.html', calendar=calendar, user_only=True)

View File

@ -34,6 +34,10 @@ header > h1 > img {
color: #666666; color: #666666;
} }
.ui.centered.statistics {
justify-content: center;
}
.timezone-warning { .timezone-warning {
color: #e94a4a; color: #e94a4a;
} }

View File

@ -40,17 +40,17 @@
</div> </div>
<div class="four wide column"> <div class="four wide column">
<div class="ui statistics"> <div class="ui centered statistics">
<div class="statistic"> <div class="statistic">
<div class="value">12</div> <div class="value">{{ user_count }}</div>
<div class="label"> <div class="label">
{% trans count=12 %}user{% pluralize %}users{% endtrans %} {% trans count=user_count %}user{% pluralize %}users{% endtrans %}
</div> </div>
</div> </div>
<div class="statistic"> <div class="statistic">
<div class="value">87</div> <div class="value">{{ event_count }}</div>
<div class="label"> <div class="label">
{% trans count=87 %}event{% pluralize %}events{% endtrans %} {% trans count=event_count %}event{% pluralize %}events{% endtrans %}
</div> </div>
</div> </div>
</div> </div>