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 #15

Closed
41 of 45 tasks
ExperimentsInHonesty opened this issue May 26, 2022 · 5 comments · Fixed by #83
Closed
41 of 45 tasks

Create Table: User #15

ExperimentsInHonesty opened this issue May 26, 2022 · 5 comments · Fixed by #83
Assignees
Labels
complexity: missing feature: table creation p-feature: user PII: TRUE Table or function has or uses Personally Identifiable Information (PII) role: back end s: CTJ stakeholder: Civic Tech Jobs s: kb stakeholder: knowledgebase s: VRMS stakeholder: VRMS size: 5pt Can be done in 19-30 hours

Comments

@ExperimentsInHonesty
Copy link
Member

ExperimentsInHonesty commented May 26, 2022

Overview

We need to create the User table so that we can automate user permissions and accounts creation

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 other tables are associated (see ERD under 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). - no relationships yet since this is the only model
  • Write an API end point
  • write API unit tests
  • Document the endpoint in Swagger

Resources/Instructions

Items to document (referenced above)

Description

  • List of users

Data Fields

  1. Copied from spreadsheet and checked off according to ERD. Data fields are bolded and relation fields are not.

    • id
    • name_first
    • name_last
    • gmail
    • preferred_email
    • created
    • user_status_id (FK)
    • practice_area_current
    • job_title_current
    • practice_area_target
    • job_title_target
    • desired_roles
    • availability - this has been converted into a related table user_availability
    • current_skills
    • target_skills
    • linkedin_account
    • referred_by (FK)
    • github_handle
    • phone
    • texting_ok
    • slack_id
    • time_zone
    • conduct - 8/10 meeting: Nicole informed that this was converted to the more generic user_check record
    • updated
    • password - this is not used with Cognito authentication
  2. In ERD only - none

  3. Combined table

name Data Rela. in ERD in sheet notes
id x x x PK
name_first x x x
name_last x x x
gmail x x x
preferred_email x x x
created x x x
job_title_current x x x
availability x x this has been converted into a related table user_availability
current_skills x x x
target_skills x x x
linkedin_account x x x
github_handle x x x
phone x x x
texting_ok x x x
slack_id x x x
time_zone x x x
conduct x x 8/10 meeting: Nicole informed that this was converted to the more generic user_check record
updated x x x
password x x x this is not used with Cognito authentication
user_status_id x x x FK
practice_area_current x x x
practice_area_target x x x
desired_roles x x x
referred_by x x x FK

Associated Tables

  1. Copied from spreadsheet and checked off according to ERD

    • cancelled_event (one-to-many)
    • check_in (one-to-many)
    • permission (one-to-many)
    • permission_history (one-to-many)
    • user_availability (one-to-many)
    • user_check (one-to-many)
    • user_employment_change (one-to-many)
    • win (one-to-many)
    • user_status_type (many-to-one)
    • project (array of IDs) - this has been converted to a sort of junction table called permission in the ERD
  2. In ERD only

    • practice_area (many-to-many)
    • referrer (many-to-one)

Swagger Endpoint Link

@ExperimentsInHonesty ExperimentsInHonesty added this to the 01 - Update project data milestone May 26, 2022
@fyliu fyliu self-assigned this Jun 13, 2022
@fyliu
Copy link
Member

fyliu commented Jun 19, 2022

It would be nice if all data fields have

  1. default values
  2. if it can be empty or not
  3. varchar size
  4. uniqueness constraint

I read that using UUID for primary key is the best thing to do and doesn't impact performance if we're using postgres

I see array fields that represent a list of PK of other models. Should they be made into model relations like one-to many?

@fyliu
Copy link
Member

fyliu commented Jun 23, 2022

From today's meeting I think we settled on these

  1. Use UUID as model index to simplify things.
  2. The int array fields represent many-to-many relationships that I just didn't recognize before.
  3. varchar size could be something like 50 for gmail, for example, or maybe 255, which is a common value.
  4. Ask Nicole and Bonnie about nullable fields, uniqueness constraints, and default values for the fields.

@fyliu
Copy link
Member

fyliu commented Jul 22, 2022

I've neglected this for a while but I'm much more confident now, having read through a few more books on django and drf.

I recently worked on

  1. creating the API
  2. limiting viewable fields for the API
  3. setting up API docs using drf-spectacular
  4. generating ER diagrams from django models

I expect to have this complete in the next week.

Things that need to be done

  • api tests
  • final adjustments to the model definition if any
  • add custom type fields like phone number and timezone

Things for the future

  • model relations to undefined models
  • limit API actions to maybe disable delete or perform soft delete

@fyliu
Copy link
Member

fyliu commented Jul 28, 2022

Just a note in case anyone really wants to try fixing this. It doesn't affect the application at all except the swagger doc shows time_zone as string type instead of timezone.

I'm using this timezone field extension and drf-spectacular (generates swagger docs) is not able to recognize it correctly.
https://github.com/mfogel/django-timezone-field

There's documentation on how to customize it but I don't think we want to do that at this point.
https://drf-spectacular.readthedocs.io/en/latest/customization.html

This was referenced Aug 4, 2022
@fyliu
Copy link
Member

fyliu commented Aug 9, 2022

Need to review the description

  • missing "conduct" field

@fyliu fyliu mentioned this issue Aug 13, 2022
6 tasks
@fyliu fyliu mentioned this issue Aug 25, 2022
39 tasks
@fyliu fyliu mentioned this issue Sep 19, 2022
@fyliu fyliu modified the milestones: 01 - Update project data, All tables added Sep 25, 2022
@fyliu fyliu closed this as completed in #83 Oct 5, 2022
@ExperimentsInHonesty ExperimentsInHonesty added p-feature: user s: CTJ stakeholder: Civic Tech Jobs s: VRMS stakeholder: VRMS and removed MVP labels Mar 4, 2023
@ethanstrominger ethanstrominger added the s: kb stakeholder: knowledgebase label Apr 25, 2023
@ExperimentsInHonesty ExperimentsInHonesty added the PII: TRUE Table or function has or uses Personally Identifiable Information (PII) label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: missing feature: table creation p-feature: user PII: TRUE Table or function has or uses Personally Identifiable Information (PII) role: back end s: CTJ stakeholder: Civic Tech Jobs s: kb stakeholder: knowledgebase s: VRMS stakeholder: VRMS size: 5pt Can be done in 19-30 hours
Projects
Status: ✅Done
Development

Successfully merging a pull request may close this issue.

3 participants