Skip to content

Commit

Permalink
Merge pull request #164 from MikiEremiki/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MikiEremiki authored Mar 15, 2024
2 parents b617f09 + a089c5c commit 1f50412
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/db/db_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ async def get_ticket(
return await session.get(Ticket, ticket_id)


async def delete_ticket(
session: AsyncSession,
ticket_id,
):
ticket = await get_ticket(session, ticket_id)
return await session.delete(ticket)


async def create_schedule_event(
session: AsyncSession,
type_event_id,
Expand Down
5 changes: 5 additions & 0 deletions src/handlers/main_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from telegram.constants import ChatType
from telegram.error import BadRequest

from db import db_postgres
from handlers import check_user_db
from handlers.sub_hl import write_old_seat_info, remove_inline_button
from settings.settings import (
Expand Down Expand Up @@ -487,6 +488,10 @@ async def cancel(update: Update, context: ContextTypes.DEFAULT_TYPE):
event_id = payment_data['event_id']

await write_old_seat_info(user, event_id, chose_ticket)
await db_postgres.delete_ticket(
context.session,
payment_data['ticket_id']
)
case 'bd':
await query.delete_message()
await update.effective_chat.send_message(
Expand Down
13 changes: 13 additions & 0 deletions src/handlers/reserve_admin_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from telegram.ext import ContextTypes

from api.googlesheets import get_quality_of_seats, write_data_for_reserve
from db import db_postgres
from db.db_googlesheets import load_show_info, load_list_show
from db.enum import TicketStatus
from handlers import init_conv_hl_dialog
from handlers.sub_hl import (
get_chose_ticket_and_price, get_emoji_and_options_for_event)
Expand Down Expand Up @@ -212,6 +214,17 @@ async def start_forma_info(

write_data_for_reserve(event_id, numbers, 3)


ticket_id = await db_postgres.create_ticket(
context.session,
base_ticket_id=chose_ticket.base_ticket_id,
price=price,
schedule_event_id=event_id,
status=TicketStatus.CREATED,
)

payment_data['ticket_id'] = ticket_id

await query.edit_message_text(
'<b>Напишите фамилию и имя (взрослого)</b>',
)
Expand Down

0 comments on commit 1f50412

Please sign in to comment.