Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4f8ed61
Ticket change over
armanddidierjean Apr 8, 2026
e454a56
Remove unused and fix
armanddidierjean May 1, 2026
8a72edd
Disable event
foucblg Jun 14, 2026
c0089f8
authorize disabling session and category with sold ticket
foucblg Jun 14, 2026
6d48baa
being able to disable questions with answer
foucblg Jun 14, 2026
1c29a40
delete event
foucblg Jun 14, 2026
828f735
add question after creation
foucblg Jun 14, 2026
becd0b5
lint and format
foucblg Jun 14, 2026
841b423
Fastapi 0.137.0
armanddidierjean Jun 14, 2026
9a637ca
Revert "Fastapi 0.137.0"
armanddidierjean Jun 14, 2026
a2a0333
Ticket change over tests
armanddidierjean Jun 27, 2026
c870f4d
Test ticket change over
armanddidierjean Jun 27, 2026
f0790c6
Remove allows_update_with_checkouts_or_tickets and has_checkouts_or_t…
armanddidierjean Jun 27, 2026
5fa6803
Only prevent from updating some fields
armanddidierjean Jun 27, 2026
44deb96
Delete sessions, categories, questions and events
armanddidierjean Jun 27, 2026
cb3a919
Fix types_feed import
armanddidierjean Jun 28, 2026
9e79e56
Allow to patch required_membership
armanddidierjean Jun 28, 2026
02e397d
count_valid_checkouts_and_tickets_by_event_id
armanddidierjean Jun 28, 2026
6cd8693
ensure_user_can_manage_events
armanddidierjean Jun 28, 2026
7d9c802
307 status_code and any condition
armanddidierjean Jun 28, 2026
3fb343d
Remove duplicated count_valid_checkouts_and_tickets_by_event_id defin…
armanddidierjean Jun 28, 2026
b4c2c3f
Fix tickets auth tests
armanddidierjean Jun 30, 2026
5b0e03c
Fix deletion rules
armanddidierjean Jun 30, 2026
33a3bcf
Remove duplicated definitions
armanddidierjean Jun 30, 2026
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
14 changes: 14 additions & 0 deletions app/core/feed/cruds_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,17 @@ async def edit_news_by_module_object_id(
)
.values(**news_edit.model_dump(exclude_unset=True)),
)


async def get_news_by_module_object_id(
module: str,
module_object_id: UUID,
db: AsyncSession,
) -> models_feed.News | None:
result = await db.execute(
select(models_feed.News).where(
models_feed.News.module == module,
models_feed.News.module_object_id == module_object_id,
),
)
return result.scalars().first()
13 changes: 13 additions & 0 deletions app/core/feed/utils_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,16 @@ async def edit_feed_news(
group_id=group,
message=message,
)


async def check_if_module_object_id_is_linked_to_feed(
module: str,
module_object_id: uuid.UUID,
db: AsyncSession,
) -> bool:
result = await cruds_feed.get_news_by_module_object_id(
module=module,
module_object_id=module_object_id,
db=db,
)
return result is not None
15 changes: 15 additions & 0 deletions app/core/mypayment/utils_mypayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,18 @@ async def can_user_manage_events(
db=db,
)
return seller is not None and seller.can_manage_events


