def delete_group(id): group = Group.query.get_or_404(id) if not is_group_removable(group): abort(409) group.notifications.delete() db.session.delete(group) flash('группа {} удалена'.format(group.name)) return redirect_back_or_home()
def delete_bot(id): bot = Bot.query.get_or_404(id) for at in bot.system_user.access_tokens.all(): db.session.delete(at) delete_all_messages_with_user(bot.system_user_id) db.session.delete(bot) db.session.delete(bot.system_user) flash('бот {} удалён'.format(bot.fio)) return redirect_back_or_home()
def delete_developer(id): developer = Developer.query.get_or_404(id) if not is_developer_removable(developer): abort(409) for at in developer.system_user.access_tokens.all(): db.session.delete(at) delete_all_messages_with_user(developer.system_user_id) db.session.delete(developer) db.session.delete(developer.system_user) flash('разработчик {} удалён'.format(developer.fio)) return redirect_back_or_home()
def delete_student(id): student = Student.query.get_or_404(id) if not is_student_removable(student): abort(409) for at in student.system_user.access_tokens.all(): db.session.delete(at) student.parent_of_students.delete() delete_all_messages_with_user(student.system_user_id) db.session.delete(student) db.session.delete(student.system_user) flash('ученик {} удалён'.format(student.fio)) return redirect_back_or_home()
def delete_teacher(id): teacher = Teacher.query.get_or_404(id) if not is_teacher_removable(teacher): abort(409) for at in teacher.system_user.access_tokens.all(): db.session.delete(at) teacher.system_user.notifications.delete() delete_all_messages_with_user(teacher.system_user_id) db.session.delete(teacher) db.session.delete(teacher.system_user) flash('преподаватель {} удалён'.format(teacher.fio)) return redirect_back_or_home()
def delete_master(id): master = Master.query.get_or_404(id) if not is_master_removable(master): abort(409) for at in master.system_user.access_tokens.all(): db.session.delete(at) master.system_user.notifications.delete() delete_all_messages_with_user(master.system_user_id) db.session.delete(master) db.session.delete(master.system_user) flash('руководитель {} удалён'.format(master.fio)) return redirect_back_or_home()
def delete_lesson(lesson_id): lesson = Lesson.query.get_or_404(lesson_id) # can't use @check_access_group_write() because no 'group_id' param. if not can_user_write_group(current_user, lesson.group): abort(403) if not is_lesson_removable(lesson): abort(409) if current_user.is_teacher and lesson.date < datetime.date.today(): abort(409) for a in lesson.attendings_was_not: db.session.delete(a) db.session.delete(lesson) flash('занятие {} в {} удалено'.format(lesson.date, lesson.group.name)) return redirect_back_or_home()
def delete_parent(id): parent = Parent.query.get_or_404(id) if not is_parent_removable(parent): abort(409) db.session.delete(parent) flash('родитель {} удален'.format(parent.fio)) return redirect_back_or_home()
def delete_school(id): school = School.query.get_or_404(id) if not is_school_removable(school): abort(409) db.session.delete(school) flash('школа {} удалена'.format(school.name)) return redirect_back_or_home()
def delete_section(id): section = Section.query.get_or_404(id) if not is_section_removable(section): abort(409) db.session.delete(section) flash('секция {} удалена'.format(section.name)) return redirect_back_or_home()
def delete_citizenship(id): citizenship = Citizenship.query.get_or_404(id) if not is_citizenship_removable(citizenship): abort(409) db.session.delete(citizenship) flash('гражданство {} удалено'.format(citizenship.name)) return redirect_back_or_home()