Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Add consent table #1301

Merged
merged 20 commits into from
Sep 14, 2022
Merged

Add consent table #1301

merged 20 commits into from
Sep 14, 2022

Conversation

sanders41
Copy link
Contributor

@sanders41 sanders41 commented Sep 12, 2022

Purpose

❗ Contains migrations.

Adds a table to store consent preferences for data subjects.

Changes

  • Added a consent table.

Checklist

  • Update CHANGELOG.md file
    • Merge in main so the most recent CHANGELOG.md file is being appended to
    • Add description within the Unreleased section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.
    • Add a link to this PR at the end of the description with the PR number as the text. example: #1
  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #1160

@sanders41 sanders41 changed the title Ps consent database updates Add consent table Sep 12, 2022
@sanders41 sanders41 marked this pull request as ready for review September 13, 2022 00:11
@@ -714,6 +714,7 @@ class ProvidedIdentity(Base): # pylint: disable=R0904
),
nullable=True,
) # Type bytea in the db
consent = relationship("Consent", back_populates="provided_identity", uselist=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have uselist as False because I am assuming consent would only need to be given one time. Is that a correct assumption?

Copy link
Contributor

Choose a reason for hiding this comment

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

The main thing that's enforcing the 1:1 is your unique constraint on Consent.provided_identity_id, this uselist by itself doesn't prevent there from being multiple consents for the same privacy request id. The uselist=False just loads this as a scalar. But yes, in my opinion the unique constraint makes sense to me.

@pattisdr
Copy link
Contributor

Starting review..

src/fidesops/ops/models/privacy_request.py Show resolved Hide resolved
@@ -714,6 +714,7 @@ class ProvidedIdentity(Base): # pylint: disable=R0904
),
nullable=True,
) # Type bytea in the db
consent = relationship("Consent", back_populates="provided_identity", uselist=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

The main thing that's enforcing the 1:1 is your unique constraint on Consent.provided_identity_id, this uselist by itself doesn't prevent there from being multiple consents for the same privacy request id. The uselist=False just loads this as a scalar. But yes, in my opinion the unique constraint makes sense to me.

src/fidesops/ops/models/privacy_request.py Show resolved Hide resolved
src/fidesops/ops/models/privacy_request.py Show resolved Hide resolved
@sanders41
Copy link
Contributor Author

@pattisdr I updated the models to allow multiple consents and added a test, but still need to update the database diagram.

@sanders41
Copy link
Contributor Author

Database diagram is updated now also so I think it is ready for another review.

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

good work I just have a couple comments about the unit test and the downgrade but feel free to push back

tests/ops/models/test_privacy_request.py Outdated Show resolved Hide resolved
tests/ops/models/test_privacy_request.py Outdated Show resolved Hide resolved
tests/ops/models/test_privacy_request.py Outdated Show resolved Hide resolved
Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

nice work here

@pattisdr pattisdr merged commit cdd0e54 into main Sep 14, 2022
@pattisdr pattisdr deleted the ps-consent-database-updates branch September 14, 2022 00:01
@sanders41
Copy link
Contributor Author

Thanks @pattisdr!

sanders41 pushed a commit that referenced this pull request Sep 22, 2022
Co-authored-by: Paul Sanders <pau@ethyca.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consent database updates
3 participants