Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8094bd7865
18
app.py
18
app.py
@ -778,6 +778,24 @@ def add_user():
|
||||
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
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
|
||||
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
||||
from models.Habit import Habit
|
||||
from models.User import User
|
||||
from db.SQLiteClient import (create_habitList, get_habitList, get_habits, get_users, add_user, remove_user,
|
||||
update_habitList, delete_habitList, accept_List)
|
||||
update_habitList, delete_habitList)
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -66,9 +66,6 @@ class HabitList:
|
||||
else:
|
||||
return None
|
||||
|
||||
def accept_List(self, user:User):
|
||||
accept_List(self.id, user.id)
|
||||
|
||||
# Removes a User from the HabitList
|
||||
def remove_user(self, user_id):
|
||||
remove_user(self.id, user_id)
|
||||
|
||||
@ -2,7 +2,7 @@ from datetime import datetime
|
||||
|
||||
from flask_login import UserMixin
|
||||
from db.SQLiteClient import (create_user, get_user, get_user_by_email, update_user, delete_user,
|
||||
get_habitLists, get_heatmap_value)
|
||||
get_habitLists, get_heatmap_value, accept_List)
|
||||
|
||||
|
||||
class User(UserMixin):
|
||||
@ -76,3 +76,6 @@ class User(UserMixin):
|
||||
heatmap.reverse()
|
||||
day = 27-weekday
|
||||
return heatmap, day
|
||||
|
||||
def accept_List(self, HabitList_id):
|
||||
accept_List(self.id, HabitList_id)
|
||||
|
||||
@ -115,7 +115,12 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% 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 %}
|
||||
|
||||
<div class="col-4"></div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user