SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
006265f8
Commit
006265f8
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
forbid users from changing to another's email
fixes
#203
parent
e4ef2dd8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/scipost/forms.py
+20
-3
20 additions, 3 deletions
scipost_django/scipost/forms.py
with
20 additions
and
3 deletions
scipost_django/scipost/forms.py
+
20
−
3
View file @
006265f8
...
@@ -335,6 +335,23 @@ class UpdateUserDataForm(forms.ModelForm):
...
@@ -335,6 +335,23 @@ class UpdateUserDataForm(forms.ModelForm):
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
"
last_name
"
].
widget
.
attrs
[
"
readonly
"
]
=
True
self
.
fields
[
"
last_name
"
].
widget
.
attrs
[
"
readonly
"
]
=
True
def
clean_email
(
self
):
if
email
:
=
self
.
cleaned_data
.
get
(
"
email
"
):
other_users
=
User
.
objects
.
filter
(
email
=
email
).
exclude
(
pk
=
self
.
instance
.
pk
)
if
other_users
.
exists
():
self
.
add_error
(
"
email
"
,
"
This email is already in use by another user.
"
"
If it belongs to you and you have forgotten your credentials,
"
"
use the email in place of your username and/or reset your password.
"
,
)
# other_profiles = Profile.objects.filter(emails__email=email).exclude(
# user=self.instance
# )
# if other_profiles.exists():
return
email
or
self
.
instance
.
email
def
clean_last_name
(
self
):
def
clean_last_name
(
self
):
"""
Make sure the `last_name` cannot be saved via this form.
"""
"""
Make sure the `last_name` cannot be saved via this form.
"""
instance
=
getattr
(
self
,
"
instance
"
,
None
)
instance
=
getattr
(
self
,
"
instance
"
,
None
)
...
@@ -404,9 +421,9 @@ class UpdatePersonalDataForm(forms.ModelForm):
...
@@ -404,9 +421,9 @@ class UpdatePersonalDataForm(forms.ModelForm):
]
]
self
.
fields
[
"
orcid_id
"
].
initial
=
self
.
instance
.
profile
.
orcid_id
self
.
fields
[
"
orcid_id
"
].
initial
=
self
.
instance
.
profile
.
orcid_id
self
.
fields
[
"
webpage
"
].
initial
=
self
.
instance
.
profile
.
webpage
self
.
fields
[
"
webpage
"
].
initial
=
self
.
instance
.
profile
.
webpage
self
.
fields
[
self
.
fields
[
"
accepts_SciPost_emails
"
].
initial
=
(
"
accepts_SciPost_emails
"
self
.
instance
.
profile
.
accepts_SciPost_emails
].
initial
=
self
.
instance
.
profile
.
accepts_SciPost_emails
)
def
save
(
self
):
def
save
(
self
):
self
.
instance
.
profile
.
title
=
self
.
cleaned_data
[
"
title
"
]
self
.
instance
.
profile
.
title
=
self
.
cleaned_data
[
"
title
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment