Add week and month view
This commit is contained in:
@@ -11,7 +11,7 @@ from app.models import Profile, Reading, db, User
|
||||
from app.forms import DeleteForm, LoginForm, ProfileForm, ReadingForm, SignupForm
|
||||
from flask_login import login_user, login_required, current_user, logout_user
|
||||
import base64
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import date, datetime, timedelta
|
||||
from PIL import Image
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
@@ -193,6 +193,14 @@ def dashboard():
|
||||
diastolic = [reading.diastolic for reading in readings]
|
||||
heart_rate = [reading.heart_rate for reading in readings]
|
||||
|
||||
# Group readings by date
|
||||
readings_by_date = {}
|
||||
for reading in readings:
|
||||
date_key = reading.timestamp.date()
|
||||
if date_key not in readings_by_date:
|
||||
readings_by_date[date_key] = []
|
||||
readings_by_date[date_key].append(reading)
|
||||
|
||||
# Render template
|
||||
return render_template(
|
||||
'dashboard.html',
|
||||
@@ -208,7 +216,10 @@ def dashboard():
|
||||
diastolic=diastolic,
|
||||
heart_rate=heart_rate,
|
||||
start_date=start_date,
|
||||
end_date=end_date
|
||||
end_date=end_date,
|
||||
readings_by_date=readings_by_date,
|
||||
date=date,
|
||||
timedelta=timedelta
|
||||
)
|
||||
|
||||
@main.route('/add-reading', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user