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))
|
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)
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
|||||||
from models.Habit import Habit
|
from models.Habit import Habit
|
||||||
from models.User import User
|
from models.User import User
|
||||||
from db.SQLiteClient import (create_habitList, get_habitList, get_habits, get_users, add_user, remove_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
|
@dataclass
|
||||||
@ -66,9 +66,6 @@ class HabitList:
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def accept_List(self, user:User):
|
|
||||||
accept_List(self.id, user.id)
|
|
||||||
|
|
||||||
# Removes a User from the HabitList
|
# Removes a User from the HabitList
|
||||||
def remove_user(self, user_id):
|
def remove_user(self, user_id):
|
||||||
remove_user(self.id, user_id)
|
remove_user(self.id, user_id)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
from db.SQLiteClient import (create_user, get_user, get_user_by_email, update_user, delete_user,
|
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):
|
class User(UserMixin):
|
||||||
@ -75,4 +75,7 @@ class User(UserMixin):
|
|||||||
heatmap.append(value)
|
heatmap.append(value)
|
||||||
heatmap.reverse()
|
heatmap.reverse()
|
||||||
day = 27-weekday
|
day = 27-weekday
|
||||||
return heatmap, day
|
return heatmap, day
|
||||||
|
|
||||||
|
def accept_List(self, HabitList_id):
|
||||||
|
accept_List(self.id, HabitList_id)
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user