Example #1
0
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)
Example #2
0
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)
Example #3
0
def change_absent(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'))
    pres = Attendance.query.filter_by(id=id).first()
    Attendance.query.filter_by(id=id).update({'present': pres.apset})
    Attendance.query.filter_by(id=id).update({'apset': None})
    db.session.commit()
    return redirect(url_for('see_att', id=pres.student_id))
Example #4
0
def info_teacher():
    teacher = get_current_teacher()
    try:
        if not teacher:
            return redirect(url_for('home'))
    except AttributeError:
        return redirect(url_for('home'))
    user = get_current_user()
    users = Teachers.query.filter_by(id=teacher.id)
    return render_template('Teacher/teacher_profile.html',
                           teacher=teacher,
                           users=users,
                           user=user)
Example #5
0
def group_without_teacher():
    user = get_current_user()
    try:
        if not user.xojakent_admin and not user.director:
            return redirect(url_for('home'))
    except AttributeError:
        return redirect(url_for('home'))
    teacher = get_current_teacher()
    groups = Groups.query.filter_by(teacher_1=0).all()

    return render_template('Groups/Without Teacher.html',
                           teacher=teacher,
                           user=user,
                           groups=groups)
Example #6
0
def see_att(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'))
    attendance = Attendance.query.filter_by(
        student_id=id, teacher_id=teacher.id).order_by('id').all()
    return render_template('Teacher/student_att.html',
                           user=user,
                           teacher=teacher,
                           attendance=attendance)
Example #7
0
def teacher_salary():
    teacher = get_current_teacher()
    try:
        if not teacher:
            return redirect(url_for('home'))
    except AttributeError:
        return redirect(url_for('home'))
    user = get_current_user()
    teacher_info = Teachers.query.filter_by(id=teacher.id).first()
    cash = Teacher_cash.query.filter_by(teacher_id=teacher.id)
    return render_template('Teacher/teacher_salary.html',
                           teacher=teacher,
                           teacher_info=teacher_info,
                           cash=cash,
                           user=user)
Example #8
0
def due_days1():
    user = get_current_user()
    try:
        if not user:
            return redirect(url_for('home'))
    except AttributeError:
        return redirect(url_for('home'))
    teacher = get_current_teacher()
    reason = request.form.get('reason')
    form = PhotoForm(meta={'csrf': False})
    get = Attendance.query.filter_by(for_sabab=True).first()
    if form.validate_on_submit():
        filename = images.save(form.image.data)
        image_url = images.url(filename)
        add = reason_apset_days(student_id=user.id,
                                img_due_days=image_url,reason_due=reason,
                                date_abset=get.apset,group_id=get.group_id)
        db.session.add(add)
        db.session.commit()

    return render_template('student/Sababli_kun.html', user=user, teacher=teacher,form=form, get=get)
Example #9
0
def show_group(group_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()
    query_groups = Groups.query.order_by('id').all()
    query_students = Student.query.filter_by(
        for_moved=True).order_by('id').all()
    if user.locations == 1:
        return render_template('Groups/Show_group.html',
                               groups=query_groups,
                               old_id=group_id,
                               students=query_students,
                               user=user)
    elif user.locations == 2:
        return render_template('Groups/Show_group2.html',
                               groups=query_groups,
                               old_id=group_id,
                               students=query_students,
                               user=user)
Example #10
0
def create_group():
    teacher = get_current_teacher()
    user = get_current_user()
    try:
        if not user.xojakent_admin and not user.gazalkent_admin and not user.director:
            return redirect(url_for('home'))
    except AttributeError:
        return redirect(url_for('home'))
    if request.method == 'POST':
        name = request.form.get("name")
        teachers = request.form.get("teacher")
        group_location = request.form.get('location')
        type_of_course = request.form.get('type_of_course')
        cost = request.form.get('cost')
        if group_location == "xojakent":
            group_location = 1
            num = 1
            groups_num = All_groups.all_groups + num
            All_groups.query.filter_by(id=1).update({'all_groups': groups_num})
            db.session.commit()
            teach = Teachers.query.filter_by(id=teachers).first()
            total = teach.number_groups + num
            Teachers.query.filter_by(id=teachers).update(
                {'number_groups': total})
            db.session.commit()
        elif group_location == "gazalkent":
            group_location = 2
            num = 1
            groups_num = All_groups.all_groups + num
            All_groups.query.filter_by(id=1).update({'all_groups': groups_num})
            db.session.commit()
            teach = Teachers.query.filter_by(id=teachers).first()
            total = teach.number_groups + num
            Teachers.query.filter_by(id=teachers).update(
                {'number_groups': total})
            db.session.commit()
        teacher_id = Teachers.query.filter_by(id=teachers).first()
        teacher_name = Teachers.query.filter_by(id=teachers).first()
        teacher_surname = Teachers.query.filter_by(id=teachers).first()
        if user.director:
            add = Groups(name=name,
                         teacher_1=teacher_id.id,
                         location=group_location,
                         subject=teacher_id.subject,
                         cost=cost,
                         teacher_name=teacher_name.name,
                         teacher_surname=teacher_surname.surname,
                         type_of_course=type_of_course)
            db.session.add(add)
        else:
            add = Groups(name=name,
                         teacher_1=teacher_id.id,
                         location=user.locations,
                         subject=teacher_id.subject,
                         cost=cost,
                         teacher_name=teacher_name.name,
                         teacher_surname=teacher_surname.surname,
                         type_of_course=type_of_course)
            db.session.add(add)
        show = Groups.query.filter_by(name=name).all()
        teachers1 = Teachers.query.filter_by(id=teachers).all()
        query_teacher = Teachers.query.filter_by(id=teachers).first()

        for i in show:
            if query_teacher.group1 is None and query_teacher.group2 is None and query_teacher.group3 is None and \
                    query_teacher.group4 is None and query_teacher.group5 is None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                Teachers.query.filter_by(id=teachers).update({'group1': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is None and query_teacher.group3 is None \
                    and query_teacher.group4 is None and query_teacher.group5 is None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group2': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is None \
                    and query_teacher.group4 is None and query_teacher.group5 is None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'

                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group3': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is None and query_teacher.group5 is None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group4': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'

                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group5': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is not None and \
                    query_teacher.group6 is None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group5 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group6': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is not None and \
                    query_teacher.group6 is not None and query_teacher.group7 is None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group5 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group6 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group7': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is not None and \
                    query_teacher.group6 is not None and query_teacher.group7 is not None and \
                    query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group5 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group6 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group7 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group8': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is not None and \
                    query_teacher.group6 is not None and query_teacher.group7 is not None and \
                    query_teacher.group8 is not None and query_teacher.group9 is None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group5 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group6 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group7 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group8 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group9': i.id})


            elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \
                    and query_teacher.group4 is not None and query_teacher.group5 is not None and \
                    query_teacher.group6 is not None and query_teacher.group7 is not None and \
                    query_teacher.group8 is not None and query_teacher.group9 is not None and query_teacher.group10 is None:
                if query_teacher.group1 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group2 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group3 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group4 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group5 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group6 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group7 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group8 == i.id:
                    return 'Bu grda ustoz uje bor'
                elif query_teacher.group9 == i.id:
                    return 'Bu grda ustoz uje bor'
                else:
                    Teachers.query.filter_by(id=teachers).update(
                        {'group10': i.id})
        calc = Student.query.filter_by(for_group=True).all()
        calculate = len(calc)
        Groups.query.filter_by(name=name).update(
            {'number_students': calculate})
        query = Student.query.filter_by(for_group=True).first()
        for q in teachers1:
            for i in show:
                if query.group1 is None and query.group2 is None and query.group3 is None:
                    if q.subject == query.subject_1:
                        Student.query.filter_by(for_group=True).update({
                            'group1':
                            i.id,
                            'for_group':
                            False,
                            'subject_1':
                            None
                        })

                    elif q.subject == query.subject_2:
                        Student.query.filter_by(for_group=True).update({
                            'group1':
                            i.id,
                            'for_group':
                            False,
                            'subject_2':
                            None
                        })

                    elif q.subject == query.subject_3:
                        Student.query.filter_by(for_group=True).update({
                            'group1':
                            i.id,
                            'for_group':
                            False,
                            'subject_3':
                            None
                        })

                elif query.group1 is not None and query.group2 is None and query.group3 is None:
                    if query.group1 == i.id:
                        return 'Bu gruppa band'
                    else:
                        if q.subject == query.subject_1:
                            Student.query.filter_by(for_group=True).update({
                                'group2':
                                i.id,
                                'for_group':
                                False,
                                'subject_1':
                                None
                            })

                        elif q.subject == query.subject_2:
                            Student.query.filter_by(for_group=True).update({
                                'group2':
                                i.id,
                                'for_group':
                                False,
                                'subject_2':
                                None
                            })

                        elif q.subject == query.subject_3:
                            Student.query.filter_by(for_group=True).update({
                                'group2':
                                i.id,
                                'for_group':
                                False,
                                'subject_3':
                                None
                            })

                elif query.group1 is not None and query.group2 is not None and query.group3 is None:
                    if query.group1 == i.id:
                        return 'Bu gruppa band'
                    elif query.group2 == i.id:
                        return 'Bu gruppa band'
                    else:
                        if q.subject == query.subject_1:
                            Student.query.filter_by(for_group=True).update({
                                'group3':
                                i.id,
                                'for_group':
                                False,
                                'subject_1':
                                None
                            })

                        elif q.subject == query.subject_2:
                            Student.query.filter_by(for_group=True).update({
                                'group3':
                                i.id,
                                'for_group':
                                False,
                                'subject_2':
                                None
                            })

                        elif q.subject == query.subject_3:
                            Student.query.filter_by(for_group=True).update({
                                'group3':
                                i.id,
                                'for_group':
                                False,
                                'subject_3':
                                None
                            })

    experts = Teachers.query.filter_by(teacher=True).all()
    student1 = Student.query.filter_by(for_group=True).all()
    student = Student.query.filter_by(for_group=True).first()
    db.session.commit()
    return render_template('Groups/create group.html',
                           user=user,
                           teachers=experts,
                           student1=student1,
                           teacher=teacher,
                           student=student)
Example #11
0
def add_group():
    teacher = get_current_teacher()
    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'))
    if request.method == 'POST':
        name = request.form.get('group')

        calc = Student.query.filter_by(for_group=True).all()
        calculate = len(calc)
        all = Groups.number_students + calculate
        Groups.query.filter_by(name=name).update({'number_students': all})
        db.session.commit()

        query = Student.query.filter_by(for_group=True).first()
        show = Groups.query.filter_by(name=name).all()
        for i in show:
            if query.group1 is None and query.group2 is None and query.group3 is None:
                if i.subject == query.subject_1:
                    Student.query.filter_by(for_group=True).update({
                        'group1':
                        i.id,
                        'for_group':
                        False,
                        'subject_1':
                        None
                    })
                    db.session.commit()
                elif i.subject == query.subject_2:
                    Student.query.filter_by(for_group=True).update({
                        'group1':
                        i.id,
                        'for_group':
                        False,
                        'subject_2':
                        None
                    })
                    db.session.commit()
                elif i.subject == query.subject_3:
                    Student.query.filter_by(for_group=True).update({
                        'group1':
                        i.id,
                        'for_group':
                        False,
                        'subject_3':
                        None
                    })
                    db.session.commit()

            elif query.group1 is not None and query.group2 is None and query.group3 is None:
                if query.group1 == i.id:
                    return 'Bu gruppa band'
                else:
                    if i.subject == query.subject_1:
                        Student.query.filter_by(for_group=True).update({
                            'group2':
                            i.id,
                            'for_group':
                            False,
                            'subject_1':
                            None
                        })
                        db.session.commit()
                    elif i.subject == query.subject_2:
                        Student.query.filter_by(for_group=True).update({
                            'group2':
                            i.id,
                            'for_group':
                            False,
                            'subject_2':
                            None
                        })
                        db.session.commit()
                    elif i.subject == query.subject_3:
                        Student.query.filter_by(for_group=True).update({
                            'group2':
                            i.id,
                            'for_group':
                            False,
                            'subject_3':
                            None
                        })
                        db.session.commit()

            elif query.group1 is not None and query.group2 is not None and query.group3 is None:
                if query.group1 == i.id:
                    return 'Bu gruppa band'
                elif query.group2 == i.id:
                    return 'Bu gruppa band'
                else:
                    if i.subject == query.subject_1:
                        Student.query.filter_by(for_group=True).update({
                            'group3':
                            i.id,
                            'for_group':
                            False,
                            'subject_1':
                            None
                        })
                        db.session.commit()
                    elif i.subject == query.subject_2:
                        Student.query.filter_by(for_group=True).update({
                            'group3':
                            i.id,
                            'for_group':
                            False,
                            'subject_2':
                            None
                        })
                        db.session.commit()
                    elif i.subject == query.subject_3:
                        Student.query.filter_by(for_group=True).update({
                            'group3':
                            i.id,
                            'for_group':
                            False,
                            'subject_3':
                            None
                        })
                        db.session.commit()
    experts = Teachers.query.filter_by(teacher=True).all()
    student = Student.query.filter_by(director=False,
                                      xojakent_admin=False,
                                      gazalkent_admin=False,
                                      for_group=True)
    groups = Groups.query.order_by("id").all()
    students = Student.query.order_by('id').all()
    return render_template('Groups/add_group.html',
                           user=user,
                           teachers=experts,
                           student=student,
                           groups=groups,
                           students=students,
                           teacher=teacher)
Example #12
0
def register_teacher():
    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'))
    teacher = get_current_teacher()
    if request.method == 'POST':
        teacher_name = request.form.get('name').upper()
        teacher_surname = request.form.get('surname').upper()
        teacher_age = request.form.get('age')
        teacher_location = request.form.get('location')
        teacher_username = request.form.get('username')
        teacher_hashed_password = request.form.get('password')
        confirm_password = request.form.get('confirm_password')
        teacher_phone = request.form.get('phone')
        otasining_ismi = request.form.get('father_name')
        teacher_subject = request.form.get('subject_1')
        if Teachers.query.filter_by(username=teacher_username).first():
            return "This username is already token"
        if teacher_name == "":
            abort(422)
        elif teacher_surname == "":
            abort(422)
        elif teacher_age == "":
            abort(422)

        if teacher_hashed_password != confirm_password:
            return "Parolingiz bir biriga to'g'ri kelmadi"
        hash = generate_password_hash(confirm_password, method='sha256')
        if teacher_location == "xojakent":
            teacher_location = 1
            num = 1
            total = All_teachers.teachers + num
            All_teachers.query.filter_by(id=1).update({'teachers': total})
        elif teacher_location == "gazalkent":
            teacher_location = 2
            num = 1
            total = All_teachers.teachers + num
            All_teachers.query.filter_by(id=1).update({'teachers': total})

        if teacher_subject == "Ingliz tili":
            teacher_subject = 'Ingliz tili'
        elif teacher_subject == "Rus tili":
            teacher_subject = 'Rus tili'
        elif teacher_subject == "Matematika":
            teacher_subject = 'Matematika'
        elif teacher_subject == "Tarix":
            teacher_subject = 'Tarix'
        elif teacher_subject == "Kimyo":
            teacher_subject = 'Kimyo'
        elif teacher_subject == "Fizika":
            teacher_subject = 'Fizika'
        elif teacher_subject == "Ona tili va Adabiyot":
            teacher_subject = 'Ona tili va Adabiyot'
        elif teacher_subject == "Biologiya":
            teacher_subject = 'Biologiya'
        elif teacher_subject == "Uy xamshiraligi":
            teacher_subject = "Uy xamshiraligi"
        add = Teachers(name=teacher_name,
                       surname=teacher_surname,
                       age=teacher_age,
                       locations=teacher_location,
                       username=teacher_username,
                       password=hash,
                       subject=teacher_subject,
                       phone=teacher_phone,
                       teacher=True,
                       number_groups=0,
                       otasining_ismi=otasining_ismi)
        add.add_teacher()
    return render_template('base template/Register_teacher.html',
                           user=user,
                           teacher=teacher)
Example #13
0
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)
Example #14
0
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)