How to use support_id method in lisa

Best Python code snippet using lisa_python

Support.py

Source:Support.py Github

copy

Full Screen

1# $Header: //depot/cs/db/Support.py#19 $2import re3from db.Db import get_cursor4from db.Exceptions import DbError, SupportSessionExpired5from p.Utility import session_key6class SupportSession:7 """Return a support session (which includes the database table row) for the logged in support account."""8 def __init__(self, key = None, name = None, password = None):9 if (name):10 if (password == None):11 raise DbError("Name and Password Required")12 c = get_cursor()13 c.execute("""select * from support14 where name = %s15 and password = password(%s)""",16 (name, password))17 if (c.rowcount == 0):18 raise DbError("Invalid Name or Password. Please try again.")19 self.row = c.fetchone()20 self.name = self.row['name']21 self.row['session_key'] = session_key(30)22 c.execute("""update support set session_key = %s23 where support_id = %s""",24 (self.row['session_key'], self.row['support_id']))25 return26 if (key):27 c = get_cursor()28 c.execute("""select * from support29 where session_key = %s""",30 (key,))31 if (c.rowcount == 0):32 raise SupportSessionExpired()33 self.row = c.fetchone()34 self.name = self.row['name']35 return36 raise SupportSessionExpired()37 def logout():38 """Remove the session key from the support table to log the support account out."""39# Always assume the logout is successful.40 try:41 c = get_cursor()42 c.execute("""update support set session_key = null43 where support_id = %s""",44 (self.row['support_id'],))45 except:46 pass47 def column(self, column_name):48 """Retrieve the value of the column specified in column_name."""49 return self.row[column_name]50#51# These functions are used by the support management script.52#53def get_all():54 c = get_cursor()55 c.execute("""select support.support_id, support.name from support""")56 rows = c.fetchall()57 return { 'supports': rows }58def new():59 c = get_cursor()60 c.execute("""insert into support values () """)61 62 support_id = c.lastrowid63 c.execute("""select support.support_id, support.name from support where support_id = %s""", support_id)64 row = c.fetchone()65 return { 'support': row }66def delete(support_id):67 support_id = re.sub('[^0-9]', '', support_id)68 c = get_cursor()69 c.execute("""delete from support70 where support_id = %s""",71 (support_id,))72 return { 'support_id': support_id }73def edit(req):74 """Update the given email template based on the data in the req object."""75 name = req.get('name', "")76 password = req.get('password', "")77 support_id = re.sub('[^0-9]', '', req['support_id'])78 c = get_cursor()79 c.execute("""update support80 set name = %s,81 password = password(%s)82 where support_id = %s""",83 (name, password, support_id))84 c.execute("""select support.support_id, support.name from support where support_id = %s""", support_id)85 row = c.fetchone()...

Full Screen

Full Screen

support_admin.py

Source:support_admin.py Github

copy

Full Screen

1from aiogram import types, Dispatcher2from aiogram.dispatcher import FSMContext3from aiogram.dispatcher.filters.state import StatesGroup, State4import database5from loader import bot, dp6from source.admins import send_admins7from src.const import is_const8class AdminSupport(StatesGroup):9 support_answer = State()10async def get_answer(message: types.Message, support_id):11 """12 Запрос ответа на запрос13 :param message:14 :param support_id: id запроса15 :return:16 """17 await message.answer("📕 Напишите ответ")18 await AdminSupport.support_answer.set()19 state = Dispatcher.get_current().current_state()20 await state.update_data(support_id=support_id)21@dp.message_handler(state=AdminSupport.support_answer)22async def send_answer(message: types.Message, state: FSMContext):23 """24 Отправка ответа25 :param message:26 :param state:27 :return:28 """29 answer = message.text30 if is_const(answer):31 await message.answer("❗️ Некорректный ответ ❗️")32 return33 data = await state.get_data()34 data['answer'] = answer35 support_data = database.get_support(data['support_id'])36 database.close_support(data['support_id'], data)37 user_message = "✅ Ваш запрос рассмотрен\n" \38 "➖➖➖➖➖➖➖➖➖➖\n" \39 f"🆔 Номер запроса: <b>{data['support_id']}</b>\n" \40 f"📕 Ответ:\n\n{answer}"41 await bot.send_message(support_data[1], user_message)42 admin_message = "✅ Ответ отправлен\n" \43 "➖➖➖➖➖➖➖➖➖➖\n" \44 f"🙍‍♂ Ответил: <b>@{message.chat.username}</b>\n" \45 "➖➖➖➖➖➖➖➖➖➖\n" \46 f"🆔 Номер запроса: <b>{data['support_id']}</b>\n" \47 f"🙍‍♂ Пользователь: <b>@{support_data[2]}</b>\n" \48 f"📋 Описание:\n{support_data[3]}\n" \49 "➖➖➖➖➖➖➖➖➖➖\n" \50 f"📕 Ответ:\n{answer}"51 await send_admins(admin_message)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful