From 4706ce3f9098b003984bfcbab69e1425e743122d Mon Sep 17 00:00:00 2001
From: abdelrahman390 <88147091+abdelrahman390@users.noreply.github.com>
Date: Sun, 11 May 2025 01:48:59 +0300
Subject: [PATCH 1/3] Fix avatar image bug. Fixes #586
---
web/templates/profile.html | 85 ++++++++++++++++++++++++--------------
1 file changed, 54 insertions(+), 31 deletions(-)
diff --git a/web/templates/profile.html b/web/templates/profile.html
index 2d460d1c2..976e4d4dc 100644
--- a/web/templates/profile.html
+++ b/web/templates/profile.html
@@ -30,37 +30,39 @@
Profile
Teacher
{% endif %}
-
-
- {% if user.profile.custom_avatar %}
-
{{ form.avatar.as_hidden }}
@@ -529,6 +527,31 @@
My Badges
+
{% if discount_codes %}
Your Discount Codes
From 81d559cea39387786f721018243ea9857e5f722c Mon Sep 17 00:00:00 2001
From: abdelrahman390 <88147091+abdelrahman390@users.noreply.github.com>
Date: Sun, 11 May 2025 02:14:25 +0300
Subject: [PATCH 2/3] edited
---
web/templates/profile.html | 6 ++----
web/views.py | 2 ++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/web/templates/profile.html b/web/templates/profile.html
index 976e4d4dc..57cd10ad7 100644
--- a/web/templates/profile.html
+++ b/web/templates/profile.html
@@ -539,11 +539,9 @@ My Badges
mainForm.addEventListener('submit', function(e) {
e.preventDefault();
- const formData = new FormData(mainForm);
-
- // Only include avatar if it was changed
if (sessionStorage.getItem('avatarChanged') !== 'true') {
- formData.delete('avatar');
+ // disable the file input so the browser will not include it
+ avatarInput.disabled = true;
}
// Reset the flag
diff --git a/web/views.py b/web/views.py
index c7ed4d433..5749ccdb7 100644
--- a/web/views.py
+++ b/web/views.py
@@ -528,6 +528,8 @@ def profile(request):
if request.method == "POST":
form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user)
if form.is_valid():
+ print("POST data:", request.POST) # Print form field data
+ print("FILES data:", request.FILES) # Print uploaded files
form.save() # Save the form data
request.user.profile.refresh_from_db() # Refresh to load updated profile
messages.success(request, "Profile updated successfully!")
From bd435f71c9ed760f67989fc7920444583bae5a90 Mon Sep 17 00:00:00 2001
From: abdelrahman390 <88147091+abdelrahman390@users.noreply.github.com>
Date: Sun, 11 May 2025 02:20:23 +0300
Subject: [PATCH 3/3] final
---
web/views.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/web/views.py b/web/views.py
index 5749ccdb7..c7ed4d433 100644
--- a/web/views.py
+++ b/web/views.py
@@ -528,8 +528,6 @@ def profile(request):
if request.method == "POST":
form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user)
if form.is_valid():
- print("POST data:", request.POST) # Print form field data
- print("FILES data:", request.FILES) # Print uploaded files
form.save() # Save the form data
request.user.profile.refresh_from_db() # Refresh to load updated profile
messages.success(request, "Profile updated successfully!")