Commit f2b841b0 authored by Bruno Martin's avatar Bruno Martin
Browse files

fix missing dependencies in user model

parent 4e0b7c18
......@@ -3,9 +3,13 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from easy_thumbnails.files import get_thumbnailer
from easy_thumbnails.exceptions import InvalidImageFormatError
from allauth.socialaccount.models import SocialAccount
from cities_light.models import City, Region, Country
import hashlib
import re
class PoliticalFront(models.Model):
......@@ -351,19 +355,19 @@ class User(AbstractUser):
except Group.DoesNotExist:
pass
# def get_picture_url(self):
# if not self.picture:
# location = "/%s/%s" % (settings.STATIC_URL, 'img/avatar-default.png')
# else:
# location = "/%s/%s" % (settings.MEDIA_URL, self.picture)
# return re.sub('/+', '/', location)
# def get_picture_thumb_url(self,
# options={'size': (150, 150), 'crop': 'scale'}):
# try:
# return get_thumbnailer(self.picture).get_thumbnail(options).url
# except InvalidImageFormatError as e:
# return str(settings.STATIC_URL + 'img/avatar-default.png')
def get_picture_url(self):
if not self.image:
location = "/%s/%s" % (settings.STATIC_URL, 'img/avatar-default.png')
else:
location = "/%s/%s" % (settings.MEDIA_URL, self.image)
return re.sub('/+', '/', location)
def get_picture_thumb_url(self,
options={'size': (150, 150), 'crop': 'scale'}):
try:
return get_thumbnailer(self.image).get_thumbnail(options).url
except InvalidImageFormatError:
return str(settings.STATIC_URL + 'img/avatar-default.png')
def email_user(self, subject, message, from_email=None):
send_mail(subject, message, from_email, [self.email])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment