Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
4192576c
Commit
4192576c
authored
6 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Remove all paths on element deletion
parent
71a97593
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!91
Remove all paths on Element deletion
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/documents/apps.py
+3
-0
3 additions, 0 deletions
arkindex/documents/apps.py
arkindex/documents/models.py
+1
-1
1 addition, 1 deletion
arkindex/documents/models.py
arkindex/documents/signals.py
+11
-0
11 additions, 0 deletions
arkindex/documents/signals.py
with
15 additions
and
1 deletion
arkindex/documents/apps.py
+
3
−
0
View file @
4192576c
...
...
@@ -3,3 +3,6 @@ from django.apps import AppConfig
class
ElementsConfig
(
AppConfig
):
name
=
'
documents
'
def
ready
(
self
):
from
arkindex.documents
import
signals
# noqa
This diff is collapsed.
Click to expand it.
arkindex/documents/models.py
+
1
−
1
View file @
4192576c
...
...
@@ -82,7 +82,7 @@ class ElementPath(models.Model):
An element can have multiple paths up to the top
"""
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
element
=
models
.
ForeignKey
(
'
documents.Element
'
,
related_name
=
'
paths
'
,
on_delete
=
models
.
DO_NOTHING
)
element
=
models
.
ForeignKey
(
'
documents.Element
'
,
related_name
=
'
paths
'
,
on_delete
=
models
.
CASCADE
)
path
=
ArrayField
(
models
.
UUIDField
(),
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/signals.py
0 → 100644
+
11
−
0
View file @
4192576c
from
django.db.models.signals
import
pre_delete
from
django.dispatch
import
receiver
from
arkindex.documents.models
import
Element
,
ElementPath
@receiver
(
pre_delete
,
sender
=
Element
)
def
pre_delete_handler
(
sender
,
instance
,
*
args
,
**
kwargs
):
assert
isinstance
(
instance
,
Element
)
# Run remove_child on all direct parents of the element
for
parent
in
ElementPath
.
objects
.
filter
(
path__last
=
instance
.
id
):
parent
.
remove_child
(
instance
)
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