diff --git a/README.md b/README.md index 86bd3c4d..c35af40b 100644 --- a/README.md +++ b/README.md @@ -55,15 +55,17 @@ cd supportive-housing docker-compose up --build ``` -4. Create an Admin user. In `seeding/.env`, ensure `FIRST_NAME`, `LAST_NAME`, and `EMAIL` are set (you should use your Blueprint email/any email you have access to here). Ensure `ROLE` is set to `Admin`. Run: +4. Run the initial migration: `bash ./scripts/flask-db-upgrade.sh` + +5. Create an Admin user. In `seeding/.env`, ensure `FIRST_NAME`, `LAST_NAME`, and `EMAIL` are set (you should use your Blueprint email/any email you have access to here). Ensure `ROLE` is set to `Admin`. Run: ```bash bash ./seeding/invite-user.sh ``` **IMPORTANT**: If you've reset your local DB and want to re-use an email, ensure it's deleted from Firebase as well (ask the PL for access if you don't have it) -5. Signup for an account on the app! Ensure that you use the values you used in Step 3. Your password can be anything you remember +6. Signup for an account on the app! Ensure that you use the values you used in Step 3. Your password can be anything you remember -6. Verify your email address. You should receive an email in your inbox with a link - once you click the link, you're good to freely use the app! You can invite any other users through the `Employee Directory` within the `Admin Controls` +7. Verify your email address. You should receive an email in your inbox with a link - once you click the link, you're good to freely use the app! You can invite any other users through the `Employee Directory` within the `Admin Controls` ## Useful Commands diff --git a/backend/app/models/log_record_tags.py b/backend/app/models/log_record_tags.py index e052e234..4cc188ef 100644 --- a/backend/app/models/log_record_tags.py +++ b/backend/app/models/log_record_tags.py @@ -11,7 +11,7 @@ class LogRecordTag(db.Model): log_record_id = db.Column( db.Integer, db.ForeignKey("log_records.log_id"), nullable=False ) - tag_id = db.Column(db.Integer, db.ForeignKey("tags.tag_id"), nullable=False) + tag_id = db.Column(db.Integer, db.ForeignKey("tags.tag_id", ondelete='CASCADE'), nullable=False) def to_dict(self, include_relationships=False): # define the entities table diff --git a/backend/app/services/implementations/tags_service.py b/backend/app/services/implementations/tags_service.py index 86b7fe00..fbd7abcc 100644 --- a/backend/app/services/implementations/tags_service.py +++ b/backend/app/services/implementations/tags_service.py @@ -1,5 +1,6 @@ from ..interfaces.tags_service import ITagsService from ...models.tags import Tag +from ...models.log_record_tags import LogRecordTag from ...models import db @@ -26,9 +27,13 @@ def get_tags(self): raise postgres_error def delete_tag(self, tag_id): - deleted_tag = Tag.query.filter_by(tag_id=tag_id).update({"status": "Deleted"}) - if not deleted_tag: - raise Exception("Tag with id {tag_id} not found".format(tag_id=tag_id)) + tags_to_delete = Tag.query.filter_by(tag_id=tag_id).first() + if not tags_to_delete: + raise Exception( + "Log record with id {log_id} not found".format(log_id=log_id) + ) + tags_to_delete.log_records = [] + db.session.delete(tags_to_delete) db.session.commit() def update_tag(self, tag_id, updated_tag): diff --git a/backend/migrations/versions/117790caec65_.py b/backend/migrations/versions/117790caec65_.py new file mode 100644 index 00000000..9905f14c --- /dev/null +++ b/backend/migrations/versions/117790caec65_.py @@ -0,0 +1,32 @@ +"""empty message + +Revision ID: 117790caec65 +Revises: 8b5132609f1f +Create Date: 2023-11-16 01:53:04.353305 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '117790caec65' +down_revision = '8b5132609f1f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('tags', schema=None) as batch_op: + batch_op.drop_column('status') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('tags', schema=None) as batch_op: + batch_op.add_column(sa.Column('status', postgresql.ENUM('Deleted', 'Active', name='status'), autoincrement=False, nullable=False)) + + # ### end Alembic commands ### diff --git a/frontend/src/components/common/Pagination.tsx b/frontend/src/components/common/Pagination.tsx index c519a1eb..5f6fa1d9 100644 --- a/frontend/src/components/common/Pagination.tsx +++ b/frontend/src/components/common/Pagination.tsx @@ -40,7 +40,7 @@ const Pagination = ({ setResultsPerPage, getRecords, }: Props): React.ReactElement => { - const numPages = Math.ceil(numRecords / resultsPerPage); + const numPages = Math.ceil(Math.max(1, numRecords) / resultsPerPage); const handleNumberInputChange = ( newUserPageNumString: string, diff --git a/frontend/src/components/forms/Login.tsx b/frontend/src/components/forms/Login.tsx index 06f09234..4ac917e4 100644 --- a/frontend/src/components/forms/Login.tsx +++ b/frontend/src/components/forms/Login.tsx @@ -103,18 +103,16 @@ const Login = ({ } if (toggle) { - // Lock scroll - document.body.style.overflow = "hidden"; return ( - + - + Log In @@ -153,14 +151,16 @@ const Login = ({ > Log In - - - Not a member yet? - - - Sign Up Now - - + + + + Not a member yet? + + + Sign Up Now + + + diff --git a/frontend/src/components/forms/Signup.tsx b/frontend/src/components/forms/Signup.tsx index 7d8d471c..fef5c5a0 100644 --- a/frontend/src/components/forms/Signup.tsx +++ b/frontend/src/components/forms/Signup.tsx @@ -143,84 +143,89 @@ const Signup = ({ return ; } - if (toggle) { + if (toggle) { return ( - - - - Sign Up - - setFirstName(event.target.value)} - /> - setLastName(event.target.value)} - /> - + + + Sign Up + + + setFirstName(event.target.value)} /> - {emailErrorStr} - - + + setLastName(event.target.value)} /> - {passwordErrorStr} - - - - + + + + + {emailErrorStr} + + + + + + {passwordErrorStr} + + + + + + + + Already have an account? Log In Now - + diff --git a/frontend/src/theme/forms/inputStyles.tsx b/frontend/src/theme/forms/inputStyles.tsx index 9211c3d3..de142516 100644 --- a/frontend/src/theme/forms/inputStyles.tsx +++ b/frontend/src/theme/forms/inputStyles.tsx @@ -39,7 +39,7 @@ const Input: ComponentStyleConfig = { border: "1px solid", borderColor: "gray.100", borderRadius: "4px", - height: "7vh", + height: "8vh", fontWeight: "400", fontSize: "22px", fontFamily: "DM Sans", diff --git a/scripts/exec-db.sh b/scripts/exec-db.sh old mode 100644 new mode 100755