-
Notifications
You must be signed in to change notification settings - Fork 7
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
Copy affiliations to targeted journalists and institutions #865
Copy affiliations to targeted journalists and institutions #865
Conversation
619da58
to
98b891f
Compare
98b891f
to
39fe578
Compare
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.
This worked as expected! I'd like us to hide the deprecated fields (or mark them as deprecated) but this is a definite improvement over the current situation!
inst, _ = Institution.objects.get_or_create(title=incident.affiliation) | ||
|
||
targeted_journos = incident.targeted_journalists.all() | ||
if targeted_journos: |
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.
Had to check my memory that empty querysets are falsey. They are 👍
We are phasing out the one-affiliation-per-incident affiliation model in favor of an Institution model, which can either be applied on a journalist by journalist basis, or to the incident as a whole, but as many as desired. For this, we must move data from the legacy affiliation field to the new Institution field. We do this using a data migration, with two pre- and post- migrations to work around this bug in djang-modelcluster: wagtail/django-modelcluster#96 For the migration, we want these steps: 1. For each incident, examine the `affiliation` field 2. If it null or set to the default value of "Independent," discard it. The "independent" value is a placeholder for no definite affiliation and will not be used in the new scheme. 3. Create, if it doesn't already exist, an Institution with the title of the affiliation. 4. If this incident has any targeted journalists who do not already have an associated institution, associate the new institution with them. 5. If this incident does *not* have any targeted journalists, add the new institution as a target of this incident. This will fully bring any affiliation data into the institution model and apply it to the incidents that this data described.
Since this information is subsumed by the institution data, I'm feeling like it should be removed from display as well.
39fe578
to
36bf7a7
Compare
This is to correct an oversight in from #776 where the field
IncidentPage.affiliation
should have been used to initialize theInstitution
model and the relationships betweenInstitution
,IncidentPage
, andTargetedJournalist
. In this pull request, we have:affiliation
data into theInstitution
model and its relations. See commit for further detail and rationale.affiliation
display on the incident page sidebar.Fixes #866
Testing and Acceptance
The crucial element here is the data manipulation code. I believe it's good, but we ought to make extra sure that: 1. we know what we want it to do, and 2. it does that correctly.