Giter VIP home page Giter VIP logo

peopledepot's Introduction

Hi there ๐Ÿ‘‹

peopledepot's People

Contributors

alexlaw528 avatar anandramakris avatar azaniabg avatar benpinhassi avatar brdeleon avatar chelseybeck avatar cnk avatar dakahn93 avatar ericvennemeyer avatar ethanstrominger avatar experimentsinhonesty avatar freaky4wrld avatar fyliu avatar jasoneb avatar joey-ma avatar joey-ma-steelgem avatar pre-commit-ci[bot] avatar

peopledepot's Issues

Update project configs for deployment

Overview

We need to improve the project configuration so that it is ready for deployment.

Action Items

  • work though the deployment checklist to be able to switch the project from DEBUG to production using an environment variable
  • Check off this issue's item in #218

Resources/Instructions

Update Event table must-could-should

Overview

We need to update the event table model in django to utilize the practice area table instead of the outdated role table.

  • #173 wasn't as complete as we thought it was

Details

The old model issues for this table are

Action Items

  • Update existing Django model
  • Write a test for the new relationships this model will have with other models (e.g., creating a user and assigning them a set of permissions on a project) if any.
  • Update API end point
  • Update API unit tests
  • Document the endpoint in Swagger

Changes Needed

Columns to Remove

  • must_roles - int[] (role_id)
  • should_roles - int[] (role_id)
  • could_roles - int[] (role_id)

Columns to Add

  • must_attend - JSON[]
  • should_attend - JSON[]
  • could_attend - JSON[]

Additional Changes

  • Add example JSON to the documentation (like the one in the ERD)

JSON Example:

[
  {
    practice_area: engineering,
    permission_level: practiceLeadProject
  },
  {
    practice_area: pm,
    permission_level: practiceLeadProject
  }
]

Resources

Practice Areas:

  • Development
  • Project Management
  • Design
  • Professional Development

Permission Types:

  • adminGlobal
  • adminBrigade
  • adminProject
  • practiceLeadProject
  • practiceLeadJrProject
  • memberProject
  • memberGeneral

Test suggestions

  • create an "All" event for the PeopleDepot project with these attendance suggestions
    • must: adminProject, practiceLeadProject, practiceLeadJrProject
    • should: memberProject
    • could: memberGeneral
  • need an example that utilizes Practice Area values

Update project configs for deployment

Overview

We need to improve the project configuration so that it is ready for deployment.

Action Items

  • work though the deployment checklist to be able to switch the project from DEBUG to production using an environment variable
  • Check off this issue's item in #218

Resources/Instructions

Create Table [name of table]

Overview

We need to create the [name of table] 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

Details

A table and a model are the same thing

Action Items

  • identify and document table description (see spreadsheet under Resources)
    • if not, reach out to PD leads
  • compare the data fields (below) against the ERD. Check off on the list and note any extras (see Resources)
  • compare the associated tables (below) against the ERD. Check off on the list and note any extras (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

Resources/Instructions

Description

No response

Data Fields

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

    • [name] - [type]
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • [name] - [type]

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)

    • [other_table] ([relationship])
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • None

Move all documentation either to markdown or Wiki

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Adjust pre-commit settings

Overview

Adjust pre-commit settings to resolve some issues

Action Items

  • ignore github issue template files
  • set pre-commit.ci to run quarterly from weekly

Resources/Instructions

  • ignore github issue template files because mdformat is doing the wrong thing for square brackets (it should not try to escape them)

image

  • we should unignore this when mdformat does the right thing

  • set pre-commit.ci to run quarterly from weekly because weekly is too often to update syntax checkers

Update Event table must-could-should

Overview

We need to update the event table model in django to utilize the practice area table instead of the outdated role table.

  • #173 wasn't as complete as we thought it was

Details

The old model issues for this table are

Action Items

  • Update existing Django model
  • Write a test for the new relationships this model will have with other models (e.g., creating a user and assigning them a set of permissions on a project) if any.
  • Update API end point
  • Update API unit tests
  • Document the endpoint in Swagger

Changes Needed

Columns to Remove

  • must_roles - int[] (role_id)
  • should_roles - int[] (role_id)
  • could_roles - int[] (role_id)

Columns to Add

  • must_attend - JSON[]
  • should_attend - JSON[]
  • could_attend - JSON[]

Additional Changes

  • Add example JSON to the documentation (like the one in the ERD)

JSON Example:

[
  {
    practice_area: engineering,
    permission_level: practiceLeadProject
  },
  {
    practice_area: pm,
    permission_level: practiceLeadProject
  }
]

Resources

Practice Areas:

  • Development
  • Project Management
  • Design
  • Professional Development

Permission Types:

  • adminGlobal
  • adminBrigade
  • adminProject
  • practiceLeadProject
  • practiceLeadJrProject
  • memberProject
  • memberGeneral

Test suggestions

  • create an "All" event for the PeopleDepot project with these attendance suggestions
    • must: adminProject, practiceLeadProject, practiceLeadJrProject
    • should: memberProject
    • could: memberGeneral
  • need an example that utilizes Practice Area values

[docs] Document github actions

Overview

We need to add documentation for the github actions being used in this repo for the benefit of developers and maintainers so that they can understand how to read the results in the Actions page.

Action Items

  • Add a page if this is a new topic
  • Add documentation

Instructions

What to include in the documentation

test issue to create card

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Create Table [name of table]

Overview

We need to create the [name of table] 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

Resources/Instructions

Description

No response

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)

    • [name] - [type]
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • [name] - [type]

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)

    • [other_table] ([relationship])
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • None

Pilot row and field level security for READ privileges of users for three roles

Overview

We are planning on including row and field-level security for tables. The required permissions need to be tested before implementation. Row and field level READ privileges for certain fields and roles will be implemented to prove feasibility.

Details

name test case requirement
globalAdmin Can view and update all user info for all users, can create new users, and can de-activate users .Can CRUD anything
adminProject Can view and update all user info for users assigned to the project. Can not view users not related to a project which they are assigned. Cannot update users for projects for which they are not a project admin Can Read and Update anything related to their assigned project
memberProject Can read basic user info for users on the same project. Cannot update information. Can Read anything related to their project that is visible

Action Items

  • implement code needed for FLS (tables, possibly models)
  • test Practice Lead project
  • create test cases for FLS

Resources/Instructions

[docs] Improve contributing docs

Overview

We need better contributing docs so that contributors know what to do and what to expect

Action Items

  • Move most or all sections out of contributing page and create links to them from the page
  • Keep the contributing page short but usable by experienced devs
  • Link to detailed pages for clarification and for inexperienced devs
  • Make sure the clarifications below are part of the docs

Resources/Instructions

  • Things that need clarification
    • The supported workflow
      • fork, create feature branch, work, commit, push to fork, create PR from fork to hackforla/peopledepot/main
    • priority goals for the repo:
      • keep as much history as possible
        • prefer rebase merge over squash merge
      • keep the main branch linear for ease of debug
        • merge commits are hard to follow because commits are in another branch
      • keep the commit history clean
        • avoid fix commits if the original commit is in the same PR. Just redo the original commit to include the fix
          • use fixup messages and rebase to modify the original commits
        • changes should be divided into logical commits
    • Every commit in hackforla/peopledepot/main should be runnable.
      • No WIP commits or nonsense commits
    • The way to test GHA is also to test it in a fork
      • For tests against the project board, get a copy of the board from another team member
    • To keep the hackforla/peopledepot/main branch linear, the acceptable PR merging methods are rebase and squash. This means:
      • It's okay to do merge commits in feature branches, provided that you're okay with having them squashed during the final merge
      • The preferred way is to always do rebase to pull in new code. The individual commits in the feature branch can then be rebased during the final merge, provided they're cleaned up (each commit runs, no fixup commits).

test create issue to see if actions creates a new card

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Add seed data for Table: Permission Type

Dependency

Overview

We need to add seed data for the Permission Type table, because it won't be changing, it's the same for all users of people depot and the information is public

Action Items

  • Read the instructions (resource 1.01)
  • Find the table (resource 1.02), and add it to the resources below (resource 2.01)
  • create the json file
  • convert the json file to python script
  • Combine the script in migration
  • Update the 2.02 & 2.03 links when the pr is merged

Resources

Resources for creating this issue

Resources gathered during the completion of this issue

Create Table: role

Overview

We need to create the role 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

Resources/Instructions

Description

Dictionary of roles

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
    • name - varchar
    • description - varchar
    • responsibilities - varchar
    • qualifications - varchar
    • created - timestamp
    • updated - timestamp
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • none

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 (one-to-many)
    • permission_history (one-to-many)
    • recurring_event (many-to-many array of IDs)
    • user (many-to-many array of IDs)
    • win (many-to-many array of IDs)
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • none

Create Table: [name of table]

Overview

We need to create the [name of table] 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

Details

A table and a model are the same thing

Action Items

  • identify and document table description (see spreadsheet under Resources)
    • if not, reach out to PD leads
  • compare the data fields (below) against the ERD. Check off on the list and note any extras (see Resources)
  • compare the associated tables (below) against the ERD. Check off on the list and note any extras (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

Resources/Instructions

Description

No response

Data Fields

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

    • [name] - [type]
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • [name] - [type]

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)

    • [other_table] ([relationship])
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • None

[docs] Document project structure

Overview

We need to create an explanation page for the project directory structure so that new devs can understand where everything is and should go.

Action Items

  • Add a new page, something like project_structure.md and lay out and explain the project structure

Resources/Instructions

  • docs/ for documentation
  • app/ for the django application and also where the docker container's project root is
  • scripts/ to store helper scripts callable from outside docker
  • etc.

All the project files (some project-specific content omitted)

tree -L 4 -I __pycache__ -I venv -I __init__.py
โ”œโ”€โ”€ app                                                                                                                                                                                                                                        
โ”‚ย ย  โ”œโ”€โ”€ core                                                                                                                                                                                                                                   
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ admin.py                                                                                                                                                                                                                           
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ api                                                                                                                                                                                                                       
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ permissions.py                                                                                                                                                                                                                 
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ serializers.py                                                                                                                                                                                                                 
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ urls.py                                                                                                                                                                                                                        
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ views.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ apps.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ initial_data/
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 0001_initial.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ...
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ max_migration.txt
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ models.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ scripts/
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ tests
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ conftest.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_api.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_models.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ test_permissions.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ utils
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ jwt.py
โ”‚ย ย  โ”œโ”€โ”€ data
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ ...
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ max_migration.txt
โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
โ”‚ย ย  โ”œโ”€โ”€ entrypoint.sh
โ”‚ย ย  โ”œโ”€โ”€ erd.png
โ”‚ย ย  โ”œโ”€โ”€ manage.py
โ”‚ย ย  โ”œโ”€โ”€ peopledepot
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ asgi.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ settings.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ urls.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ wsgi.py
โ”‚ย ย  โ”œโ”€โ”€ requirements.in
โ”‚ย ย  โ”œโ”€โ”€ requirements.txt
โ”‚ย ย  โ”œโ”€โ”€ scripts
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ convert.py
โ”‚ย ย  โ”œโ”€โ”€ setup.cfg
โ”‚ย ย  โ””โ”€โ”€ tmp.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ docs/
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ mkdocs.yml
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ scripts
    โ”œโ”€โ”€ buildrun.sh
    โ”œโ”€โ”€ check-migrations.sh
    โ”œโ”€โ”€ createsuperuser.sh
    โ”œโ”€โ”€ db.sh
    โ”œโ”€โ”€ erd.sh
    โ”œโ”€โ”€ lint.sh
    โ”œโ”€โ”€ loadenv.sh
    โ”œโ”€โ”€ logs.sh
    โ”œโ”€โ”€ migrate.sh
    โ”œโ”€โ”€ precommit-check.sh
    โ”œโ”€โ”€ run.sh
    โ”œโ”€โ”€ start-local.sh
    โ”œโ”€โ”€ test.sh
    โ””โ”€โ”€ update-dependencies.sh
  • scripts, docs, initial data should be documented in their own pages

Test issue automation

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Add SSO

Overview

As an administrator I want to be able to log into People Depot using my SSO account so I don't have to remember the People Depot username and password.

Action Items

  • Implement using allauth package

Test 2 issue automation

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Add Questions for PD Team here if they are not related to a specific issue

Dependency

  • Someone having a question

Overview

We need a place for new project team members to annotate their questions so that we can answer them in writing and then update the wiki

Action Items

  • Add question to a new comment below
    • Move the issue to the questions column on the project board
    • add the label question
  • If you are answering a question, edit the comment and write A: and then the answer.
  • Evaluate if this requires a wiki update.
  • Edit wiki

Resources/Instructions

https://github.com/hackforla/peopledepot/wiki

[docs] Improve contributing docs

Overview

We need better contributing docs so that contributors know what to do and what to expect

