Fixed checked habit sorting
This commit is contained in:
parent
8094bd7865
commit
ece973ad28
42
app.py
42
app.py
@ -142,7 +142,7 @@ def index():
|
||||
|
||||
# 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: (not habit.checked, habit.slot))
|
||||
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"}
|
||||
@ -795,6 +795,46 @@ def user_leave():
|
||||
habit_list.remove_user(current_user.id)
|
||||
return redirect(url_for("index"))
|
||||
|
||||
@app.route('/accept-list', methods=['POST'])
|
||||
@login_required
|
||||
def accept_list():
|
||||
list_id = request.form.get('list_id')
|
||||
habit_list = HabitList.get(int(list_id))
|
||||
|
||||
users = habit_list.get_users()
|
||||
# Check if user is part of the list
|
||||
found = False
|
||||
for user in users:
|
||||
if user.id == habit_list.id:
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
return redirect(url_for("index"))
|
||||
|
||||
current_user.accept_List(list_id)
|
||||
return {}
|
||||
|
||||
@app.route('/deny-list', methods=['POST'])
|
||||
@login_required
|
||||
def deny_list():
|
||||
list_id = request.form.get('list_id')
|
||||
habit_list = HabitList.get(int(list_id))
|
||||
|
||||
users = habit_list.get_users()
|
||||
# Check if user is part of the list
|
||||
found = False
|
||||
for user in users:
|
||||
if user.id == habit_list.id:
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
return redirect(url_for("index"))
|
||||
|
||||
habit_list.remove_user(current_user.id)
|
||||
return {}
|
||||
|
||||
|
||||
# Run the application
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user