fixes
This commit is contained in:
parent
8f6e60f650
commit
e677a1e6ae
|
|
@ -26,6 +26,8 @@ router = Router()
|
||||||
|
|
||||||
async def t_callback_purchase_node_content(query: types.CallbackQuery, memory=None, user=None, db_session=None, chat_wrap=None, **extra):
|
async def t_callback_purchase_node_content(query: types.CallbackQuery, memory=None, user=None, db_session=None, chat_wrap=None, **extra):
|
||||||
content_oid = int(query.data.split('_')[1])
|
content_oid = int(query.data.split('_')[1])
|
||||||
|
is_cancel_request = query.data.split('_')[2] == 'cancel' if len(query.data.split('_')) > 2 else False
|
||||||
|
if not is_cancel_request:
|
||||||
make_log("OwnedContent", f"{user} Try to purchase content: {content_oid}", level='info')
|
make_log("OwnedContent", f"{user} Try to purchase content: {content_oid}", level='info')
|
||||||
content = db_session.query(StoredContent).filter_by(id=content_oid).first()
|
content = db_session.query(StoredContent).filter_by(id=content_oid).first()
|
||||||
if not content:
|
if not content:
|
||||||
|
|
@ -66,6 +68,19 @@ async def t_callback_purchase_node_content(query: types.CallbackQuery, memory=No
|
||||||
created=datetime.now()
|
created=datetime.now()
|
||||||
)
|
)
|
||||||
db_session.add(new_action)
|
db_session.add(new_action)
|
||||||
|
else:
|
||||||
|
make_log("OwnedContent", f"{user} Try to cancel purchase: {content_oid}", level='info')
|
||||||
|
action = db_session.query(UserAction).filter_by(
|
||||||
|
type='purchase',
|
||||||
|
content_id=content_oid,
|
||||||
|
user_id=user.id,
|
||||||
|
status='requested'
|
||||||
|
).first()
|
||||||
|
if not action:
|
||||||
|
return await query.answer()
|
||||||
|
|
||||||
|
action.status = 'canceled'
|
||||||
|
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
await chat_wrap.send_content(db_session, content, message_id=query.message.message_id)
|
await chat_wrap.send_content(db_session, content, message_id=query.message.message_id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,10 @@ class PlayerTemplates:
|
||||||
'text': self.user.translated('gotoWallet_button'),
|
'text': self.user.translated('gotoWallet_button'),
|
||||||
'url': purchase_action.meta['confirmation_url']
|
'url': purchase_action.meta['confirmation_url']
|
||||||
}])
|
}])
|
||||||
|
inline_keyboard_array.append([{
|
||||||
|
'text': self.user.translated('cancelPurchase_button'),
|
||||||
|
'callback_data': f'PC_{content.id}_cancel'
|
||||||
|
}])
|
||||||
text = self.user.translated('p_playerContext_purchaseRequested')
|
text = self.user.translated('p_playerContext_purchaseRequested')
|
||||||
else:
|
else:
|
||||||
inline_keyboard_array.append([{
|
inline_keyboard_array.append([{
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -150,3 +150,7 @@ msgstr "Error: content price is not set"
|
||||||
#: app/client_bot/routers/content.py:133
|
#: app/client_bot/routers/content.py:133
|
||||||
msgid "viewTrack_button"
|
msgid "viewTrack_button"
|
||||||
msgstr "View track"
|
msgstr "View track"
|
||||||
|
|
||||||
|
#: app/client_bot/routers/content.py:138
|
||||||
|
msgid "cancelPurchase_button"
|
||||||
|
msgstr "Cancel purchase"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue