Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for post-save signals that depend on related objects #329

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pupa/importers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging

from django.db.models import Q
from django.db.models.signals import post_save
from django.contrib.contenttypes.models import ContentType

from opencivicdata.legislative.models import LegislativeSession
Expand Down Expand Up @@ -293,6 +294,10 @@ def import_item(self, data):
self.model_class))
self._create_related(obj, related, self.related_models)

# Fire post-save signal after related objects are created to allow
# for handlers make use of related objects
post_save.send(sender=self.model_class, instance=obj, created=True)

if pupa_id:
Identifier.objects.get_or_create(identifier=pupa_id,
jurisdiction_id=self.jurisdiction_id,
Expand Down