Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
CTB
ctb-platform-backend-antigo
Commits
f2b841b0
Commit
f2b841b0
authored
May 14, 2019
by
Bruno Martin
Browse files
fix missing dependencies in user model
parent
4e0b7c18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
+17
-13
base_django_project/users/models.py
base_django_project/users/models.py
+17
-13
No files found.
base_django_project/users/models.py
View file @
f2b841b0
...
...
@@ -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.
pictur
e:
#
location = "/%s/%s" % (settings.STATIC_URL, 'img/avatar-default.png')
#
else:
#
location = "/%s/%s" % (settings.MEDIA_URL, self.
pictur
e)
#
return re.sub('/+', '/', location)
#
def get_picture_thumb_url(self,
#
options={'size': (150, 150), 'crop': 'scale'}):
#
try:
#
return get_thumbnailer(self.
pictur
e).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
.
imag
e
:
location
=
"/%s/%s"
%
(
settings
.
STATIC_URL
,
'img/avatar-default.png'
)
else
:
location
=
"/%s/%s"
%
(
settings
.
MEDIA_URL
,
self
.
imag
e
)
return
re
.
sub
(
'/+'
,
'/'
,
location
)
def
get_picture_thumb_url
(
self
,
options
=
{
'size'
:
(
150
,
150
),
'crop'
:
'scale'
}):
try
:
return
get_thumbnailer
(
self
.
imag
e
).
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
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment