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

Fixes for whether existing Identifier objects are preserved or not #11

Merged
merged 3 commits into from
Jan 9, 2017

Conversation

mhl
Copy link

@mhl mhl commented Jan 6, 2017

This pull request addresses two problems:

  • The cases where a person's 'identifiers' array was missing and when
    it was empty had confusingly different behaviour. This makes the 'missing'
    case consistent with the empty array and existing handling of other related
    objects.
  • It wasn't possible for users of the importer to specify particular schemes of
    identifiers that should be preserved; this pull request adds that facility.

@coveralls
Copy link

coveralls commented Jan 6, 2017

Coverage Status

Coverage increased (+0.1%) to 92.938% when pulling ad332c1 on extend-identifier-preservation into 4337f05 on master.

Copy link
Member

@struan struan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from some naming pedantry and a request for an extra test this looks good.

@@ -573,14 +577,22 @@ def create_identifier(self, popit_collection, popit_id, django_object):
identifier=popit_id,
)

def preserve_related(self, django_main_model, related_object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preserve_related sounds like an action, I think something more like should_preserve_related makes it a little clearer what this is doing.

)
existing_person.identifiers.create(
scheme='preserve-me',
identifier="data-that-should-be-kept"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like a helpful name here given the test output.

person.identifiers.order_by('scheme').values_list('scheme', 'identifier'),
[(u'popolo:person', u'a1b2')]
)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there should be a near identical test with identifiers set to [] to show that they do the same thing?

We're refactoring this in order to make it easier subsequently to allow
users of this class to specify additional Identifier schemes to
preserve.
If 'identifiers' was missing from a person, the old Identifier objects
associated with a Person would all be preserved, but if instead
identifiers was [] it would remove all Identifier objects associated
with that Person except for the one that preserved the Django ID for
them.

This change makes the behaviour consistent between those two very
similar cases - unknown identifiers are removed when syncing from the
source. (This is what happens for contact details, etc. as well.)
@mhl mhl force-pushed the extend-identifier-preservation branch from ad332c1 to b9f3c1d Compare January 9, 2017 08:16
@mhl
Copy link
Author

mhl commented Jan 9, 2017

Thanks, @struan, I've made the changes you suggested.

@coveralls
Copy link

coveralls commented Jan 9, 2017

Coverage Status

Coverage increased (+0.2%) to 92.996% when pulling b9f3c1d on extend-identifier-preservation into 4337f05 on master.

@mhl mhl merged commit b9f3c1d into master Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants