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

ASP dashboard list view UI #92

Merged
merged 58 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3648d6d
Implement main list view
ansonjwhe Aug 12, 2023
8b4357d
create dashboard view
ansonjwhe Aug 12, 2023
34f1fec
add primary contact and delivery instructions
ansonjwhe Aug 19, 2023
437adcb
update test
ansonjwhe Aug 19, 2023
fdc0695
Changed node version to attempt to fix build issue
shahanneda Sep 2, 2023
b2ceb2c
Added babel to fix import error in test
shahanneda Sep 2, 2023
fa9eda8
Merge remote-tracking branch 'origin/main' into asp-dashboard-list-vi…
shahanneda Nov 2, 2023
0ef8e9b
fixed merge conflicts
shahanneda Nov 2, 2023
074b6b4
Connect meal requests to backend
jarydo Nov 14, 2023
da87577
Add meal request types
jarydo Nov 14, 2023
0553def
Add loading spinner
jarydo Nov 14, 2023
8bf63c0
Sort and filter button styling, lint
jarydo Nov 14, 2023
0c51c03
Add sort and filter button options
jarydo Nov 16, 2023
61b51af
Add filter + sort functionality
jarydo Dec 5, 2023
2f5b5f9
Add pagination UI
jarydo Dec 5, 2023
2893545
Add pagination + error handling
jarydo Dec 7, 2023
3ebd16c
Merge remote-tracking branch 'origin/main' into asp-dashboard-list-vi…
shahanneda Dec 7, 2023
d7a28ce
fixed merge conflicts and added create meal request button
shahanneda Dec 7, 2023
27efa57
deleted sample data
shahanneda Dec 7, 2023
41ce1d7
Add ListView component
jarydo Dec 8, 2023
fefa69e
Lint
jarydo Dec 8, 2023
57a37c3
Sort by drop off datetime
jarydo Dec 8, 2023
97bf741
Merge remote-tracking branch 'origin/main' into asp-dashboard-list-vi…
shahanneda Dec 24, 2023
551ce9c
Added Upcoming meal status
shahanneda Dec 28, 2023
24a7a17
added get_meal_request_by_id query
shahanneda Dec 29, 2023
5620eaa
Started querying data on edit meal request page
shahanneda Dec 31, 2023
dc90535
finished basic editing
shahanneda Dec 31, 2023
b598fda
Fixed tests from failing duo to gecoding
shahanneda Jan 1, 2024
5be6111
removed console logs
shahanneda Jan 9, 2024
3030845
added create onsite contact mutation
shahanneda Jan 10, 2024
01f47b3
added test for creating contact
shahanneda Jan 12, 2024
e231992
worked on onsite contact service and queries
shahanneda Jan 14, 2024
054d3d4
added tests for onsite contact functions
shahanneda Jan 14, 2024
8d7031c
Added mypy typings, and migrated onsite contacts to initial onsite
shahanneda Jan 22, 2024
5349573
Finished settings page and fixed meal requests to work with new conta…
shahanneda Feb 12, 2024
6fd2eaa
Moved create meal request form to new onsite contact system.
shahanneda Feb 14, 2024
ea0efb3
Added onsite contact editing to meal request edit page
shahanneda Feb 14, 2024
eea4357
Renamed dashboard page
shahanneda Feb 14, 2024
789b260
Merge remote-tracking branch 'origin/main' into asp-dashboard-list-vi…
shahanneda Feb 14, 2024
0ac038f
fixed lint
shahanneda Feb 14, 2024
0dfafad
Ran backend lint
shahanneda Feb 14, 2024
21ee90e
fixed be lint errors
shahanneda Feb 14, 2024
f6a758f
fixed lint ignore
shahanneda Feb 14, 2024
7808c38
tried fixing lint typings
shahanneda Feb 14, 2024
c20060e
Updated actions
shahanneda Feb 17, 2024
4038769
added typings to exclude file again
shahanneda Feb 17, 2024
99bcbac
updated actions
shahanneda Feb 17, 2024
6ebc683
try full path
shahanneda Feb 17, 2024
ed16529
try removing lint step
shahanneda Feb 17, 2024
80d668d
add back black step
shahanneda Feb 17, 2024
6b77ee0
fix black
shahanneda Feb 17, 2024
e2dbb5b
Update exclude expression
shahanneda Feb 17, 2024
7c54d07
Updated exclude
shahanneda Feb 17, 2024
46d0fe1
Try exclude change
shahanneda Feb 17, 2024
bc5202d
fix typo
shahanneda Feb 17, 2024
1d03008
Added back flake8
shahanneda Feb 17, 2024
ba1d819
Commented dashboard page
shahanneda Feb 17, 2024
29e6fc2
Added test admin
shahanneda Feb 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Lint codebase

on:
Expand Down Expand Up @@ -52,4 +51,4 @@ jobs:
- name: Lint backend
if: steps.changes.outputs.backend == 'true'
working-directory: ./backend
run: pip install black flake8 && python -m black --check . && python -m flake8 .
run: pip install black flake8 && python -m black --check . --exclude ".*typings.*|test_csv.py" && flake8 .
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
**/*.cache
**/*.egg-info
**/*.eslintcache
**/*.swp
**/*.swp
**/.mypy_cache/**
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/feeding-canadian-kids.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,18 @@ docker-compose up --build

The backend runs at http://localhost:5000 and the frontend runs at http://localhost:3000.

If you need to login as a user, there is a user in the development db: `[email protected]` with password `12345678`.
### Test Users

Password For all test accounts: `12345678`

Test ASP:
Email: `[email protected]`

Test Donor:
Email: `[email protected]`

Test Admin:
Email: `[email protected]`

## Useful Commands

Expand Down
1 change: 0 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM python:3.8

WORKDIR /app

COPY requirements.txt ./
Expand Down
6 changes: 3 additions & 3 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ test:
docker ps -qf name=fck_backend | grep "." > /dev/null || (echo "****** Run \`docker-compose up\` first! ******" && false)
# Add -s to the end of this next line to see all prints when testing
# i.e "... python -m pytest -s"
docker exec -it fck_backend /bin/bash -c "pip install -r requirements.txt && python -m pytest"

docker exec -it fck_backend /bin/bash -c "pip install -r requirements.txt && python -m pytest -s"
lint:
docker ps -qf name=fck_backend | grep "." > /dev/null || (echo "****** Run \`docker-compose up\` first! ******" && false)
docker exec -it fck_backend /bin/bash -c "black . && flake8 ."
docker exec -it fck_backend /bin/bash -c "black . && flake8 . --exclude **/typings/**"

16 changes: 14 additions & 2 deletions backend/app/graphql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
import os

from flask import current_app


from .onsite_contact_mutations import OnsiteContactMutations
from .onsite_contact_queries import OnsiteContactQueries
from .example import ExampleQueries, ExampleMutations
from .user_queries import UserQueries
from .user_mutations import UserMutations
from .services import services
from ..services.implementations.user_service import UserService
from ..services.implementations.email_service import EmailService
from ..services.implementations.auth_service import AuthService
from ..services.implementations.onsite_contact_service import OnsiteContactService
from .auth import AuthMutations
from .meal_request import MealRequestMutations, MealRequestQueries
from ..services.implementations.meal_request_service import MealRequestService
Expand All @@ -24,6 +29,7 @@ class RootQuery(
UserQueries,
OnboardingRequestQueries,
MealRequestQueries,
OnsiteContactQueries,
):
pass

Expand All @@ -35,6 +41,7 @@ class RootMutation(
OnboardingRequestMutations,
MealRequestMutations,
UserMutations,
OnsiteContactMutations,
):
pass

Expand All @@ -48,7 +55,6 @@ class RootMutation(
def init_app(app):
with app.app_context():
# Add your services here: services["service_name"] = ...
services["user_service"] = UserService(logger=current_app.logger)
services["email_service"] = EmailService(
logger=current_app.logger,
credentials={
Expand All @@ -60,6 +66,13 @@ def init_app(app):
sender_email=os.getenv("MAILER_USER"),
display_name="Feeding Canadian Kids",
)
services["onsite_contact_service"] = OnsiteContactService(
logger=current_app.logger
)
services["user_service"] = UserService(
logger=current_app.logger,
onsite_contact_service=services["onsite_contact_service"],
)
services["auth_service"] = AuthService(
logger=current_app.logger,
user_service=services["user_service"],
Expand All @@ -69,4 +82,3 @@ def init_app(app):
logger=current_app.logger, email_service=services["email_service"]
)
services["meal_request_service"] = MealRequestService(logger=current_app.logger)
services["user_service"] = UserService(logger=current_app.logger)
47 changes: 32 additions & 15 deletions backend/app/graphql/meal_request.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import graphene

from .types import (
ContactInput,
Contact,
Mutation,
MutationList,
OnsiteContact,
QueryList,
SortDirection,
User,
)
from ..models.meal_request import MealStatus, MEAL_STATUSES
from ..models.meal_request import MEAL_STATUSES_ENUMS, MealStatus
from ..graphql.services import services

# Input Types
Expand All @@ -34,8 +33,9 @@ class MealInfoResponse(graphene.ObjectType):
class CreateMealRequestResponse(graphene.ObjectType):
id = graphene.ID()
drop_off_datetime = graphene.DateTime(required=True)
status = graphene.String(required=True)
status = graphene.Field(graphene.Enum.from_enum(MealStatus), required=True)
meal_info = graphene.Field(MealInfoResponse, required=True)
onsite_staff = graphene.List(OnsiteContact)


class DonationInfo(graphene.ObjectType):
Expand All @@ -48,11 +48,11 @@ class DonationInfo(graphene.ObjectType):
class MealRequestResponse(graphene.ObjectType):
id = graphene.ID()
requestor = graphene.Field(User)
status = graphene.String()
status = graphene.Field(graphene.Enum.from_enum(MealStatus), required=True)
drop_off_datetime = graphene.DateTime()
drop_off_location = graphene.String()
meal_info = graphene.Field(MealInfoResponse)
onsite_staff = graphene.List(Contact)
onsite_staff = graphene.List(OnsiteContact)
date_created = graphene.DateTime()
date_updated = graphene.DateTime()
delivery_instructions = graphene.String()
Expand All @@ -70,7 +70,7 @@ class Arguments:
drop_off_time = graphene.Time(required=True)
drop_off_location = graphene.String(required=True)
delivery_instructions = graphene.String(default_value=None)
onsite_staff = graphene.List(ContactInput, required=True)
onsite_staff = graphene.List(graphene.String, default_value=[])

# return values
meal_requests = graphene.List(CreateMealRequestResponse)
Expand Down Expand Up @@ -102,12 +102,12 @@ def mutate(
class UpdateMealRequest(Mutation):
class Arguments:
meal_request_id = graphene.ID(required=True)
requestor = graphene.ID(required=False)
requestor_id = graphene.ID(required=False)
drop_off_datetime = graphene.DateTime(required=False)
meal_info = MealTypeInput()
drop_off_location = graphene.String()
delivery_instructions = graphene.String()
onsite_staff = graphene.List(ContactInput)
onsite_staff = graphene.List(graphene.String)

# return values
meal_request = graphene.Field(MealRequestResponse)
Expand All @@ -116,15 +116,15 @@ def mutate(
self,
info,
meal_request_id,
requestor=None,
requestor_id: str,
drop_off_datetime=None,
meal_info=None,
drop_off_location=None,
delivery_instructions=None,
onsite_staff=None,
):
result = services["meal_request_service"].update_meal_request(
requestor=requestor,
requestor_id=requestor_id,
meal_info=meal_info,
drop_off_datetime=drop_off_datetime,
drop_off_location=drop_off_location,
Expand All @@ -138,7 +138,7 @@ def mutate(

class CommitToMealRequest(Mutation):
class Arguments:
requester = graphene.ID(required=True)
requestor = graphene.ID(required=True)
meal_request_ids = graphene.List(graphene.ID, required=True)
meal_description = graphene.String(required=True)
additional_info = graphene.String(default_value=None)
Expand All @@ -148,13 +148,13 @@ class Arguments:
def mutate(
self,
info,
requester,
requestor,
meal_request_ids,
meal_description,
additional_info=None,
):
result = services["meal_request_service"].commit_to_meal_request(
donor_id=requester,
donor_id=requestor,
meal_request_ids=meal_request_ids,
meal_description=meal_description,
additional_info=additional_info,
Expand All @@ -175,15 +175,32 @@ class MealRequestQueries(QueryList):
requestor_id=graphene.ID(required=True),
min_drop_off_date=graphene.Date(default_value=None),
max_drop_off_date=graphene.Date(default_value=None),
# status=graphene.List(graphene.Enum.from_enum(MealStatus)),
status=graphene.List(
graphene.Enum.from_enum(MealStatus),
default_value=MEAL_STATUSES,
# MealStatus,
default_value=MEAL_STATUSES_ENUMS,
),
offset=graphene.Int(default_value=0),
limit=graphene.Int(default_value=None),
sort_by_date_direction=SortDirection(default_value=SortDirection.ASCENDING),
)

getMealRequestById = graphene.Field(
MealRequestResponse,
requestor_id=graphene.ID(required=True),
id=graphene.ID(required=True),
)

def resolve_getMealRequestById(
self,
info,
requestor_id: str,
id: str,
):
meal_request = services["meal_request_service"].get_meal_request_by_id(id)
return meal_request

def resolve_getMealRequestsByRequestorId(
self,
info,
Expand Down
Loading
Loading