Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
BDE
nk20
Commits
2e8505e9
Commit
2e8505e9
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Patches
Plain Diff
ménage dans les imports
parent
fd74080c
No related branches found
No related tags found
1 merge request
!31
Alias
Pipeline
#7830
failed with stages
in 1 minute and 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/member/views.py
+5
-8
5 additions, 8 deletions
apps/member/views.py
with
5 additions
and
8 deletions
apps/member/views.py
+
5
−
8
View file @
2e8505e9
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
dal
import
autocomplete
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.shortcuts
import
redirect
from
django.utils.translation
import
gettext_lazy
as
_
...
...
@@ -11,15 +10,17 @@ from django.contrib.auth.models import User
from
django.contrib
import
messages
from
django.urls
import
reverse_lazy
from
django.http
import
HttpResponseRedirect
from
django.db.models
import
Q
from
django.core.exceptions
import
ValidationError
from
django_tables2.views
import
SingleTableView
from
rest_framework.authtoken.models
import
Token
from
django.core.exceptions
import
ValidationError
from
dal
import
autocomplete
from
note.models
import
Alias
,
NoteUser
from
note.models.transactions
import
Transaction
from
note.tables
import
HistoryTable
,
AliasTable
from
note.forms
import
AliasForm
from
note.forms
import
AliasForm
,
ImageForm
from
.models
import
Profile
,
Club
,
Membership
from
.forms
import
SignUpForm
,
ProfileForm
,
ClubForm
,
MembershipForm
,
MemberFormSet
,
FormSetHelper
...
...
@@ -70,16 +71,13 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
form
=
super
().
get_form
(
form_class
)
if
'
username
'
not
in
form
.
data
:
return
form
new_username
=
form
.
data
[
'
username
'
]
# Si l'utilisateur cherche à modifier son pseudo, le nouveau pseudo ne doit pas être proche d'un alias existant
note
=
NoteUser
.
objects
.
filter
(
alias__normalized_name
=
Alias
.
normalize
(
new_username
))
if
note
.
exists
()
and
note
.
get
().
user
!=
self
.
object
:
form
.
add_error
(
'
username
'
,
_
(
"
An alias with a similar name already exists.
"
))
return
form
def
form_valid
(
self
,
form
):
...
...
@@ -184,7 +182,6 @@ class AliasView(LoginRequiredMixin,FormMixin,DetailView):
alias
=
form
.
save
(
commit
=
False
)
alias
.
note
=
self
.
object
.
note
alias
.
save
()
print
(
alias
,
alias
.
pk
)
return
super
().
form_valid
(
form
)
class
DeleteAliasView
(
LoginRequiredMixin
,
DeleteView
):
...
...
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