예제 #1
0
    def delete(self):
        items = self.tableWidget.selectedItems()
        for i in items:
            row = self.tableWidget.row(i)
            number = self.tableWidget.item(row, 1).text()

            student = Student()
            student.delete(self.session, number)

            self.tableWidget.removeRow(row)
예제 #2
0
async def delete_students(ans: SimpleBotEvent):
    with logger.contextualize(user_id=ans.object.object.message.from_id):
        payload = hyperjson.loads(ans.object.object.message.payload)
        query = 0
        raw_html = requests.get(payload["students"])
        soup = BeautifulSoup(raw_html.text, "html.parser")
        students_ids = list(map(int, soup.find_all("pre")[1].text.split(",")))
        for st in students_ids:
            query += Student.delete().where(Student.vk_id == st).execute()
        await ans.answer(
            f"{query} студент(ов) удалено",
            keyboard=kbs.preferences.configure_chat(payload["chat_id"]),
        )