|
|
|
@ -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 |
|
|
|
|
|
|
|
|