Reformating 2
This commit is contained in:
parent
51509bb04f
commit
1d88041023
77
app.py
77
app.py
@ -47,18 +47,53 @@ def inject_notifications():
|
|||||||
return dict(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')
|
@app.route('/login')
|
||||||
@anonymous_required
|
@anonymous_required
|
||||||
def login():
|
def login():
|
||||||
return render_template('auth/login.html', errors={})
|
return render_template('auth/login.html', errors={})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/signup')
|
@app.route('/signup')
|
||||||
@anonymous_required
|
@anonymous_required
|
||||||
def signup():
|
def signup():
|
||||||
return render_template('auth/signup.html', errors={})
|
return render_template('auth/signup.html', errors={})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/login', methods=['POST'])
|
@app.route('/login', methods=['POST'])
|
||||||
def login_post():
|
def login_post():
|
||||||
email = request.form.get('email')
|
email = request.form.get('email')
|
||||||
@ -92,7 +127,6 @@ def login_post():
|
|||||||
# Redirect to login page
|
# Redirect to login page
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/signup', methods=['POST'])
|
@app.route('/signup', methods=['POST'])
|
||||||
def signup_post():
|
def signup_post():
|
||||||
email = request.form.get('email')
|
email = request.form.get('email')
|
||||||
@ -128,7 +162,6 @@ def signup_post():
|
|||||||
# Redirect to login page
|
# Redirect to login page
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
@login_required
|
@login_required
|
||||||
def logout():
|
def logout():
|
||||||
@ -136,43 +169,9 @@ def logout():
|
|||||||
logout_user()
|
logout_user()
|
||||||
|
|
||||||
return redirect(url_for('index'))
|
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 ##########################
|
########################## Habit ##########################
|
||||||
@app.route('/habit')
|
@app.route('/habit')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user