Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into braydon/connect-tags-log-record
  • Loading branch information
braydonwang committed Nov 30, 2023
2 parents c7d6457 + 435b9dc commit 37491b1
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 84 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backend/app/models/log_record_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions backend/app/services/implementations/tags_service.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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):
Expand Down
32 changes: 32 additions & 0 deletions backend/migrations/versions/117790caec65_.py
Original file line number Diff line number Diff line change
@@ -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 ###
2 changes: 1 addition & 1 deletion frontend/src/components/common/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 13 additions & 13 deletions frontend/src/components/forms/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,16 @@ const Login = ({
}

if (toggle) {
// Lock scroll
document.body.style.overflow = "hidden";
return (
<Flex h="100vh">
<Flex>
<Box w="47%">
<Flex
marginTop="270px"
height="100vh"
display="flex"
align="center"
justify="center"
>
<Flex width="76%" align="flex-start" direction="column" gap="28px">
<Flex width="80%" align="flex-start" direction="column" gap="28px">
<Text variant="login" paddingBottom="12px">
Log In
</Text>
Expand Down Expand Up @@ -153,14 +151,16 @@ const Login = ({
>
Log In
</Button>
<Flex paddingTop="29px" alignContent="center">
<Text variant="loginSecondary" paddingRight="17px">
Not a member yet?
</Text>
<Text variant="loginTertiary" onClick={onSignUpClick}>
Sign Up Now
</Text>
</Flex>
<Box w="80%">
<Flex gap="10px">
<Text variant="loginSecondary" paddingRight="17px">
Not a member yet?
</Text>
<Text variant="loginTertiary" onClick={onSignUpClick}>
Sign Up Now
</Text>
</Flex>
</Box>
</Flex>
</Flex>
</Box>
Expand Down
129 changes: 67 additions & 62 deletions frontend/src/components/forms/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,84 +143,89 @@ const Signup = ({
return <Redirect to={HOME_PAGE} />;
}

if (toggle) {
if (toggle) {
return (
<Flex h="100vh">
<Box w="47%">
<Flex
marginTop="172px"
display="flex"
align="center"
justify="center"
<Flex
h="100%"
direction="column"
justifyContent="center"
alignItems="center"
gap="28px"
>
<Flex
width="76%"
align="flex-start"
direction="column"
gap="28px"
>
<Text variant="login" paddingBottom="12px">
Sign Up
</Text>
<Input
variant="login"
placeholder="Your first name"
value={firstName}
onChange={(event) => setFirstName(event.target.value)}
/>
<Input
variant="login"
placeholder="Your last name"
value={lastName}
onChange={(event) => setLastName(event.target.value)}
/>
<FormControl isRequired isInvalid={emailError}>
<Box w="80%" textAlign="left">
<Text variant="login">
Sign Up
</Text>
</Box>
<Box w="80%">
<Input
variant="login"
placeholder="Your email"
value={email}
onChange={handleEmailChange}
placeholder="Your first name"
value={firstName}
onChange={(event) => setFirstName(event.target.value)}
/>
<FormErrorMessage>{emailErrorStr}</FormErrorMessage>
</FormControl>
<FormControl isRequired isInvalid={passwordError}>
</Box>
<Box w="80%">
<Input
variant="login"
type="password"
placeholder="Your password"
value={password}
onChange={handlePasswordChange}
placeholder="Your last name"
value={lastName}
onChange={(event) => setLastName(event.target.value)}
/>
<FormErrorMessage>{passwordErrorStr}</FormErrorMessage>
</FormControl>
<Button
variant="login"
disabled={isCreateAccountBtnDisabled()}
_hover={
email && password && firstName && lastName
? {
background: "teal.500",
transition:
"transition: background-color 0.5s ease !important",
}
: {}
}
onClick={onSignupClick}
>
Create Account
</Button>
<Flex
paddingTop="29px"
alignContent="center"
>
<Text variant="loginSecondary" paddingRight="17px">
</Box>
<Box w="80%">
<FormControl isRequired isInvalid={emailError}>
<Input
variant="login"
placeholder="Your email"
value={email}
onChange={handleEmailChange}
/>
<FormErrorMessage>{emailErrorStr}</FormErrorMessage>
</FormControl>
</Box>
<Box w="80%">
<FormControl isRequired isInvalid={passwordError}>
<Input
variant="login"
type="password"
placeholder="Your password"
value={password}
onChange={handlePasswordChange}
/>
<FormErrorMessage>{passwordErrorStr}</FormErrorMessage>
</FormControl>
</Box>
<Box w="80%">
<Button
variant="login"
disabled={isCreateAccountBtnDisabled()}
_hover={
email && password && firstName && lastName
? {
background: "teal.500",
transition:
"transition: background-color 0.5s ease !important",
}
: {}
}
onClick={onSignupClick}
>
Create Account
</Button>
</Box>
<Box w="80%">
<Flex gap="10px">
<Text variant="loginSecondary" paddingRight="1.1vw">
Already have an account?
</Text>
<Text variant="loginTertiary" onClick={onLogInClick}>
Log In Now
</Text>
</Flex>
</Flex>
</Box>
</Flex>
</Box>
<Box flex="1" bg="teal.400">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/theme/forms/inputStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Empty file modified scripts/exec-db.sh
100644 → 100755
Empty file.

0 comments on commit 37491b1

Please sign in to comment.