Refactor event retrieval and improve test coverage
Removed redundant code for event retrieval and standardized logic by introducing a unified method for generating event endpoints. Updated tests to align with these changes, adding support for slug-based access and handling finer permission cases. Minor issues with test formatting and comments were also addressed.
This commit is contained in:
@@ -239,7 +239,6 @@ def get_event(
|
||||
current_user: Optional[User] = Depends(get_current_user)
|
||||
) -> EventResponse:
|
||||
"""Get event by ID."""
|
||||
print("Getting event")
|
||||
try:
|
||||
event_obj = event.get(db=db, id=event_id)
|
||||
return validate_event_access(
|
||||
@@ -270,8 +269,7 @@ def get_event_by_slug(
|
||||
) -> EventResponse:
|
||||
"""Get event by slug."""
|
||||
try:
|
||||
event_obj = event.get_public_event(db=db, slug=slug, access_code=access_code)
|
||||
|
||||
event_obj = event.get_by_slug(db=db, slug=slug)
|
||||
return validate_event_access(
|
||||
db=db,
|
||||
event_obj=event_obj,
|
||||
|
||||
Reference in New Issue
Block a user