-
Notifications
You must be signed in to change notification settings - Fork 6
Add signal to support additional foreign keys on Sample #14
Conversation
@@ -0,0 +1,3 @@ | |||
from django.dispatch import Signal | |||
|
|||
pre_delete_sample = Signal(providing_args=["pk_set", "cursor"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change strings to use single quotes to be consistent with the rest of the codebase.
@@ -111,6 +113,9 @@ def handle(self, *args, **options): | |||
''', [project_id]) | |||
|
|||
# Remove samples | |||
pre_delete_sample.send(sender=Project, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going to use the pre_delete_sample
signal then the pk_set
argument should be the sample IDs in the project being deleted. If you are going to send the project ID then change this to use a new pre_delete_project
signal.
Please squash this into a single commit |
@@ -111,6 +113,9 @@ def handle(self, *args, **options): | |||
''', [project_id]) | |||
|
|||
# Remove samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorder these lines:
pre_delete_project.send(
sender=Project, pk=project_id, cursor=cursor)
# Remove samples
cursor.execute('''
DELETE FROM sample WHERE project_id = %s
''', [project_id])
7129ef8
to
cabfd72
Compare
@@ -70,6 +71,8 @@ def handle(self, *args, **options): | |||
'''.format(columns), valid_ids) | |||
|
|||
# Remove sample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
Signed-off-by: Adam Wenocur <wenocur@email.chop.edu>
Add signal to support additional foreign keys on Sample
This allows the delete-sample command to be extended, to support models with foreign keys pointing to Sample.