Action Items

  • Move most or all sections out of contributing page and create links to them from the page
  • Keep the contributing page short but usable by experienced devs
  • Link to detailed pages for clarification and for inexperienced devs
  • Make sure the clarifications below are part of the docs

Resources/Instructions

  • Things that need clarification
    • The supported workflow
      • fork, create feature branch, work, commit, push to fork, create PR from fork to hackforla/peopledepot/main
    • priority goals for the repo:
      • keep as much history as possible
        • prefer rebase merge over squash merge
      • keep the main branch linear for ease of debug
        • merge commits are hard to follow because commits are in another branch
      • keep the commit history clean
        • avoid fix commits if the original commit is in the same PR. Just redo the original commit to include the fix
          • use fixup messages and rebase to modify the original commits
        • changes should be divided into logical commits
    • Every commit in hackforla/peopledepot/main should be runnable.
      • No WIP commits or nonsense commits
    • The way to test GHA is also to test it in a fork
      • For tests against the project board, get a copy of the board from another team member
    • To keep the hackforla/peopledepot/main branch linear, the acceptable PR merging methods are rebase and squash. This means:
      • It's okay to do merge commits in feature branches, provided that you're okay with having them squashed during the final merge
      • The preferred way is to always do rebase to pull in new code. The individual commits in the feature branch can then be rebased during the final merge, provided they're cleaned up (each commit runs, no fixup commits).

Rename `sponsor_partner` to `affiliate`

Overview

We should rename the sponsor_partner table to something like affiliate. And the project_sponsor_partner_xref table to affiliation or similar. This would simplify and clarify the ideas behind these tables.

Also more clear would be converting the project_sponsor_partner_xref.is_sponsor field to type. See discussion below.

Action Items

ERD, spreadsheet, code changes for each of these

  • rename sponsor_partner to affiliate
  • rename project_sponsor_partner_xref to affiliation. Made part of #65
    • convert the is_sponsor field name to type and make it a choice or enum. Made part of #65

Resources/Instructions

Proposed Changes

  • Rename the project_sponsor_partner_xref table to affiliation or a more appropriate descriptive term for the relationship.
  • Rename the sponsor_partner table to affiliate.
  • Make is_sponsor is a choice like choose between sponsor or partner, and call it type

What the changes give us

Mostly simpler naming for these concepts.

Clearer code when working with the relationship and model.

Example to create a project-affiliate relation

Affiliation.objects.create(project="PeopleDepot", affiliate="Code for America", type="partner")

The current way would look like this

ProjectSponsorPartnerXref.objects.create(project="PeopleDepot", sponsor_partner="Code for America", is_sponsor=False)

Originally posted by @fyliu in hackforla#270 (comment)

Rename `sponsor_partner` to `affiliate`

Overview

We should rename the sponsor_partner table to something like affiliate. And the project_sponsor_partner_xref table to affiliation or similar. This would simplify and clarify the ideas behind these tables.

Also more clear would be converting the project_sponsor_partner_xref.is_sponsor field to type. See discussion below.

Action Items

ERD, spreadsheet, code changes for each of these

  • rename sponsor_partner to affiliate
  • rename project_sponsor_partner_xref to affiliation. Made part of #65
    • convert the is_sponsor field name to type and make it a choice or enum. Made part of #65

Resources/Instructions

Proposed Changes

  • Rename the project_sponsor_partner_xref table to affiliation or a more appropriate descriptive term for the relationship.
  • Rename the sponsor_partner table to affiliate.
  • Make is_sponsor is a choice like choose between sponsor or partner, and call it type

What the changes give us

Mostly simpler naming for these concepts.

Clearer code when working with the relationship and model.

Example to create a project-affiliate relation

Affiliation.objects.create(project="PeopleDepot", affiliate="Code for America", type="partner")

The current way would look like this

ProjectSponsorPartnerXref.objects.create(project="PeopleDepot", sponsor_partner="Code for America", is_sponsor=False)

Originally posted by @fyliu in hackforla#270 (comment)

Test field level permissions

Overview

We are planning on including field-level security for tables. The required permissions need to be tested before implementation.

Action Items

  • implement code needed for FLS (tables, possibly models)
    • create tables
    • add test data
  • test Practice Lead project
  • create test cases for FLS

Resources/Instructions

Pilot row and field level security for READ privileges of users for three roles

