Compare commits

..

No commits in common. "5251a80d02af954c624f8f4288291c57e4d04b6c" and "ff670abc1dbfab3963fcf5ddd133f64bf2c22687" have entirely different histories.

3 changed files with 13 additions and 12 deletions

16
app.py
View File

@ -780,7 +780,8 @@ def password_change():
current_user.update() current_user.update()
# Back to profile # Back to profile
return render_template("profile.html", return render_template(
"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,
@ -830,7 +831,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)
return output_gif_path current_user.profile_image = 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))
@ -839,7 +840,10 @@ 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)
return image_path current_user.profile_image = image_path
# Update user profile
current_user.update()
@app.route('/upload', methods=['POST']) @app.route('/upload', methods=['POST'])
@login_required @login_required
@ -848,11 +852,7 @@ def upload_profile_image():
return 'No file part' return 'No file part'
file = request.files['file'] file = request.files['file']
image_path = save_profile_image(file) 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

@ -77,18 +77,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 = 6 - datetime.today().weekday() weekday = 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, weekday): for day in range(0, 6-weekday):
heatmap.append(0) heatmap.append(0)
for day in range (0, 28-weekday): for day in range (0, 28-(6-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-weekday day = 27-(6-weekday)
return heatmap, day return heatmap, day
def accept_List(self, HabitList_id): def accept_List(self, HabitList_id):

View File

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