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 staff_tenant resource #443

Closed
5 of 6 tasks
NickSchimek opened this issue Nov 18, 2020 · 0 comments · Fixed by codeforpdx/dwellinglybackend#154
Closed
5 of 6 tasks

Create staff_tenant resource #443

NickSchimek opened this issue Nov 18, 2020 · 0 comments · Fixed by codeforpdx/dwellinglybackend#154
Assignees
Labels

Comments

@NickSchimek
Copy link
Member

NickSchimek commented Nov 18, 2020

Description
A bulk update on the staff_tenant_link table is required per the figma designs. See issue /issues/439 for more details.

Create a staff_tenant resource with the following url /staff-tenants that will accept a PATCH request with following payload structure:

{
staff: [<int:staff_id>, ...],
tenants: [<int:tenant_id>, ...]
}

The patch action will:

  • remove all rows in the staff_tenant_link table that exists for each given tenant id if any exist.
  • For each tenant id: Create a staff_tenant relationship for each provided staff id.

The above commands should all be performed within a single transaction (ex: call db.commit once) so that if there is an issue on commit it can be easily rolled back, and an appropriate error message sent to the frontend.

Possible validations to include:

  • Verify the provided staff id's are indeed Staff members.
  • Verify the provided tenant id's exist.

We probably wont be able to use any of the convenient methods defined in the BaseModel. May need to directly communicate with the db.session to add/remove objects from the session and the call db.session.commit() to commit all bulk changes in a single transaction.

See sqlalchemy docs:

Acceptance Criteria
Please list the requirements the implementation of this feature should meet.

  • Create schema and schema test file for validations
  • Create integration tests for new route
  • Create new route
  • Create patch action
  • Update README
  • Complete request in a single transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant