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

feat: add registration attributes and guards #171

Open
wants to merge 7 commits into
base: stage
Choose a base branch
from

Conversation

sharmaigne
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Feb 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sparcs-event-platform ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 13, 2024 2:42pm

Copy link
Member

@ArJSarmiento ArJSarmiento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a bit more changes @sharmaigne . Thanks!

event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No discounts for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be error NOT_FOUND

event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No discounts for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be error NOT_FOUND

event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No discounts for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be error NOT_FOUND

Comment on lines 31 to 33
event = EventUsecase.get_event(
event_id
) # NOTE: am i doing this right, i don't wanna add another param but di pud ko sure if fetching the whole thing is the best move?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the EventRepository for this.

event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No evaluations for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be NOT_FOUND

backend/usecase/evaluation_usecase.py Show resolved Hide resolved
@@ -45,6 +46,12 @@ def create_registration(self, registration_in: RegistrationIn) -> Union[JSONResp
Union[JSONResponse, RegistrationOut]: If successful, returns the created registration entry.
If unsuccessful, returns a JSONResponse with an error message.
"""

event = EventUsecase.get_event(registration_in.eventId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use EventRepository for this. Apply for all instances. Use cases should call repositories for data fetching.

@ArJSarmiento
Copy link
Member

Can you please resolve merge conflicts @sharmaigne ?

Copy link
Member

@ArJSarmiento ArJSarmiento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More changes needed @ASPactores

Also lease add guards for the following:

  1. certificate usecase
  2. preregistration_usecase

Thanks!

event = EventUsecase.get_event(DiscountIn.eventId)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: Discounts should not be created for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.NOT_FOUND, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should BAD_REQUEST.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

@@ -33,6 +35,13 @@ def create_evaluation(self, evaluation_list_in: EvaluationListIn) -> Union[JSONR
"""
event_id = evaluation_list_in.eventId
registration_id = evaluation_list_in.registrationId

# NOTE: next three lines copy pasted a lot, should this be a helper or nah kay mubo ra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment

Comment on lines +97 to +100
event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No evaluation to update for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.NOT_FOUND, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should BAD_REQUEST.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

Comment on lines +138 to +141
event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: No discounts for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.NOT_FOUND, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should BAD_REQUEST.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

@@ -228,6 +240,11 @@ def get_registration(self, event_id: str, registration_id: str) -> Union[JSONRes

"""

event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should NOT_FOUND.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

Comment on lines +40 to +43
event = EventsRepository.query_events(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Error: Evaluation should not be created for REDIRECT registrationType'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This returns an error since EventsRepository.query_events returns a tuple and not the event entry
  2. Use self.__events_repository for accessing the entry not the usecase
  3. check if event exists first before accessing the registrationType attribute so do if event and event.registrationType

APPLY FOR ALL INSTANCES

Comment on lines +53 to +56
event = EventsRepository.query_events(registration_in.eventId)
if event.registrationType == RegistrationType.REDIRECT:
message = 'Registrations should not be created for REDIRECT registration type'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Use self.__events_repository for accessing the entry not the usecase
  2. Check if event exists first before accessing the registrationType attribute so do if event and event.registrationType

APPLY FOR ALL INSTANCES

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add guards to create_registration_approval_flow also

@@ -264,6 +281,11 @@ def get_registration_by_email(self, event_id: str, email: str) -> RegistrationOu
registrations,
message,
) = self.__registrations_repository.query_registrations_with_email(event_id=event_id, email=email)
event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should NOT_FOUND.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

Comment on lines +308 to +311
event = EventUsecase.get_event(event_id)
if event.registrationType == RegistrationType.REDIRECT:
message = 'No registrations for REDIRECT registration type'
return JSONResponse(status_code=HTTPStatus.BAD_REQUEST, content={'message': message})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should NOT_FOUND.

Should be BAD_REQUEST for CUD operations and NOT_FOUND for READ operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants