diff --git a/app.py b/app.py index 64dac6e..bdb1ccf 100644 --- a/app.py +++ b/app.py @@ -172,7 +172,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"} @@ -844,6 +844,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__': diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..2ca6299 Binary files /dev/null and b/static/favicon.ico differ diff --git a/templates/components/habit_lists.html b/templates/components/habit_lists.html index bddfd67..1643dbd 100644 --- a/templates/components/habit_lists.html +++ b/templates/components/habit_lists.html @@ -115,12 +115,22 @@ {% endif %} {% else %} -
+
+
+
+ {% for user in habit_list.get_users() %} + {% if current_user.id != user.id %} + + {% endif %} + {% endfor %} +
+ {% endif %}
diff --git a/templates/layouts/main.html b/templates/layouts/main.html index 7129d89..da09360 100644 --- a/templates/layouts/main.html +++ b/templates/layouts/main.html @@ -4,6 +4,7 @@ {{ title }} - HabitTracker +