Liste verlassen feature

This commit is contained in:
nikolaswollenberg 2024-03-07 18:39:15 +01:00
parent 69b3c257d1
commit 412666705c
2 changed files with 24 additions and 1 deletions

18
app.py
View File

@ -777,6 +777,24 @@ def add_user():
return redirect(url_for('index', habit_list=habit_list.id)) return redirect(url_for('index', habit_list=habit_list.id))
@app.route('/users-leave')
@login_required
def user_leave():
list_id = request.args.get('habit_list')
habit_list = HabitList.get(list_id)
if habit_list is None:
return {"error": "List not found"}
# Check if habit belongs to user
if current_user not in habit_list.get_users():
return {"error": "List does not belong to user"}
habit_list.remove_user(current_user.id)
return redirect(url_for("index"))
# Run the application # Run the application
if __name__ == '__main__': if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000, debug=True) app.run(host="0.0.0.0", port=5000, debug=True)

View File

@ -115,7 +115,12 @@
{% endif %} {% endif %}
</div> </div>
{% else %} {% else %}
<div class="col"></div> <div class="col">
<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">
<i class="bi bi-box-arrow-left" style="font-size: 24px;"></i>
</a>
</div>
{% endif %} {% endif %}
<div class="col-4"></div> <div class="col-4"></div>