Overview

We are planning on including row and field-level security for tables. The required permissions need to be tested before implementation. Row and field level READ privileges for certain fields and roles will be implemented to prove feasibility.

Details

name test case requirement
globalAdmin Can view and update all user info for all users, can create new users, and can de-activate users .Can CRUD anything
adminProject Can view and update all user info for users assigned to the project. Can not view users not related to a project which they are assigned. Cannot update users for projects for which they are not a project admin Can Read and Update anything related to their assigned project
memberProject Can read basic user info for users on the same project. Cannot update information. Can Read anything related to their project that is visible

Action Items

  • implement code needed for FLS (tables, possibly models)
  • test Practice Lead project
  • create test cases for FLS

Resources/Instructions

Prevent users created through self-registration from automatically having access to users.

Overview

As a user I want my information protected by having an administrator in charge of who gets to view my information.

Solution

Add this code to views.py:

class IsStaffUser(BasePermission):
    """
    Custom permission to only allow staff users.
    """

    def has_permission(self, request, view):
        # Check if user is authenticated and is_staff is True
        print("Debug user", request.user.is_staff, request.user.is_authenticated, request.user.is_superuser, request.user.is_active, request.user.is_anonymous, request.user.username, request.user.email, request.user.first_name, request.user.last_name, request.user.is_staff, request.user.is_superuser, request.user.is_active)
        print(request.user.__dict__)
        return request.user.is_staff
    
class IsStaffUserOrReadOnly(BasePermission):
    """
    Custom permission to only allow staff users.
    """

    def has_permission(self, request, view):
        # Check if user is authenticated and is_staff is True
        return request.user.is_staff or request.method in SAFE_METHODS 
    
Then change permission_classes[IsAuthenticated] to permision_classes[IsStaffUser]

Prevent users who are not granted updated privileges through roles for a table from updating that table

Overview

As a user I want only authorized users to update information so that the information is accurate.

Solution

  • Sample code for preventing unauthorized updates
    if not request.user.has_perm('core.change_practice_area'):
        # If the user doesn't have permission, return forbidden response
       return HttpResponseForbidden("You don't have permission to update practice area.")

Similar code can be written for creating and deleting.

Action Items

  • Implement code
  • Write tests

[docs] How to combine migrations before merging a PR

Overview

We need to add documentation for how to combine migrations before merging a PR for the benefit of developers so that they can refer to the guide as needed.

Action Items

  • Add a page if this is a new topic
  • Add documentation

Instructions

