Compare commits

..

No commits in common. "ce68bc9786ede233155b77bf6def9c59722396c9" and "343bb265361c3c6d19b80086f3d6a0bb99582db7" have entirely different histories.

3 changed files with 1 additions and 61 deletions

51
app.py
View File

@ -24,36 +24,6 @@ login_manager.login_view = 'login'
login_manager.init_app(app)
def rgb_to_hex(rgb_string):
# Split the RGB string into individual components
rgb_list = rgb_string.split(',')
# Convert each component to an integer
r = int(rgb_list[0])
g = int(rgb_list[1])
b = int(rgb_list[2])
# Convert the integers to hexadecimal strings and concatenate them
hex_string = "#{:02x}{:02x}{:02x}".format(r, g, b)
return hex_string
def hex_to_rgb(hex_string):
# Remove the '#' character if present
hex_string = hex_string.lstrip('#')
# Convert the hexadecimal string to integers
r = int(hex_string[0:2], 16)
g = int(hex_string[2:4], 16)
b = int(hex_string[4:6], 16)
# Create the RGB string
rgb_string = "{},{},{}".format(r, g, b)
return rgb_string
@login_manager.user_loader
def load_user(user_id):
return User.get(user_id)
@ -327,12 +297,12 @@ def habit_list_create():
@app.route('/profile')
@login_required
def profile():
print(current_user.name, current_user.email)
return render_template(
"profile.html",
name=current_user.name,
email=current_user.email,
profile_image_url=current_user.profile_image,
color = rgb_to_hex(current_user.heatmap_color),
title="Profil",
)
@ -354,7 +324,6 @@ def profile_change():
name=current_user.name,
email=current_user.email,
profile_image_url=current_user.profile_image,
color=rgb_to_hex(current_user.heatmap_color),
)
@ -499,7 +468,6 @@ def password_change():
name=current_user.name,
email=current_user.email,
profile_image_url=current_user.profile_image,
color=rgb_to_hex(current_user.heatmap_color),
)
@ -573,23 +541,6 @@ def upload_profile_image():
return redirect(url_for('profile'))
@app.route('/save_color', methods=['POST'])
def save_heatmap_color():
# Get the color value from the form
new_color = request.form['color']
current_user.heatmap_color = hex_to_rgb(new_color)
current_user.update()
# Back to profile
return render_template(
"profile.html",
name=current_user.name,
email=current_user.email,
profile_image_url=current_user.profile_image,
color=rgb_to_hex(current_user.heatmap_color),
)
@app.route('/check', methods=['POST'])
@login_required
def check_habit():

View File

@ -1,5 +1,3 @@
document.addEventListener("DOMContentLoaded", function() {
// Get elements
const profileImage = document.getElementById("profileImage");

View File

@ -31,15 +31,6 @@
Bearbeiten
</button>
</div>
<form id="colorForm" action="/save_color" method="POST">
<div class="ml-5" style="margin-left: 50px;">
<h5 class="card-title">Heatmap Farbe</h5>
<div style="display: flex; align-items: center;">
<input type="color" name="color" class="form-control form-control-color" id="exampleColorInput" value="{{color}}" title="Choose your color" style="margin-right: 10px;">
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</div>
</div>