This commit is contained in:
Yapollon 2024-03-07 20:07:15 +01:00
commit ce68bc9786
4 changed files with 53 additions and 2 deletions

42
app.py
View File

@ -172,7 +172,7 @@ def index():
# Sort habits by whether they have been checked today and then by slot # Sort habits by whether they have been checked today and then by slot
for habit_list in habit_lists: 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", days = {"Monday": "Montag", "Tuesday": "Dienstag", "Wednesday": "Mittwoch", "Thursday": "Donnerstag",
"Friday": "Freitag", "Saturday": "Samstag", "Sunday": "Sonntag"} "Friday": "Freitag", "Saturday": "Samstag", "Sunday": "Sonntag"}
@ -844,6 +844,46 @@ def user_leave():
habit_list.remove_user(current_user.id) habit_list.remove_user(current_user.id)
return redirect(url_for("index")) 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 # Run the application
if __name__ == '__main__': if __name__ == '__main__':

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -115,12 +115,22 @@
{% endif %} {% endif %}
</div> </div>
{% else %} {% else %}
<div class="col"> <div class="row">
<a class="me-5" href="/users-leave?habit_list={{habit_list.id}}" style="width: 40px; height: 40px; min-height: 3em;" <a class="me-5" href="/users-leave?habit_list={{habit_list.id}}" style="width: 40px; height: 40px; min-height: 3em;"
data-toggle="tooltip" data-placement="top" title="Liste verlassen"> data-toggle="tooltip" data-placement="top" title="Liste verlassen">
<i class="bi bi-box-arrow-left" style="font-size: 24px;"></i> <i class="bi bi-box-arrow-left" style="font-size: 24px;"></i>
</a> </a>
<div class="col">
<div class="avatar-stack">
{% for user in habit_list.get_users() %}
{% if current_user.id != user.id %}
<img class="avatar" src="/{{user.profile_image}}" data-toggle="tooltip" data-placement="top"
title="{{user.name}}"/>
{% endif %}
{% endfor %}
</div>
</div> </div>
{% endif %} {% endif %}
<div class="col-4"></div> <div class="col-4"></div>

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" > <meta name="viewport" content="width=device-width, initial-scale=1" >
<title>{{ title }} - HabitTracker</title> <title>{{ title }} - HabitTracker</title>
<link rel="icon" href="/static/favicon.ico">
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" type="text/css" href="../../static/css/background.css"> <link rel="stylesheet" type="text/css" href="../../static/css/background.css">