mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Merge branch 'remove_profil_image' into 'dev'
Remove profil image See merge request re2o/re2o!565
This commit is contained in:
commit
e8d4cbf9ed
7 changed files with 22 additions and 50 deletions
|
@ -216,9 +216,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
{% if request_user.is_authenticated %}
|
||||
<div class="panel-heading">
|
||||
<h4>{{ request_user.name }} {{ request_user.surname }}</h4>
|
||||
{% if request_user.image_url %}
|
||||
<img src="{{ request_user.image_url }}" height="42" width="42" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
|
|
|
@ -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",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -45,7 +45,6 @@ class UserSerializer(NamespacedHMSerializer):
|
|||
"state",
|
||||
"registered",
|
||||
"telephone",
|
||||
"profile_image",
|
||||
"solde",
|
||||
"access",
|
||||
"end_access",
|
||||
|
@ -78,7 +77,6 @@ class ClubSerializer(NamespacedHMSerializer):
|
|||
"state",
|
||||
"registered",
|
||||
"telephone",
|
||||
"profile_image",
|
||||
"solde",
|
||||
"room",
|
||||
"access",
|
||||
|
@ -114,7 +112,6 @@ class AdherentSerializer(NamespacedHMSerializer):
|
|||
"state",
|
||||
"registered",
|
||||
"telephone",
|
||||
"profile_image",
|
||||
"room",
|
||||
"solde",
|
||||
"access",
|
||||
|
|
|
@ -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",
|
||||
|
|
19
users/migrations/0094_remove_user_profile_image.py
Normal file
19
users/migrations/0094_remove_user_profile_image.py
Normal file
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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."))
|
||||
|
||||
|
|
Loading…
Reference in a new issue