async def ensure_user_can_manage_events(
user_id: str,
store_id: UUID,
db: AsyncSession,
):
"""
Will raise a 403 HTTPException if the user is not authorized to manage events for the store.
"""
if not await can_user_manage_events(user_id, store_id, db):
raise HTTPException(
403,
detail="User is not authorized to manage store's events",
)
154 changes: 129 additions & 25 deletions app/core/tickets/cruds_tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ async def create_event_category(
db.add(db_category)


async def create_event_question(
question_id: UUID,
event_id: UUID,
question: schemas_tickets.QuestionCreate,
db: AsyncSession,
):
db_question = models_tickets.Question(
id=question_id,
event_id=event_id,
question=question.question,
answer_type=question.answer_type,
price=question.price,
required=question.required,
disabled=False,
)
db.add(db_question)


async def get_category_by_id(
category_id: UUID,
db: AsyncSession,
Expand Down Expand Up @@ -726,52 +744,56 @@ async def count_valid_checkouts_by_event_id(
return result.scalar() or 0


async def count_valid_checkouts_by_category_id(
category_id: UUID,
async def count_valid_checkouts_and_tickets_by_event_id(
event_id: UUID,
db: AsyncSession,
) -> int:
"""
Count only unpaid checkouts that are not expired
Count unpaid checkouts that are not expired and paid tickets
"""
result = await db.execute(
select(func.count()).where(
models_tickets.Checkout.category_id == category_id,
models_tickets.Checkout.expiration >= datetime.now(UTC),
not_(models_tickets.Checkout.paid),
models_tickets.Checkout.event_id == event_id,
or_(
models_tickets.Checkout.paid,
models_tickets.Checkout.expiration >= datetime.now(UTC),
),
),
)

return result.scalar() or 0


async def count_valid_checkouts_by_session_id(
async def count_valid_checkouts_and_tickets_by_session_id(
session_id: UUID,
db: AsyncSession,
) -> int:
"""
Count only unpaid checkouts that are not expired
Count unpaid checkouts that are not expired and paid tickets
"""
result = await db.execute(
select(func.count()).where(
models_tickets.Checkout.session_id == session_id,
models_tickets.Checkout.expiration >= datetime.now(UTC),
not_(models_tickets.Checkout.paid),
or_(
models_tickets.Checkout.paid,
models_tickets.Checkout.expiration >= datetime.now(UTC),
),
),
)

return result.scalar() or 0


async def count_valid_checkouts_and_tickets_by_event_id(
event_id: UUID,
async def count_valid_checkouts_and_tickets_by_category_id(
category_id: UUID,
db: AsyncSession,
) -> int:
"""
Count unpaid checkouts that are not expired and paid tickets
"""
result = await db.execute(
select(func.count()).where(
models_tickets.Checkout.event_id == event_id,
models_tickets.Checkout.category_id == category_id,
or_(
models_tickets.Checkout.paid,
models_tickets.Checkout.expiration >= datetime.now(UTC),
Expand All @@ -782,40 +804,36 @@ async def count_valid_checkouts_and_tickets_by_event_id(
return result.scalar() or 0


async def count_valid_checkouts_and_tickets_by_category_id(
async def count_valid_checkouts_by_category_id(
category_id: UUID,
db: AsyncSession,
) -> int:
"""
Count unpaid checkouts that are not expired and paid tickets
Count only unpaid checkouts that are not expired
"""
result = await db.execute(
select(func.count()).where(
models_tickets.Checkout.category_id == category_id,
or_(
models_tickets.Checkout.paid,
models_tickets.Checkout.expiration >= datetime.now(UTC),
),
models_tickets.Checkout.expiration >= datetime.now(UTC),
not_(models_tickets.Checkout.paid),
),
)

return result.scalar() or 0


async def count_valid_checkouts_and_tickets_by_session_id(
async def count_valid_checkouts_by_session_id(
session_id: UUID,
db: AsyncSession,
) -> int:
"""
Count unpaid checkouts that are not expired and paid tickets
Count only unpaid checkouts that are not expired
"""
result = await db.execute(
select(func.count()).where(
models_tickets.Checkout.session_id == session_id,
or_(
models_tickets.Checkout.paid,
models_tickets.Checkout.expiration >= datetime.now(UTC),
),
models_tickets.Checkout.expiration >= datetime.now(UTC),
not_(models_tickets.Checkout.paid),
),
)

Expand Down Expand Up @@ -926,3 +944,89 @@ async def get_ticket_change_over_invitation_by_token(
new_user_id=invitation.new_user_id,
token=invitation.token,
)


async def delete_question(
question_id: UUID,
db: AsyncSession,
):
await db.execute(
delete(models_tickets.Question).where(
models_tickets.Question.id == question_id,
),
)


async def delete_session(
session_id: UUID,
db: AsyncSession,
):
# Delete all expired unpaid checkouts for the session before deleting the session itself
await db.execute(
delete(models_tickets.Checkout).where(
models_tickets.Checkout.session_id == session_id,
not_(models_tickets.Checkout.paid),
models_tickets.Checkout.expiration < datetime.now(UTC),
),
)

await db.execute(
delete(models_tickets.EventSession).where(
models_tickets.EventSession.id == session_id,
),
)


async def delete_category(
category_id: UUID,
db: AsyncSession,
):
# Delete all expired unpaid checkouts for the category before deleting the category itself
await db.execute(
delete(models_tickets.Checkout).where(
models_tickets.Checkout.category_id == category_id,
not_(models_tickets.Checkout.paid),
models_tickets.Checkout.expiration < datetime.now(UTC),
),
)

await db.execute(
delete(models_tickets.Category).where(
models_tickets.Category.id == category_id,
),
)


async def delete_event(
event_id: UUID,
db: AsyncSession,
):
# Delete all expired unpaid checkouts for the event before deleting the event itself
await db.execute(
delete(models_tickets.Checkout).where(
models_tickets.Checkout.event_id == event_id,
not_(models_tickets.Checkout.paid),
models_tickets.Checkout.expiration < datetime.now(UTC),
),
)

await db.execute(
delete(models_tickets.Question).where(
models_tickets.Question.event_id == event_id,
),
)
await db.execute(
delete(models_tickets.EventSession).where(
models_tickets.EventSession.event_id == event_id,
),
)
await db.execute(
delete(models_tickets.Category).where(
models_tickets.Category.event_id == event_id,
),
)
await db.execute(
delete(models_tickets.TicketEvent).where(
models_tickets.TicketEvent.id == event_id,
),
)
Loading
Loading