Beispiel #1
0
    def update(session, id_grade, value, new_date, new_path_file, note,
               feedback):
        try:
            new_date = str_to_date(new_date)
            s = session.query(Grade).filter_by(id_grade=id_grade)
            if new_path_file == '':
                s.update({
                    Grade.value: value,
                    Grade.note: note,
                    Grade.feedback: feedback,
                    Grade.date: new_date
                })
            else:
                s.update({
                    Grade.value: value,
                    Grade.path_file: new_path_file,
                    Grade.note: note,
                    Grade.feedback: feedback,
                    Grade.date: new_date
                })
            session.commit()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #2
0
    def add(session, discipline_name, group_number, name, task, note,
            grade_scale, new_date, isdeadline):
        try:
            new_date = str_to_date(new_date)
            g = session.query(Group).filter_by(number=group_number).first()
            id_group = g.id_group
            d = session.query(Discipline).filter_by(
                name=discipline_name).first()
            id_discipline = d.id_discipline
            max = grade_scale.split('-', 1)
            max = max[1]
            gr = session.query(GradeScale).filter_by(max=max).first()
            id_grade_scale = gr.id_grade_scale
            new_work = Work(id_group=id_group,
                            id_discipline=id_discipline,
                            id_grade_scale=id_grade_scale,
                            name=name,
                            task=task,
                            note=note,
                            deadline=new_date,
                            isdeadline=isdeadline)
            session.add(new_work)
            session.commit()
            session.flush()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #3
0
    def update(session, fio, safety, new_date, discipline_name, group_number):
        try:
            s = session.query(PassSafety).join(Safety).join(Discipline).join(Group).join(Student).filter(
                Discipline.name == discipline_name) \
                .filter(Group.number == group_number).filter(Safety.name == safety).filter(Student.fio == fio).first()
            id = s.id_pass_safety

            s = session.query(PassSafety).filter_by(id_pass_safety=id)
            new_date = str_to_date(new_date)
            s.update({PassSafety.date: new_date})
            session.commit()

        except Exception as e:
            print(e)
            session.rollback()
            bd_error()
Beispiel #4
0
    def add(session, id_work, student, value, action, date):
        try:
            st = session.query(Student).filter(Student.fio == student).first()
            id_student = st.id_student

            date = str_to_date(date)

            new_history_grade = HistoryGrade(date=date,
                                             id_student=id_student,
                                             id_work=id_work,
                                             value=value,
                                             action=action)
            session.add(new_history_grade)
            session.commit()
            session.flush()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #5
0
    def add(session, student, safety, date, discipline, group_number):
        try:
            s = session.query(Safety).join(Group).filter(Group.number == group_number). \
                filter(Discipline.name == discipline).filter(Safety.name == safety).first()

            id_safety = s.id_safety
            st = session.query(Student).filter(Student.fio == student).first()
            id_student = st.id_student

            date = str_to_date(date)

            new_pass_safety = PassSafety(date=date,
                                         id_student=id_student,
                                         id_safety=id_safety)
            session.add(new_pass_safety)
            session.commit()
            session.flush()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #6
0
    def add(session, id_work, student, value, new_date, new_path_file, note,
            feedback):
        try:
            st = session.query(Student).filter(Student.fio == student).first()
            id_student = st.id_student

            date = str_to_date(new_date)

            new_grade = Grade(date=date,
                              id_student=id_student,
                              id_work=id_work,
                              value=value,
                              path_file=new_path_file,
                              note=note,
                              feedback=feedback)
            session.add(new_grade)
            session.commit()
            session.flush()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #7
0
    def add_once(session, discipline, format, audience, group, date, time):
        try:
            d = session.query(Discipline).filter(
                Discipline.name == discipline).first()
            f = session.query(ClassFormat).filter(
                ClassFormat.name == format).first()
            corps = audience.split(' ')[0]
            number = audience.split(' ')[1]
            a = session.query(Audience).filter(Audience.corps == corps).filter(
                Audience.number == number).first()
            g = session.query(Group).filter(Group.number == group).first()

            id_discipline = d.id_discipline
            id_class_format = f.id_class_format
            id_audience = a.id_audience
            id_group = g.id_group

            date = str(date)
            date = str_to_date(date)

            s = session.query(ScheduledDay).filter_by(date=date).first()
            id_scheduled_day = s.id_scheduled_day
            # session.rollback()

            new_occupation = Occupation(time=time,
                                        id_scheduled_day=id_scheduled_day,
                                        id_discipline=id_discipline,
                                        id_class_format=id_class_format,
                                        id_audience=id_audience,
                                        id_group=id_group)

            session.add(new_occupation)
            session.commit()
            # session.flush()

        except Exception as e:
            session.rollback()
            bd_error()
Beispiel #8
0
    def update(session, id_work, name, task, note, grade_scale, new_date,
               isdeadline):
        try:
            new_date = str_to_date(new_date)
            max = grade_scale.split('-', 1)
            max = max[1]
            gr = session.query(GradeScale).filter_by(max=max).first()
            id_grade_scale = gr.id_grade_scale

            s = session.query(Work).filter_by(id_work=id_work)
            s.update({
                Work.name: name,
                Work.task: task,
                Work.note: note,
                Work.deadline: new_date,
                Work.isdeadline: isdeadline,
                Work.id_grade_scale: id_grade_scale
            })
            session.commit()

        except Exception as e:
            session.rollback()
            bd_error()