forked from gergely/calendar-social
[Refactor] Refactor the about page
This makes it available to logged in users, too.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user