def my_group3(): teacher = get_current_teacher() try: if not teacher: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) user = get_current_user() groups = Groups.query.filter_by(teacher_1=teacher.id).first() teach = Teachers.query.filter_by(id=teacher.id).all() for gr1 in teach: group = Groups.query.filter_by(id=gr1.group3) for gr in group: query = Student.query.filter( or_(Student.group1 == gr.id, Student.group2 == gr.id, Student.group3 == gr.id)).order_by('id') return render_template('Teacher/my group3.html', groups=groups, group=group, teacher=teacher, user=user, query=query) return render_template('Teacher/my group3.html', groups=groups, teacher=teacher, user=user)
def manage(id): user = get_current_user() try: if not user.gazalkent_admin and not user.director and not user.xojakent_admin: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) teacher = get_current_teacher() groups = Groups.query.filter_by(id=id).all() experts = Teachers.query.filter_by(teacher=True).all() for group in groups: student = Student.query.filter( or_(Student.group1 == group.id, Student.group2 == group.id, Student.group3 == group.id)) if user.locations == 1: return render_template('Groups/manage_group.html', students=student, groups=groups, user=user, teachers=experts) elif user.locations == 2: return render_template('Groups/manage_group2.html', students=student, groups=groups, user=user, teachers=experts) return render_template('Groups/manage_group.html', groups=groups, user=user, teachers=experts)
def find_group3(): user = get_current_user() try: if not user: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) student = Student.query.filter_by(id=user.id).first() groups = Groups.query.filter_by(id=student.group3) for st in groups: students = Student.query.filter(or_(Student.group1 == st.id, Student.group2 == st.id, Student.group3 == st.id)) return render_template('student/st group3.html', students=students, user=user, groups=groups) return render_template('student/st group3.html', user=user, groups=groups)
def inside_of_group2(id): user = get_current_user() try: if not user.gazalkent_admin and not user.director: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) groups = Groups.query.filter_by(id=id).all() experts = Teachers.query.filter_by(teacher=True).all() for group in groups: student = Student.query.filter( or_(Student.group1 == group.id, Student.group2 == group.id, Student.group3 == group.id)) return render_template('Groups/Inside of Group2.html', students=student, groups=groups, user=user, teachers=experts) return render_template('Groups/Inside of Group2.html', groups=groups, user=user, teachers=experts)
def delete_student_q(id, teacher_id, gr_id): user = get_current_user() try: if not user.xojakent_admin and not user.director and not user.gazalkent_admin: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) num = 1 calc = Groups.number_students - num Groups.query.filter_by(id=gr_id).update({'number_students': calc}) db.session.commit() gr_location = Groups.query.filter_by(id=gr_id).first() students = Student.query.filter( or_(Student.group1 == gr_id, Student.group2 == gr_id, Student.group3 == gr_id)) groups_n1 = Groups.query.filter_by(id=gr_id).all() for q in groups_n1: for i in students: if i.group1 == gr_id: if i.subject_1 == "": Student.query.filter_by(group1=gr_id, id=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 == "": Student.query.filter_by(group1=gr_id, id=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 == "": Student.query.filter_by(group1=gr_id, id=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_3': q.subject }) db.session.commit() if i.group2 == gr_id: if i.subject_1 == "": Student.query.filter_by(group2=gr_id, id=id).update({ 'group2': i.group3, 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 == "": Student.query.filter_by(group2=gr_id, id=id).update({ 'group2': i.group3, 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 == "": Student.query.filter_by(group2=gr_id, id=id).update({ 'group2': i.group3, 'group3': None, 'subject_3': q.subject }) db.session.commit() if i.group3 == gr_id: if i.subject_1 == "": Student.query.filter_by(group3=gr_id, id=id).update({ 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 == "": Student.query.filter_by(group3=gr_id, id=id).update({ 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 == "": Student.query.filter_by(group3=gr_id, id=id).update({ 'group3': None, 'subject_3': q.subject }) db.session.commit() if gr_location == 1: return redirect(url_for('all_groups')) elif gr_location == 2: return redirect(url_for('all_groups2'))
def delete_group(id, gr): user = get_current_user() try: if not user.xojakent_admin and not user.director and not user.gazalkent_admin: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) del_gr = Groups.query.filter_by(id=id).first() students = Student.query.filter( or_(Student.group1 == id, Student.group2 == id, Student.group3 == id)) groups_n1 = Groups.query.filter_by(id=id).all() for q in groups_n1: for i in students: if i.group1 == id: if i.subject_1 is None: Student.query.filter_by(group1=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 is None: Student.query.filter_by(group1=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 is None: Student.query.filter_by(group1=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': None, 'subject_3': q.subject }) db.session.commit() if i.group2 == id: if i.subject_1 is None: Student.query.filter_by(group2=id).update({ 'group2': i.group3, 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 is None: Student.query.filter_by(group2=id).update({ 'group2': i.group3, 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 is None: Student.query.filter_by(group2=id).update({ 'group2': i.group3, 'group3': None, 'subject_3': q.subject }) db.session.commit() if i.group3 == id: if i.subject_1 is None: Student.query.filter_by(group3=id).update({ 'group3': None, 'subject_1': q.subject }) db.session.commit() if i.subject_2 is None: Student.query.filter_by(group3=id).update({ 'group3': None, 'subject_2': q.subject }) db.session.commit() if i.subject_3 is None: Student.query.filter_by(group3=id).update({ 'group3': None, 'subject_3': q.subject }) db.session.commit() teachers = Teachers.query.filter_by(id=gr).all() for i in teachers: if i.group1 == id: Teachers.query.filter_by(id=gr, group1=id).update({ 'group1': i.group2, 'group2': i.group3, 'group3': i.group4, 'group4': i.group5, 'group5': i.group6, 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group2 == id: Teachers.query.filter_by(id=gr, group2=id).update({ 'group2': i.group3, 'group3': i.group4, 'group4': i.group5, 'group5': i.group6, 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group3 == id: Teachers.query.filter_by(id=gr, group3=id).update({ 'group3': i.group4, 'group4': i.group5, 'group5': i.group6, 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group4 == id: Teachers.query.filter_by(id=gr, group4=id).update({ 'group4': i.group5, 'group5': i.group6, 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group5 == id: Teachers.query.filter_by(id=gr, group5=id).update({ 'group5': i.group6, 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group6 == id: Teachers.query.filter_by(id=gr, group6=id).update({ 'group6': i.group7, 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group7 == id: Teachers.query.filter_by(id=gr, group7=id).update({ 'group7': i.group8, 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group8 == id: Teachers.query.filter_by(id=gr, group8=id).update({ 'group8': i.group9, 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group9 == id: Teachers.query.filter_by(id=gr, group9=id).update({ 'group9': i.group10, 'group10': None }) db.session.commit() elif i.group10 == id: Teachers.query.filter_by(id=gr, group10=id).update({'group10': None}) db.session.commit() teach = Teachers.query.filter_by(id=gr).first() num = 1 total = teach.number_groups - num Teachers.query.filter_by(id=gr).update({'number_groups': total}) db.session.commit() del_gr.delete() if del_gr.location == 1: return redirect(url_for('all_groups')) elif del_gr.location == 2: return redirect(url_for('all_groups2'))
def attendance_3(student_id, group_id): user = get_current_user() teacher = get_current_teacher() try: if not teacher: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) if request.method == 'POST': query2 = Groups.query.filter_by(id=group_id).first() query = Student.query.filter_by(id=student_id).first() group = Groups.query.filter( or_(Groups.id == query.group1, Groups.id == query.group2, Groups.id == query.group3)).first() query_teacher1 = Teachers.query.filter_by(id=teacher.id).first() query_teacher = Teachers.query.filter_by(id=group.teacher_1).first() slesh = group.cost / 13 boluv = slesh / 2 salery = query_teacher.salary + boluv plus = query.money - slesh + query.charity get_date = datetime.now() Student.query.filter_by(id=student_id).update({'money': plus}) Teachers.query.filter_by(id=group.teacher_1).update({'salary': salery}) db.session.commit() add = Attendance(group_id=group.id, student_id=student_id, teacher_id=teacher.id, present=None, apset=get_date) db.session.add(add) db.session.commit() query_charity = All_Charity_Sums.query.order_by('id').first() plus_charity = query_charity.bank_charity + query.charity All_Charity_Sums.query.update({'bank_charity': plus_charity}) db.session.commit() if query2.id == query_teacher1.group1: return redirect(url_for('my_group1')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group2')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group3')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group4')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group5')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group6')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group7')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group8')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group9')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group10')) groups = Groups.query.filter_by(teacher_1=teacher.id).all() for i in groups: student = Student.query.filter( or_(Student.group1 == i.id, Student.group2 == i.id, Student.group3 == i.id)) return render_template('Teacher/my groups.html', user=user, teacher=teacher, groups=groups, students=student) return render_template('Teacher/my groups.html', user=user, teacher=teacher, groups=groups)
def attendance_1(student_id, group_id): user = get_current_user() teacher = get_current_teacher() try: if not teacher: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) if request.method == 'POST': query = Student.query.filter_by(attendance=True).first() query2 = Groups.query.filter_by(id=group_id).first() group = Groups.query.filter( or_(Groups.id == query.group1, Groups.id == query.group2, Groups.id == query.group3)).first() query_teacher = Teachers.query.filter_by(id=group.teacher_1).first() query_teacher1 = Teachers.query.filter_by(id=teacher.id).first() slesh = group.cost / 13 + query.charity boluv = slesh / 2 if query_teacher.salary is None: salery = boluv else: salery = query_teacher.salary + boluv if query.money is None: plus2 = -slesh else: plus2 = query.money - slesh get_date = datetime.now() if teacher.subject == 'Ingliz tili' or teacher.subject == 'Rus tili': get_homework = int(request.form.get('homework')) get_dictonary = int(request.form.get('dictionary')) get_class_activity = int(request.form.get('active')) plus1 = get_homework + get_dictonary + get_class_activity boluv2 = plus1 / 3 add = Attendance(group_id=group_id, student_id=student_id, teacher_id=teacher.id, darsga_tayyorgarligi=get_homework, lugat=get_dictonary, darsda_qatnashishi=get_class_activity, ortacha_baho=boluv2, present=get_date, fan=group.subject, apset=None) db.session.add(add) db.session.commit() print(teacher.subject) elif teacher.subject == 'Matematika' or teacher.subject == 'Tarix' or \ teacher.subject == 'Fizika' or teacher.subject == 'Ona tili va Adabiyot' \ or teacher.subject == 'Biologiya': get_homework2 = int(request.form.get('homework')) get_class_activity2 = int(request.form.get('active')) plus3 = get_homework2 + get_class_activity2 boluv3 = plus3 / 2 add2 = Attendance(group_id=group_id, student_id=student_id, teacher_id=teacher.id, darsga_tayyorgarligi=get_homework2, darsda_qatnashishi=get_class_activity2, ortacha_baho=boluv3, lugat=0, present=get_date, fan=group.subject, apset=None) db.session.add(add2) db.session.commit() print(teacher.subject) Student.query.filter_by(attendance=True).update({ 'money': plus2, 'attendance': False }) Teachers.query.filter_by(id=group.teacher_1).update({'salary': salery}) db.session.commit() query_charity = All_Charity_Sums.query.order_by('bank_charity').first() plus_charity = query_charity.bank_charity + query.charity All_Charity_Sums.query.update({'bank_charity': plus_charity}) db.session.commit() if query2.id == query_teacher1.group1: return redirect(url_for('my_group1')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group2')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group3')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group4')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group5')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group6')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group7')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group8')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group9')) elif query2.id == query_teacher1.group1: return redirect(url_for('my_group10')) groups = Groups.query.filter_by(teacher_1=teacher.id).all() for i in groups: student = Student.query.filter( or_(Student.group1 == i.id, Student.group2 == i.id, Student.group3 == i.id)) return render_template('Teacher/my groups.html', user=user, teacher=teacher, groups=groups, students=student) return render_template('Teacher/my groups.html', user=user, teacher=teacher, groups=groups)