forked from gergely/calendar-social
Add the previous/next year/month links to the month view
This commit is contained in:
@@ -18,7 +18,7 @@ from datetime import datetime
|
||||
from functools import wraps
|
||||
import os
|
||||
|
||||
from flask import Flask, current_app, redirect, render_template, url_for
|
||||
from flask import Flask, current_app, redirect, render_template, request, url_for
|
||||
from flask_babelex import Babel, get_locale as babel_get_locale
|
||||
from flask_security import SQLAlchemyUserDatastore, current_user, login_required
|
||||
|
||||
@@ -40,8 +40,12 @@ def get_locale():
|
||||
|
||||
|
||||
def template_vars():
|
||||
now = datetime.utcnow()
|
||||
|
||||
return {
|
||||
'lang': babel_get_locale().language,
|
||||
'now': now,
|
||||
'now_ts': now.timestamp(),
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +98,12 @@ class CalendarSocialApp(Flask):
|
||||
if not current_user.is_authenticated:
|
||||
return render_template('welcome.html')
|
||||
|
||||
calendar = GregorianCalendar(datetime.utcnow().timestamp())
|
||||
try:
|
||||
timestamp = datetime.fromtimestamp(float(request.args.get('date')))
|
||||
except TypeError:
|
||||
timestamp = datetime.utcnow()
|
||||
|
||||
calendar = GregorianCalendar(timestamp.timestamp())
|
||||
|
||||
return render_template('index.html', calendar=calendar)
|
||||
|
||||
|
Reference in New Issue
Block a user