Skip to content

permission_model#140

Merged
jirhiker merged 4 commits into
stagingfrom
permission_model
Sep 20, 2025
Merged

permission_model#140
jirhiker merged 4 commits into
stagingfrom
permission_model

Conversation

@ksmuczynski
Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem / context:

  • Need a polymorphic table to manage and historicize access and usage agreements.

How

Implementation summary - the following was changed / added / removed:

  • Created new Permimssion model with new fields.
  • Added new PermissionMixin to db/base/py file to automatically create a polymorphic One-to-Many relationship to the
    Permission table.

Notes

Any special considerations, workarounds, or follow-up work to note?

  • This PR address the creation of the Permission table only.
  • Related validation schema files and test files still need to be created.
  • Core tables that will inherit from the Permission table still need to be updated (Thing, Location)

Comment thread db/permission.py
Comment thread db/permission.py
)
start_date: Mapped[Date] = mapped_column(Date, nullable=True)
end_date: Mapped[Date] = mapped_column(Date, nullable=True)
notes: Mapped[str] = mapped_column(Text, nullable=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would this relate back to the polymorphic notes table? rather than have a notes field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like the idea of a polymorphic notes table, but thought it might be easier to implement single note fields in individual tables to start. Later we could go back and implement the polymorphic notes table, but I'm open to discussion. If we have the time I think it could be worth implementing now. We could still retain NMAquifer notes in nma_notes fields where appropriate.

Comment thread db/permission.py
Comment on lines +62 to +76
_thing_target: Mapped["Thing"] = relationship(
"Thing",
primaryjoin=and_(
foreign(permissible_id) == Thing.thing_id, permissible_type == "Thing"
),
viewonly=True,
)
_location_target: Mapped["Location"] = relationship(
"Location",
primaryjoin=and_(
foreign(permissible_id) == Location.location_id,
permissible_type == "Location",
),
viewonly=True,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For this to work do the thing and location tables need to inherit from the permission mixin?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wait! That's been noted in your notes. Should it be present in this PR? Or wait to implement that so that it can be implemented elsewhere, too, like services and tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right. The idea with this PR is to just create the table. Then a separate PR for Thing and Location updates, where they would inherit these new tables. It seemed simpler to break down the PRs into their individual component tasks and focus on one thing at a time. Personal opinion of course, open to discussion re: best practices for PRs.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 19, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
db/base.py 75.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
db/base.py 93.22% <75.00%> (ø)

…since time is not important to capture here.
@jirhiker jirhiker merged commit 3f3a7a7 into staging Sep 20, 2025
3 checks passed
@ksmuczynski ksmuczynski deleted the permission_model branch September 24, 2025 16:44
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.

4 participants