diff --git a/app.py b/app.py index a656e71..e6a9542 100644 --- a/app.py +++ b/app.py @@ -849,6 +849,14 @@ def save_heatmap_color(): profile_image_url=current_user.profile_image, color=current_user.heatmap_color, ) + +@app.route('/delete_account', methods=['POST']) +@login_required +def delete_account(): + os.remove(current_user.profile_image) + current_user.delete() + + return redirect(url_for('index')) ########################################################### diff --git a/models/HabitList.py b/models/HabitList.py index b04f07c..e64ab56 100644 --- a/models/HabitList.py +++ b/models/HabitList.py @@ -34,6 +34,8 @@ class HabitList: if len(get_users(self.id)) > 1: self.remove_user(user_id) else: + for habit in self.get_habits(): + habit.delete() delete_habitList(self.id) diff --git a/static/css/heatmap.css b/static/css/heatmap.css index 120b61a..fac875d 100644 --- a/static/css/heatmap.css +++ b/static/css/heatmap.css @@ -1,73 +1,73 @@ - #heatmap { - display: grid; - grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */ - gap: 5px; - width: 100%; - table-layout: fixed; - } +#heatmap { + display: grid; + grid-template-columns: repeat(7, 0fr); /* 7 Tage in einer Woche */ + gap: 5px; + width: 100%; + table-layout: fixed; +} +.day { + width: 50px; + height: 50px; + border: 1px solid #ccc; + display: flex; + align-items: center; + justify-content: center; + table-layout: fixed; +} + +@media (max-width: 1400px) { + .day { + width: 40px; + height: 40px; + } +} + +@media (max-width: 1200px) { + .day { + width: 35px; + height: 35px; + } +} + +@media (max-width: 992px) { + .day { + width: 30px; + height: 30px; + } +} + +@media (max-width: 767px) { .day { width: 50px; height: 50px; - border: 1px solid #ccc; - display: flex; - align-items: center; - justify-content: center; - table-layout: fixed; } +} - @media (max-width: 1400px) { - .day { - width: 40px; - height: 40px; - } +@media (max-width: 450px) { + .day { + width: 40px; + height: 40px; } +} - @media (max-width: 1200px) { - .day { - width: 35px; - height: 35px; - } +@media (max-width: 400px) { + .day { + width: 35px; + height: 35px; } +} - @media (max-width: 992px) { - .day { - width: 30px; - height: 30px; - } +@media (max-width: 350px) { + .day { + width: 30px; + height: 30px; } +} - @media (max-width: 767px) { - .day { - width: 50px; - height: 50px; - } +@media (max-width: 300px) { + .day { + width: 25px; + height: 25px; } - - @media (max-width: 450px) { - .day { - width: 40px; - height: 40px; - } - } - - @media (max-width: 400px) { - .day { - width: 35px; - height: 35px; - } - } - - @media (max-width: 350px) { - .day { - width: 30px; - height: 30px; - } - } - - @media (max-width: 300px) { - .day { - width: 25px; - height: 25px; - } - } \ No newline at end of file +} \ No newline at end of file diff --git a/static/script/script-index.js b/static/script/script-index.js index 0029637..63791db 100644 --- a/static/script/script-index.js +++ b/static/script/script-index.js @@ -21,7 +21,7 @@ function createHeatmap(data, day) { dayElement.classList.add('day'); dayElement.style.backgroundColor = `rgba(${color}, ${opacity})`; if (day === i * 7 + j){ - dayElement.style.borderColor = `rgba(255, 0, 0)`; + dayElement.style.borderColor = `rgba(0, 0, 0)`; dayElement.style.borderWidth = "2px"; } heatmapContainer.appendChild(dayElement); diff --git a/static/script/script-profile.js b/static/script/script-profile.js index cb04af7..71a00ca 100644 --- a/static/script/script-profile.js +++ b/static/script/script-profile.js @@ -14,6 +14,11 @@ document.addEventListener("DOMContentLoaded", function() { const submitPasswordChangeButton = document.getElementById("submitPasswordChange"); + const DeleteAccountButton = document.getElementById('deleteAccountButton') + const confirmDeleteModal = new bootstrap.Modal(document.getElementById('confirmDeleteModal')); + const ConfirmDeleteButton = document.getElementById('confirmDeleteButton') + const deleteAccountForm = document.getElementById('deleteAccountForm') + // Open file input when profile image is clicked profileImageOverlay.addEventListener("click", function() { profileImageInput.click(); @@ -37,9 +42,6 @@ document.addEventListener("DOMContentLoaded", function() { // Add event listener to edit button to open modal editButton.addEventListener("click", function() { editModal.show(); - // document.getElementById("newName").value = "{{ name }}"; - // document.getElementById("newEmail").value = "{{ email }}"; - // document.getElementById("password").value = ""; }); // Add event listener to save changes button to submit form @@ -182,4 +184,14 @@ document.addEventListener("DOMContentLoaded", function() { return isValid; } + + // Add event listener to edit button to open modal + DeleteAccountButton.addEventListener("click", function() { + confirmDeleteModal.show(); + }); + + //Submit delete account form + ConfirmDeleteButton.addEventListener('click', function () { + deleteAccountForm.submit(); + }); }); \ No newline at end of file diff --git a/templates/profile.html b/templates/profile.html index 01dc987..cbda5ea 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -43,7 +43,7 @@ - +
Passwort ändern
@@ -63,8 +63,40 @@
+ - +
+
Konto löschen
+
+ +
+
+
+ + + + + + @@ -72,7 +104,7 @@