some changes i had on my local folder
This commit is contained in:
Yapollon 2024-03-25 12:41:01 +01:00
parent e57cc58b3e
commit f53b3c4059
3 changed files with 12 additions and 13 deletions

16
app.py
View File

@ -786,8 +786,7 @@ def password_change():
current_user.update() current_user.update()
# Back to profile # Back to profile
return render_template( return render_template("profile.html",
"profile.html",
name=current_user.name, name=current_user.name,
email=current_user.email, email=current_user.email,
profile_image_url=current_user.profile_image, profile_image_url=current_user.profile_image,
@ -837,7 +836,7 @@ def save_profile_image(image_file):
# Save the modified frames as a new GIF # Save the modified frames as a new GIF
output_gif_path = os.path.join(app.config['UPLOAD_FOLDER'], filename.replace(".jpg", ".gif")) output_gif_path = os.path.join(app.config['UPLOAD_FOLDER'], filename.replace(".jpg", ".gif"))
processed_frames[0].save(output_gif_path, save_all=True, append_images=processed_frames[1:], loop=0) processed_frames[0].save(output_gif_path, save_all=True, append_images=processed_frames[1:], loop=0)
current_user.profile_image = output_gif_path return output_gif_path
else: else:
# Process single image # Process single image
processed_image = process_frame(image, size=(256, 256)) processed_image = process_frame(image, size=(256, 256))
@ -846,10 +845,7 @@ def save_profile_image(image_file):
# Save the processed image # Save the processed image
image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename.replace(".gif", ".jpg")) image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename.replace(".gif", ".jpg"))
processed_image.save(image_path, 'JPEG', quality=100) processed_image.save(image_path, 'JPEG', quality=100)
current_user.profile_image = image_path return image_path
# Update user profile
current_user.update()
@app.route('/upload', methods=['POST']) @app.route('/upload', methods=['POST'])
@login_required @login_required
@ -858,7 +854,11 @@ def upload_profile_image():
return 'No file part' return 'No file part'
file = request.files['file'] file = request.files['file']
save_profile_image(file) image_path = save_profile_image(file)
# Update the User
current_user.profile_image = image_path
current_user.update()
# Back to profile # Back to profile
return redirect(url_for('profile')) return redirect(url_for('profile'))

View File

@ -78,18 +78,18 @@ class User(UserMixin):
# Returns all heatmap-values from the last 28 days # Returns all heatmap-values from the last 28 days
def get_heatmap(self) -> tuple: def get_heatmap(self) -> tuple:
# get current day of week as integer. monday is 0 and sunday is 6 # get current day of week as integer. monday is 0 and sunday is 6
weekday = datetime.today().weekday() weekday = 6 - datetime.today().weekday()
heatmap = [100] heatmap = [100]
# append the heatmap values of the current week # append the heatmap values of the current week
for day in range(0, 6-weekday): for day in range(0, weekday):
heatmap.append(0) heatmap.append(0)
for day in range (0, 28-(6-weekday)): for day in range (0, 28-weekday):
value = get_heatmap_value(self.id, day) value = get_heatmap_value(self.id, day)
heatmap.append(value) heatmap.append(value)
heatmap.reverse() heatmap.reverse()
day = 27-(6-weekday) day = 27-weekday
return heatmap, day return heatmap, day
def accept_List(self, HabitList_id): def accept_List(self, HabitList_id):

View File

@ -50,7 +50,6 @@ document.addEventListener("DOMContentLoaded", function() {
validateForm() validateForm()
.then(isValid => { .then(isValid => {
if (isValid) { if (isValid) {
console.log("Validated 2");
editForm.submit(); editForm.submit();
} }
}) })