diff --git a/app.py b/app.py index 7387f4b..e6fcbce 100644 --- a/app.py +++ b/app.py @@ -125,9 +125,11 @@ def index(): if current_user.is_authenticated: habit_lists = current_user.get_habitLists() name = "Hallo " + current_user.name + heatmap_values = current_user.get_heatmap() else: habit_lists = [] name = "Bitte melde dich an." + heatmap_values = [] # Sort habits by whether they have been checked today and then by slot for habit_list in habit_lists: @@ -138,7 +140,7 @@ def index(): title=name, utc_dt=datetime.datetime.now().strftime("%d.%m.%Y %H:%M %A"), habit_lists=habit_lists, - heatmap_values=current_user.get_heatmap(), + heatmap_values=heatmap_values, errors={}, ) @@ -296,6 +298,7 @@ def profile_change(): profile_image_url=current_user.profile_image, ) + @app.route('/check_password', methods=['POST']) @login_required def check_password(): @@ -307,6 +310,7 @@ def check_password(): else: return jsonify({"valid": False}) + @app.route('/password', methods=['POST']) @login_required def password_change(): @@ -325,9 +329,11 @@ def password_change(): profile_image_url=current_user.profile_image, ) + UPLOAD_FOLDER = 'static/profile_images/' # Folder to store profile images app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + def save_profile_image(image_file): filename = image_file.filename if '.' not in filename: @@ -368,6 +374,7 @@ def save_profile_image(image_file): image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename) image.save(image_path, 'JPEG', quality=100) + @app.route('/upload', methods=['POST']) def upload_profile_image(): if 'file' not in request.files: @@ -423,6 +430,7 @@ def check_habit(): "percentage": habit.percentage, } + @app.route('/delete', methods=['POST']) @login_required def delete_habit(): @@ -440,10 +448,11 @@ def delete_habit(): habit.delete() return {} + @app.route('/reorder', methods=['POST']) @login_required def reorder_habits(): - new_index = request.get_json()["newIndex"]+1 + new_index = request.get_json()["newIndex"] + 1 habit = Habit.get(request.get_json()["habitId"]) if habit is None: @@ -461,4 +470,4 @@ def reorder_habits(): # Run the application if __name__ == '__main__': - app.run(port=5000, debug=True) \ No newline at end of file + app.run(port=5000, debug=True) diff --git a/db/SQLiteClient.py b/db/SQLiteClient.py index fb183f3..28cb035 100644 --- a/db/SQLiteClient.py +++ b/db/SQLiteClient.py @@ -27,7 +27,7 @@ def create_user_profile_image(user_id): return relative_destination_path -def create_user(name: str, email: str, password: str, profile_image:str = None): +def create_user(name: str, email: str, password: str, profile_image: str = None): password = hashlib.sha256(password.encode()).hexdigest() now = datetime.now().isoformat() query = (f"INSERT INTO users (name, email, password, profile_image, created_at, updated_at) VALUES " diff --git a/templates/components/habit_lists.html b/templates/components/habit_lists.html new file mode 100644 index 0000000..fe02f15 --- /dev/null +++ b/templates/components/habit_lists.html @@ -0,0 +1,94 @@ +