Reformating 2

This commit is contained in:
Yapollon 2024-03-08 12:51:24 +01:00
parent 51509bb04f
commit 1d88041023

77
app.py
View File

@ -47,18 +47,53 @@ def inject_notifications():
return dict(notifications=[])
# Create a new route
@app.route('/')
def index():
if current_user.is_authenticated:
habit_lists = current_user.get_habitLists()
name = "Hallo " + current_user.name
heatmap_values, day = current_user.get_heatmap()
heatmap_color = current_user.heatmap_color
else:
habit_lists = []
name = "Bitte melde dich an."
heatmap_values = []
day = None
heatmap_color = None
# Sort habits by whether they have been checked today and then by slot
for habit_list in habit_lists:
habit_list.habits = sorted(habit_list.get_habits(), key=lambda habit: (habit.checked, habit.slot))
days = {"Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag",
"Friday": "Freitag", "Saturday": "Samstag", "Sunday": "Sonntag"}
date = datetime.datetime.now().strftime("%d.%m.%Y %H:%M ") + days[datetime.datetime.now().strftime("%A")]
return render_template(
'index.html',
title=name,
utc_dt=date,
habit_lists=habit_lists,
heatmap_values=heatmap_values,
day=day,
color=heatmap_color,
errors={}
)
###################### Login & Signup #####################
@app.route('/login')
@anonymous_required
def login():
return render_template('auth/login.html', errors={})
@app.route('/signup')
@anonymous_required
def signup():
return render_template('auth/signup.html', errors={})
@app.route('/login', methods=['POST'])
def login_post():
email = request.form.get('email')
@ -92,7 +127,6 @@ def login_post():
# Redirect to login page
return redirect(url_for('index'))
@app.route('/signup', methods=['POST'])
def signup_post():
email = request.form.get('email')
@ -128,7 +162,6 @@ def signup_post():
# Redirect to login page
return redirect(url_for('index'))
@app.route('/logout')
@login_required
def logout():
@ -136,43 +169,9 @@ def logout():
logout_user()
return redirect(url_for('index'))
###########################################################
# Create a new route
@app.route('/')
def index():
if current_user.is_authenticated:
habit_lists = current_user.get_habitLists()
name = "Hallo " + current_user.name
heatmap_values, day = current_user.get_heatmap()
heatmap_color = current_user.heatmap_color
else:
habit_lists = []
name = "Bitte melde dich an."
heatmap_values = []
day = None
heatmap_color = None
# Sort habits by whether they have been checked today and then by slot
for habit_list in habit_lists:
habit_list.habits = sorted(habit_list.get_habits(), key=lambda habit: (habit.checked, habit.slot))
days = {"Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag",
"Friday": "Freitag", "Saturday": "Samstag", "Sunday": "Sonntag"}
date = datetime.datetime.now().strftime("%d.%m.%Y %H:%M ") + days[datetime.datetime.now().strftime("%A")]
return render_template(
'index.html',
title=name,
utc_dt=date,
habit_lists=habit_lists,
heatmap_values=heatmap_values,
day=day,
color=heatmap_color,
errors={}
)
########################## Habit ##########################
@app.route('/habit')