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

Create Table: user permission #22

Closed
15 of 21 tasks
Tracked by #37
fyliu opened this issue Aug 13, 2022 · 6 comments · Fixed by #342
Closed
15 of 21 tasks
Tracked by #37

Create Table: user permission #22

fyliu opened this issue Aug 13, 2022 · 6 comments · Fixed by #342
Labels
complexity: missing dependency Issue has dependencies feature: table creation p-feature: onboarding p-feature: permissions PII: TRUE Table or function has or uses Personally Identifiable Information (PII) research Issue involving doing research role: db architect s: CTJ stakeholder: Civic Tech Jobs s: VRMS stakeholder: VRMS size: 2pt Can be done in 7-12 hours

Comments

@fyliu
Copy link
Member

fyliu commented Aug 13, 2022

Dependency

Overview

We need to create the user permission table so that we can update a shared data store across hackforla.org, vrms, civictechjobs, and tables (onboarding) project.

Details

A table and a model are the same thing

Action Items

  • identify if table has a description (see spreadsheet under Resources)
    • if not, reach out to PD leads
  • identify and document (below) what the data fields are and make sure the ERD and spreadsheets match (see Resources)
  • identify and document (below) what other tables are associated and make sure the ERD and spreadsheets match (see Resources)
  • create a single model in Django (defining schema)
  • Write a test for the relationships this model will have with other models (e.g., creating a user and assigning them a set of permissions on a project)
  • Write an API end point
  • write API unit tests
  • Document the endpoint in Swagger

Resources/Instructions

Items to document (referenced above)

Description

  • User permissions for project, brigade, etc.

Data Fields

  1. Copied from spreadsheet and checked off according to ERD. Data fields are bolded and relation fields are not. (unchecked items indicate a mismatch between ERD and spreadsheet, which requires a review)

    • PK - id - int - Record Id
    • FK - user_id - int - Record Id
    • FK - project_id - int - Record Id
    • FK - permission_type_id - int
    • FK - practice_area_id - int - Record Id
    • granted - timestamp
    • ended - timestamp
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • created_by - int
    • updated_by - int

Associated Tables

  1. Copied from spreadsheet and checked off according to ERD (unchecked items indicate a mismatch between ERD and spreadsheet, which requires a review)

    • permission_type (many-to-one)
    • practice_area (many-to-one)
    • project (many-to-one)
    • practice_area_id (many-to-one)
    • user (many-to-one)
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • None

Swagger Endpoint Link

@Neecolaa
Copy link
Member

created_by and updated_by are both foreign keys containing user ids. If a permission isn't what it should be, we can use these values to figure out who to ask. I've just added the fields to the spreadsheet.

@fyliu
Copy link
Member Author

fyliu commented Sep 27, 2022

@Neecolaa This table is really a "membership" relationship xref table between user and project, with associated roles and permissions attributes. Should we change the name to "membership" or "member" or similar?

@joshuayhwu
Copy link

class Permission(AbstractBaseModel):
	"""
	Permission
	"""
	id = models.IntegerField(primary_key=True)
	user_id = models.ForeignKey(User, on_delete=models.CASCADE)
	project_Id = models.ForeignKey(Project, on_delete=models.CASCADE)
	permission_type = models.ForeignKey(Project, on_delete=models.CASCADE)
	granted = models.DateTimeField()
	ended = models.DateTimeField()


	def __str__(self): 
		return f"{self.name}" 

@fyliu fyliu removed their assignment Nov 5, 2022
@fyliu fyliu added the research Issue involving doing research label Jan 5, 2023
@fyliu
Copy link
Member Author

fyliu commented Jan 5, 2023

Update for the record: according to @ExperimentsInHonesty during a meeting, this is not a membership junction table between user and project. It's a property relating to user. There's an optional reference to project if it makes sense to have it. Where it doesn't make sense is for a brigade admin role which has permission to all projects under that brigade.

  • Question: should there be a reference to brigade here? I'm thinking yes and it should be optional. A global admin would have permission to all brigades the same way that a brigade admin relates to projects.

@fyliu
Copy link
Member Author

fyliu commented Jan 5, 2023

This issue (or a closely-related new issue) requires some research into the best way to implement permissions in django.

  • Does django come with one?
    • Does it fit our use well?
    • Can we make it work for us?
  • What 3rd party plugins/apps are there and do any of them already do what we need or can be made to work?
  • Do we need to implement our own solution?

@ExperimentsInHonesty ExperimentsInHonesty added the PII: TRUE Table or function has or uses Personally Identifiable Information (PII) label May 4, 2023
@Neecolaa Neecolaa added the feature: ERD/SS adjustment Requires adjustments to be made to the ERD & Spreadsheet label Jul 8, 2023
@Neecolaa

This comment was marked as resolved.

@Neecolaa Neecolaa added dependency Issue has dependencies and removed feature: ERD/SS adjustment Requires adjustments to be made to the ERD & Spreadsheet labels Jan 14, 2024
@shmonks shmonks moved this to Ice Box in P: PD: Project Board Jun 7, 2024
@ethanstrominger ethanstrominger changed the title Create Table: permission Create Table: user permission Jul 1, 2024
@github-project-automation github-project-automation bot moved this from 🧊Ice Box to ✅Done in P: PD: Project Board Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: missing dependency Issue has dependencies feature: table creation p-feature: onboarding p-feature: permissions PII: TRUE Table or function has or uses Personally Identifiable Information (PII) research Issue involving doing research role: db architect s: CTJ stakeholder: Civic Tech Jobs s: VRMS stakeholder: VRMS size: 2pt Can be done in 7-12 hours
Projects
Status: ✅Done
Development

Successfully merging a pull request may close this issue.

4 participants