diff --git a/templates/base.html b/templates/base.html
index 3ef66593..559e12a0 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -216,9 +216,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if request_user.is_authenticated %}
{{ request_user.name }} {{ request_user.surname }}
- {% if request_user.image_url %}
-
- {% endif %}
diff --git a/users/admin.py b/users/admin.py
index bc4d9e61..e00f8e1f 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -222,7 +222,7 @@ class AdherentAdmin(VersionAdmin, BaseUserAdmin):
(None, {"fields": ("pseudo",)}),
(
"Personal info",
- {"fields": ("surname", "name", "email", "school", "shell", "uid_number", "profile_image", "password1", "password2")},
+ {"fields": ("surname", "name", "email", "school", "shell", "uid_number", "password1", "password2")},
),
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
@@ -240,7 +240,6 @@ class AdherentAdmin(VersionAdmin, BaseUserAdmin):
"school",
"password1",
"password2",
- "profile_image",
"is_superuser",
),
},
@@ -279,7 +278,7 @@ class ClubAdmin(VersionAdmin, BaseUserAdmin):
(None, {"fields": ("pseudo",)}),
(
"Personal info",
- {"fields": ("surname", "email", "school", "shell", "uid_number", "profile_image", "password1", "password2")},
+ {"fields": ("surname", "email", "school", "shell", "uid_number", "password1", "password2")},
),
)
@@ -295,7 +294,6 @@ class ClubAdmin(VersionAdmin, BaseUserAdmin):
"school",
"password1",
"password2",
- "profile_image",
"is_superuser",
),
},
diff --git a/users/forms.py b/users/forms.py
index 8a010c3e..570abcb0 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -330,8 +330,6 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
self.fields["email"].label = _("Email address")
self.fields["school"].label = _("School")
self.fields["comment"].label = _("Comment")
- if "profile_image" in self.fields:
- self.fields["profile_image"].label = _("Profile Image")
if "room" in self.fields:
self.fields["room"].label = _("Room")
self.fields["room"].empty_label = _("No room")
@@ -347,7 +345,6 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"school",
"comment",
"telephone",
- "profile_image",
"room",
]
@@ -566,7 +563,6 @@ class AdherentEditForm(AdherentForm):
"school",
"comment",
"telephone",
- "profile_image",
"room",
"shell",
"gpg_fingerprint",
@@ -606,7 +602,6 @@ class ClubForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
"room",
"email",
"telephone",
- "profile_image",
"email",
"shell",
"mailing",
diff --git a/users/migrations/0094_remove_user_profile_image.py b/users/migrations/0094_remove_user_profile_image.py
new file mode 100644
index 00000000..18519eee
--- /dev/null
+++ b/users/migrations/0094_remove_user_profile_image.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.29 on 2020-10-22 13:33
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0093_user_profile_image'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='user',
+ name='profile_image',
+ ),
+ ]
diff --git a/users/models.py b/users/models.py
index f67a30da..e6bb65c1 100755
--- a/users/models.py
+++ b/users/models.py
@@ -221,7 +221,6 @@ class User(
legacy_uid: Optionnal legacy user id
shortcuts_enabled : Option for js shortcuts
email_change_date: Date of the last email change
- profile_image: Optionnal image profile
"""
STATE_ACTIVE = 0
@@ -306,7 +305,6 @@ class User(
verbose_name=_("enable shortcuts on Re2o website"), default=True
)
email_change_date = models.DateTimeField(auto_now_add=True)
- profile_image = models.ImageField(upload_to='profile_image', blank=True)
USERNAME_FIELD = "pseudo"
REQUIRED_FIELDS = ["surname", "email"]
@@ -652,20 +650,6 @@ class User(
)
return somme_credit - somme_debit
- @property
- def image_url(self):
- """Shortcuts, returns the url associated with the user profile_image,
- if an image has been set.
-
- Parameters:
- self (user instance): user to return infos
-
- Returns:
- profile_image_url (url) : Returns the url of this profile image.
- """
- if self.profile_image and hasattr(self.profile_image, 'url'):
- return self.profile_image.url
-
@cached_property
def email_address(self):
"""Shortcuts, returns all the email addresses (queryset) associated
@@ -1976,19 +1960,6 @@ class User(
self.clean_pseudo(*args, **kwargs)
self.clean_email(*args, **kwargs)
-
- def save(self, *args, **kwargs):
- if self.profile_image:
- im = Image.open(self.profile_image)
- output = BytesIO()
- im = im.resize( (100,100) )
- if im.mode in ("RGBA", "P"):
- im = im.convert("RGB")
- im.save(output, format='JPEG', quality=100)
- output.seek(0)
- self.profile_image = InMemoryUploadedFile(output,'ImageField', "%s.jpg" %self.profile_image.name.split('.')[0], 'image/jpeg', sys.getsizeof(output), None)
- super(User,self).save(*args, **kwargs)
-
def __str__(self):
return self.pseudo
diff --git a/users/views.py b/users/views.py
index ffa1344e..e0478783 100644
--- a/users/views.py
+++ b/users/views.py
@@ -277,11 +277,6 @@ def edit_info(request, user, userid):
if user_form.is_valid():
if user_form.changed_data:
user = user_form.save(commit=False)
- former_user = Adherent.objects.get(pseudo=user.pseudo)
- if former_user.profile_image:
- if (user.profile_image and user.profile_image.url != former_user.profile_image.url) or (not user.profile_image):
- former_image = settings.BASE_DIR+former_user.profile_image.url
- os.remove(former_image)
user = user_form.save()
messages.success(request, _("The user was edited."))