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
35d5bcdf
Commit
35d5bcdf
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Patches
Plain Diff
Deletion of alias now possible!
parent
27391049
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
Alias
Pipeline
#7823
failed with stages
in 1 minute and 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/member/views.py
+18
-1
18 additions, 1 deletion
apps/member/views.py
apps/note/models/notes.py
+0
-8
0 additions, 8 deletions
apps/note/models/notes.py
apps/note/tables.py
+1
-1
1 addition, 1 deletion
apps/note/tables.py
with
19 additions
and
10 deletions
apps/member/views.py
+
18
−
1
View file @
35d5bcdf
...
...
@@ -8,11 +8,14 @@ from django.utils.translation import gettext_lazy as _
from
django.views.generic
import
CreateView
,
DetailView
,
UpdateView
,
TemplateView
,
DeleteView
from
django.views.generic.edit
import
FormMixin
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_tables2.views
import
SingleTableView
from
rest_framework.authtoken.models
import
Token
from
django.core.exceptions
import
ValidationError
from
note.models
import
Alias
,
NoteUser
from
note.models.transactions
import
Transaction
from
note.tables
import
HistoryTable
,
AliasTable
...
...
@@ -189,8 +192,22 @@ class AliasView(LoginRequiredMixin,FormMixin,DetailView):
class
DeleteAliasView
(
LoginRequiredMixin
,
DeleteView
):
model
=
Alias
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
try
:
self
.
object
=
self
.
get_object
()
self
.
object
.
delete
()
except
ValidationError
as
e
:
# TODO: pass message to redirected view.
messages
.
error
(
self
.
request
,
str
(
e
))
else
:
messages
.
success
(
self
.
request
,
_
(
"
Alias successfully deleted
"
))
return
HttpResponseRedirect
(
get_success_url
)
def
get_success_url
(
self
):
print
(
self
.
request
)
return
reverse_lazy
(
'
member:user_alias
'
,
kwargs
=
{
'
pk
'
:
self
.
object
.
note
.
user
.
pk
})
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
return
self
.
post
(
request
,
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
apps/note/models/notes.py
+
0
−
8
View file @
35d5bcdf
...
...
@@ -219,14 +219,6 @@ class Alias(models.Model):
if
all
(
not
unicodedata
.
category
(
char
).
startswith
(
cat
)
for
cat
in
{
'
M
'
,
'
P
'
,
'
Z
'
,
'
C
'
})).
casefold
()
def
save
(
self
,
*
args
,
**
kwargs
):
"""
Handle normalized_name
"""
self
.
normalized_name
=
Alias
.
normalize
(
self
.
name
)
if
len
(
self
.
normalized_name
)
<
256
:
super
().
save
(
*
args
,
**
kwargs
)
def
clean
(
self
):
normalized_name
=
Alias
.
normalize
(
self
.
name
)
if
len
(
normalized_name
)
>=
255
:
...
...
This diff is collapsed.
Click to expand it.
apps/note/tables.py
+
1
−
1
View file @
35d5bcdf
...
...
@@ -36,4 +36,4 @@ class AliasTable(tables.Table):
template_name
=
'
django_tables2/bootstrap4.html
'
delete
=
tables
.
LinkColumn
(
'
member:user_alias_delete
'
,
args
=
[
A
(
'
pk
'
)],
attrs
=
{
'
a
'
:
{
'
class
'
:
'
btn btn-danger
'
}
},
text
=
'
delete
'
)
'
a
'
:
{
'
class
'
:
'
btn btn-danger
'
}
},
text
=
'
delete
'
,
accessor
=
'
pk
'
)
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