From c90b261de3b26ab97727a46c3925185853cf2392 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 17 Jul 2018 10:04:58 +0200 Subject: [PATCH] [Refactor] Refactor the about page This makes it available to logged in users, too. --- calsocial/__init__.py | 53 +++++++++++++++++++++----------- calsocial/templates/base.html | 1 + calsocial/templates/welcome.html | 12 ++++++-- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/calsocial/__init__.py b/calsocial/__init__.py index a62514b..9e24926 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -155,36 +155,53 @@ class CalendarSocialApp(Flask): return self._timezone @staticmethod - @route('/') - def hello(): - """View for the main page - - This will display a welcome message for users not logged in; for others, their main - calendar view is displayed. - """ - + def _current_calendar(): from .calendar_system.gregorian import GregorianCalendar - from .models import User, Event try: timestamp = datetime.fromtimestamp(float(request.args.get('date'))) except TypeError: timestamp = datetime.utcnow() - calendar = GregorianCalendar(timestamp.timestamp()) + return GregorianCalendar(timestamp.timestamp()) + + @route('/about') + def about(self): + """View for the about page + """ + + from .models import User, Event + + calendar = self._current_calendar() if not current_user.is_authenticated: login_form_class = current_app.extensions['security'].login_form login_form = login_form_class() - user_count = User.query.count() - event_count = Event.query.count() + else: + login_form = None - return render_template('welcome.html', - calendar=calendar, - user_only=False, - login_form=login_form, - user_count=user_count, - event_count=event_count) + user_count = User.query.count() + event_count = Event.query.count() + + return render_template('welcome.html', + calendar=calendar, + user_only=False, + login_form=login_form, + user_count=user_count, + event_count=event_count) + + @route('/') + def hello(self): + """View for the main page + + This will display a welcome message for users not logged in; for others, their main + calendar view is displayed. + """ + + calendar = self._current_calendar() + + if not current_user.is_authenticated: + return self.about() return render_template('index.html', calendar=calendar, user_only=True) diff --git a/calsocial/templates/base.html b/calsocial/templates/base.html index f363a54..4d6bdbf 100644 --- a/calsocial/templates/base.html +++ b/calsocial/templates/base.html @@ -45,6 +45,7 @@ {% block content %}{% endblock %} {% block scripts %}{% endblock %} diff --git a/calsocial/templates/welcome.html b/calsocial/templates/welcome.html index 5e19372..640a9a2 100644 --- a/calsocial/templates/welcome.html +++ b/calsocial/templates/welcome.html @@ -4,6 +4,7 @@
+ {% if not current_user.is_authenticated %}

{% trans %}Login{% endtrans %}

{{ login_form.hidden_tag() }} @@ -13,18 +14,23 @@ {{ login_form.password }}
- {% if config.REGISTRATION_ENABLED %} + {% if config.REGISTRATION_ENABLED %}
{% trans %}Or{% endtrans %}
{% trans %}Register an account{% endtrans %} - {% endif %} + {% endif %}
+ {% endif %}

{% trans %}What is Calendar.social?{% endtrans %}

{% trans %}Calendar.social is a calendar app based on open protocols and free, open source software.{% endtrans %} {% trans %}It is decentralised like one of its counterparts, email.{% endtrans %}

+ {% if current_user.is_authenticated %} +
+ {% trans %}Go to your calendar{% endtrans %} + {% endif %}

{% trans %}Peek inside{% endtrans %}

@@ -33,7 +39,7 @@
-

{% trans %}Built for users in mind{% endtrans %}

+

{% trans %}Built with users in mind{% endtrans %}

{% trans %}From planning your appointments to organising large scale events Calendar.social can help with all your scheduling needs.{% endtrans %}