hackforla / peopledepot

A project to setup a datastore for people and projects at HackforLA. The link below takes you to the code documentation
https://hackforla.github.io/peopledepot/
GNU General Public License v2.0
7 stars 26 forks source link

Update Table: User #429

Open ExperimentsInHonesty opened 3 weeks ago

ExperimentsInHonesty commented 3 weeks ago

Overview

We need to update the User table model to include new fields and have the correct names for fields.

Details

Action Items

Update existing Django model

Current name in code Updated Name Updated Type (may already be this type)
current_job_title job_title_current_intake varchar
email email_intake EmailField
first_name name_first varchar
gmail email_gmail EmailField
is_active user_status_id int
last_name name_last varchar
preferred_email email_preferred EmailField
target_job_title job_title_target_intake varchar
Name Type
practice_area_primary int (practice_area_primary)
practice_area_secondary int[] (practice_area_secondary)
practice_area_target_intake int[] (practice_area_target_intake)
referred_by int
email_cognito EmailField

After PR has been approved

Resources

fyliu commented 1 week ago

User fields as of 2024-11-14

User

shmonks commented 1 week ago

@Neecolaa and @ExperimentsInHonesty to review current column fields

shmonks commented 1 week ago

We need to add a Cognito email field in this table, and change 'email' to intake_email


We decided to rename all the emails Noun - Adjective e.g., email_intake, email_gmail, email_cognito, etc.

fyliu commented 1 week ago

@Neecolaa The following is not part of this issue, but the table made me think of something else. Can we add descriptions to all the columns to help developers using the API figure out how they should use them? Something like this example I made up?

I bolded the target column names to make them more noticeable.

I think the developer should also generate and post a schema image of the table like I did above but in the PR.

Current name in code Updated Name Updated Type (may already be this type) description
first_name name_first varchar User's first name
last_name name_last varchar User's last name
created_date created_at DateTimeField Auto-generated date and time when user was created
is_active user_status_id int User active status. This is determined by <...>
current_job_title intake_job_title_current varchar The job title when first joined the organization. This is not updateable by the user later.
target_job_title intake_job_title_target varchar The user's target job title when first joined the organization. This is not updateable by the user later.

The description would show up in the API docs like the "Event name" in this example: 2024-11-15 15 50 45 localhost 58e8d85425ba

ExperimentsInHonesty commented 1 week ago

@fyliu @ethanstrominger Do you know what are these fields for: is_staff is_superuser

Re the comment above about putting descriptions. We will do that on another epic, once we get all the table changes with the correct field names made.

Can we add descriptions to all the columns to help developers using the API figure out how they should use them? Something like this example I made up?

Current name in code Updated Name Updated Type (may already be this type) description
first_name name_first varchar User's first name
last_name name_last varchar User's last name
created_date created_at DateTimeField Auto-generated date and time when user was created
is_active user_status_id int User active status. This is determined by <...>
current_job_title intake_job_title_current varchar The job title when first joined the organization. This is not updateable by the user later.
target_job_title intake_job_title_target varchar The user's target job title when first joined the organization. This is not updateable by the user later.
fyliu commented 1 week ago

@ExperimentsInHonesty Those are what django uses in the default model. See link to reference.

is_staff:

is_superuser:

is_staff currently has a description in peopledepot that we can update: "Designates whether the user can log into this admin site."


I said there's no way to get the text-only description before. But I forgot about just asking the database for it. Maybe the developer making the change can do a before and after output of this? I can provide this for the other tables as well.

Here's what the user table is defined as in the database currently:

                           Table "public.core_user"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 password          | character varying(128)   |           | not null | 
 last_login        | timestamp with time zone |           |          | 
 is_superuser      | boolean                  |           | not null | 
 uuid              | uuid                     |           | not null | 
 created_at        | timestamp with time zone |           | not null | 
 updated_at        | timestamp with time zone |           | not null | 
 username          | character varying(255)   |           | not null | 
 is_active         | boolean                  |           | not null | 
 email             | character varying(254)   |           | not null | 
 is_staff          | boolean                  |           | not null | 
 current_job_title | character varying(255)   |           | not null | 
 current_skills    | character varying(255)   |           | not null | 
 first_name        | character varying(255)   |           | not null | 
 github_handle     | character varying(255)   |           | not null | 
 gmail             | character varying(254)   |           | not null | 
 last_name         | character varying(255)   |           | not null | 
 linkedin_account  | character varying(255)   |           | not null | 
 phone             | character varying(128)   |           | not null | 
 preferred_email   | character varying(254)   |           | not null | 
 slack_id          | character varying(11)    |           | not null | 
 target_job_title  | character varying(255)   |           | not null | 
 target_skills     | character varying(255)   |           | not null | 
 texting_ok        | boolean                  |           | not null | 
 time_zone         | character varying(63)    |           | not null | 
Indexes:
    "core_user_pkey" PRIMARY KEY, btree (uuid)
    "core_user_username_36e4f7f7_like" btree (username varchar_pattern_ops)
    "core_user_username_key" UNIQUE CONSTRAINT, btree (username)
Referenced by:
    TABLE "core_user_groups" CONSTRAINT "core_user_groups_user_id_70b4d9b8_fk_core_user_uuid" FOREIGN KEY (user_id) REFERENCES core_user(uuid) DEFERRABLE INITIALLY DEFERRED
    TABLE "core_user_user_permissions" CONSTRAINT "core_user_user_permissions_user_id_085123d3_fk_core_user_uuid" FOREIGN KEY (user_id) REFERENCES core_user(uuid) DEFERRABLE INITIALLY DEFERRED
    TABLE "core_userpermission" CONSTRAINT "core_userpermission_user_id_2b95370e_fk_core_user_uuid" FOREIGN KEY (user_id) REFERENCES core_user(uuid) DEFERRABLE INITIALLY DEFERRED
    TABLE "django_admin_log" CONSTRAINT "django_admin_log_user_id_c564eba6_fk_core_user_uuid" FOREIGN KEY (user_id) REFERENCES core_user(uuid) DEFERRABLE INITIALLY DEFERRED

The steps to get this are below:

fyliu commented 4 days ago

@ethan pointed out that is_staff and is_superuser are internal data and don't need to be exposed to the API client. They can find out who the adminGlobals are from the user_permission rather than the user table.