When doing PRs involving django models, sometimes the requested changes cause django to generate more migration files. To keep things simpler, it's recommended to combine migrations as much as possible at the end of the PR process so that there's one or very few migrations to merge. Follow these steps to merge all the PR migrations into one.

  1. Check the new migrations created for the PR

    ls app/core/migrations/
    

    Let's say the PR created 0022-0027 in the core app

    ...
    Applying core.0020_rename_is_sponsor_sponsorpartner_is_org_partner_and_more... OK                                                                                                                                                            
    Applying core.0021_sdg... OK                                                                                                                                                                                                                 
    Applying core.0022_alter_sponsorpartner_table_affiliation_and_more... OK                                                                                                                                                                     
    Applying core.0023_rename_sponsorpartner_affiliate_and_more... OK                                                                                                                                                                            
    Applying core.0024_rename_is_sponsor_affiliation_affiliation_type... OK                                                                                                                                                                      
    Applying core.0025_remove_affiliation_affiliation_type_and_more... OK                                                                                                                                                                        
    Applying core.0026_alter_affiliation_created_at_alter_affiliate_table... OK                                                                                                                                                                  
    Applying core.0027_alter_affiliation_created_at... OK                                                                                                                                                                                        
    ...
  2. Undo the migrations back to before the PR

    docker-compose exec web python manage.py migrate core 0021
    
  3. Delete the migration files

    rm app/core/migrations/{0022*,0023*,0024*,0025*,0026*,0027*}
    
  4. Reset the max_migration.txt back to before the PR branch (assuming that's the current upstream/main)

    git checkout upstream/main -- app/core/migrations/max_migration.txt
    
  5. Generate the combined migration file and apply it

    docker-compose exec web python manage.py makemigrations
    docker-compose exec web python manage.py migrate
    

Add seed data for Table: Permission Type

Dependency

Overview

We need to add seed data for the Permission Type table, because it won't be changing, it's the same for all users of people depot and the information is public

Action Items

  • Read the instructions (resource 1.01)
  • Find the table (resource 1.02), and add it to the resources below (resource 2.01)
  • create the json file
  • convert the json file to python script
  • Combine the script in migration
  • Update the 2.02 & 2.03 links when the pr is merged

Resources

Resources for creating this issue

Resources gathered during the completion of this issue

[docs] Document github actions

Overview

We need to add documentation for the github actions being used in this repo for the benefit of developers and maintainers so that they can understand how to read the results in the Actions page.

Action Items

  • Add a page if this is a new topic
  • Add documentation

Instructions

What to include in the documentation

Test field level permissions

Overview

We are planning on including field-level security for tables. The required permissions need to be tested before implementation.

Action Items

  • implement code needed for FLS (tables, possibly models)
    • create tables
    • add test data
  • test Practice Lead project
  • create test cases for FLS

Resources/Instructions

Add Questions for PD Team here if they are not related to a specific issue

Dependency

  • Someone having a question

Overview

We need a place for new project team members to annotate their questions so that we can answer them in writing and then update the wiki

Action Items

  • Add question to a new comment below
    • Move the issue to the questions column on the project board
    • add the label question
  • If you are answering a question, edit the comment and write A: and then the answer.
  • Evaluate if this requires a wiki update.
  • Edit wiki

Resources/Instructions

https://github.com/hackforla/peopledepot/wiki

Update project configs for deployment

Overview

We need to improve the project configuration so that it is ready for deployment.

Action Items

  • work though the deployment checklist to be able to switch the project from DEBUG to production using an environment variable
  • Check off this issue's item in #218

Resources/Instructions

test issue to create card2

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

Create Table [name of table]

Overview

We need to create the [name of table] 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

Details

A table and a model are the same thing

Action Items

  • identify and document table description (see spreadsheet under Resources)
    • if not, reach out to PD leads
  • compare the data fields (below) against the ERD. Check off on the list and note any extras (see Resources)
  • compare the associated tables (below) against the ERD. Check off on the list and note any extras (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

Resources/Instructions

Description

No response

Data Fields

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

    • [name] - [type]
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • [name] - [type]

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)

    • [other_table] ([relationship])
  2. In ERD only (having items here indicates a mismatch, which requires a review)

    • None

Prevent users who are not granted updated privileges through roles for a table from updating that table

Overview

As a user I want only authorized users to update information so that the information is accurate.

Solution

  • Sample code for preventing unauthorized updates
    if not request.user.has_perm('core.change_practice_area'):
        # If the user doesn't have permission, return forbidden response
       return HttpResponseForbidden("You don't have permission to update practice area.")

Similar code can be written for creating and deleting.

Action Items

  • Implement code
  • Write tests

Move all documentation either to markdown or Wiki

Overview

Briefly describe the purpose of this issue.

Action Items

If this is a new issue, describe what research and documentation are likely needed.

If this is an existing issue, describe the steps and course of actions. If this is a complex issue, maybe it'd be helpful to divide into separate issues.

Resources/Instructions

Documentation or websites that can be helpful.

[docs] How to combine migrations before merging a PR

Overview

We need to add documentation for how to combine migrations before merging a PR for the benefit of developers so that they can refer to the guide as needed.

Action Items

  • Add a page if this is a new topic
  • Add documentation

Instructions

When doing PRs involving django models, sometimes the requested changes cause django to generate more migration files. To keep things simpler, it's recommended to combine migrations as much as possible at the end of the PR process so that there's one or very few migrations to merge. Follow these steps to merge all the PR migrations into one.

  1. Check the new migrations created for the PR

    ls app/core/migrations/
    

    Let's say the PR created 0022-0027 in the core app

    ...
    Applying core.0020_rename_is_sponsor_sponsorpartner_is_org_partner_and_more... OK                                                                                                                                                            
    Applying core.0021_sdg... OK                                                                                                                                                                                                                 
    Applying core.0022_alter_sponsorpartner_table_affiliation_and_more... OK                                                                                                                                                                     
    Applying core.0023_rename_sponsorpartner_affiliate_and_more... OK                                                                                                                                                                            
    Applying core.0024_rename_is_sponsor_affiliation_affiliation_type... OK                                                                                                                                                                      
    Applying core.0025_remove_affiliation_affiliation_type_and_more... OK                                                                                                                                                                        
    Applying core.0026_alter_affiliation_created_at_alter_affiliate_table... OK                                                                                                                                                                  
    Applying core.0027_alter_affiliation_created_at... OK                                                                                                                                                                                        
    ...
  2. Undo the migrations back to before the PR

    docker-compose exec web python manage.py migrate core 0021
    
  3. Delete the migration files

    rm app/core/migrations/{0022*,0023*,0024*,0025*,0026*,0027*}
    
  4. Reset the max_migration.txt back to before the PR branch (assuming that's the current upstream/main)

    git checkout upstream/main -- app/core/migrations/max_migration.txt
    
  5. Generate the combined migration file and apply it

    docker-compose exec web python manage.py makemigrations
    docker-compose exec web python manage.py migrate
    

[docs] Document project structure

Overview

We need to create an explanation page for the project directory structure so that new devs can understand where everything is and should go.

Action Items

  • Add a new page, something like project_structure.md and lay out and explain the project structure

Resources/Instructions

  • docs/ for documentation
  • app/ for the django application and also where the docker container's project root is
  • scripts/ to store helper scripts callable from outside docker
  • etc.

All the project files (some project-specific content omitted)

tree -L 4 -I __pycache__ -I venv -I __init__.py
โ”œโ”€โ”€ app                                                                                                                                                                                                                                        
โ”‚ย ย  โ”œโ”€โ”€ core                                                                                                                                                                                                                                   
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ admin.py                                                                                                                                                                                                                           
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ api                                                                                                                                                                                                                       
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ permissions.py                                                                                                                                                                                                                 
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ serializers.py                                                                                                                                                                                                                 
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ urls.py                                                                                                                                                                                                                        
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ views.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ apps.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ initial_data/
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 0001_initial.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ...
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ max_migration.txt
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ models.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ scripts/
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ tests
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ conftest.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_api.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_models.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ test_permissions.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ utils
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ jwt.py
โ”‚ย ย  โ”œโ”€โ”€ data
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ ...
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ max_migration.txt
โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
โ”‚ย ย  โ”œโ”€โ”€ entrypoint.sh
โ”‚ย ย  โ”œโ”€โ”€ erd.png
โ”‚ย ย  โ”œโ”€โ”€ manage.py
โ”‚ย ย  โ”œโ”€โ”€ peopledepot
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ asgi.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ settings.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ urls.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ wsgi.py
โ”‚ย ย  โ”œโ”€โ”€ requirements.in
โ”‚ย ย  โ”œโ”€โ”€ requirements.txt
โ”‚ย ย  โ”œโ”€โ”€ scripts
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ convert.py
โ”‚ย ย  โ”œโ”€โ”€ setup.cfg
โ”‚ย ย  โ””โ”€โ”€ tmp.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ docs/
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ mkdocs.yml
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ scripts
    โ”œโ”€โ”€ buildrun.sh
    โ”œโ”€โ”€ check-migrations.sh
    โ”œโ”€โ”€ createsuperuser.sh
    โ”œโ”€โ”€ db.sh
    โ”œโ”€โ”€ erd.sh
    โ”œโ”€โ”€ lint.sh
    โ”œโ”€โ”€ loadenv.sh
    โ”œโ”€โ”€ logs.sh
    โ”œโ”€โ”€ migrate.sh
    โ”œโ”€โ”€ precommit-check.sh
    โ”œโ”€โ”€ run.sh
    โ”œโ”€โ”€ start-local.sh
    โ”œโ”€โ”€ test.sh
    โ””โ”€โ”€ update-dependencies.sh
  • scripts, docs, initial data should be documented in their own pages

Update project configs for deployment

Overview

We need to improve the project configuration so that it is ready for deployment.

Action Items

  • work though the deployment checklist to be able to switch the project from DEBUG to production using an environment variable
  • Check off this issue's item in #218

Resources/Instructions

Adjust pre-commit settings

Overview

Adjust pre-commit settings to resolve some issues

Action Items

  • ignore github issue template files
  • set pre-commit.ci to run quarterly from weekly

Resources/Instructions

  • ignore github issue template files because mdformat is doing the wrong thing for square brackets (it should not try to escape them)

image

  • we should unignore this when mdformat does the right thing

  • set pre-commit.ci to run quarterly from weekly because weekly is too often to update syntax checkers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.