Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
c7f5ba58
Unverified
Commit
c7f5ba58
authored
Nov 29, 2016
by
Thom Wiggers
📐
Browse files
Check if nickname is set before saving preference
See
#157
parent
07d802fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/members/models.py
View file @
c7f5ba58
...
...
@@ -4,6 +4,7 @@ from functools import reduce
from
django.conf
import
settings
from
django.core
import
validators
from
django.core.exceptions
import
ValidationError
from
django.db
import
models
from
django.db.models
import
Q
from
django.urls
import
reverse
...
...
@@ -345,6 +346,17 @@ class Member(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'members:profile'
,
args
=
[
str
(
self
.
pk
)])
def
clean
(
self
):
super
().
clean
()
errors
=
{}
if
self
.
display_name_preference
in
(
'nickname'
,
'fullnick'
,
'nicklast'
):
if
not
self
.
nickname
:
errors
.
update
(
{
'nickname'
:
_
(
'You need to enter a nickname to use it as '
'display name'
)})
raise
ValidationError
(
errors
)
def
__str__
(
self
):
return
'{} ({})'
.
format
(
self
.
get_full_name
(),
self
.
user
.
username
)
...
...
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