コード例 #1
0
    def update(cid, cname, ctype, classweek, classtime, classplace, tid,
               credit):
        try:
            course = Courses.query.get(cid)  # 获取原来的信息

            # 修改信息
            course.cname = cname
            course.ctype = ctype
            course.classweek = classweek
            course.classtime = classtime
            course.classplace = classplace
            course.tid = tid
            course.credit = credit

            db.session.add(course)
            db.session.commit()
            return True

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            try:
                db.session.rollback()
            except Exception as ex:
                print(ex)
                ExceptionLog.other_error(ex.__str__())

            return False
コード例 #2
0
    def course_agree(cid_li):
        """审批同意操作"""
        if cid_li is None:
            return False

        for cid in cid_li:
            try:
                course = Courses.query.get(int(cid))
                course.ispass = 1
                course.isexamine = 1
                db.session.add(course)
                # 把课程添加到缓存
                RedisService.load_agree_course(Courses.list_to_dict(course))
            except Exception as e:
                print(e)
                ExceptionLog.model_error(e.__str__())
                try:
                    db.session.rollback()
                except Exception as ex:
                    print(ex)
                    ExceptionLog.other_error(ex.__str__())
                return False

        try:
            db.session.commit()
            return True
        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return False
コード例 #3
0
    def admin_change_pwd(id, old_pwd, new_pwd1, new_pwd2):

        if new_pwd1 != new_pwd2:
            return False

        old_pwd = Encryption.md5(old_pwd)

        try:
            admin = Admins.query.get(id)
            if admin.password != old_pwd:
                return False

            admin.password = Encryption.md5(new_pwd1)
            db.session.add(admin)
            db.session.commit()
            return True

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            try:
                db.session.rollback()
            except Exception as ex:
                print(ex)
                ExceptionLog.other_error(ex.__str__())
            return False
コード例 #4
0
    def course_end(cls, id_li):
        """课程结束操作"""
        for id in id_li:
            try:
                course = Courses.query.get(int(id))
                course.isend = 1
                db.session.add(course)

            except Exception as e:
                print(e)
                ExceptionLog.model_error(e.__str__())
                try:
                    db.session.rollback()
                except Exception as ex:
                    print(ex)
                    ExceptionLog.other_error(ex.__str__())
                return False

        try:
            db.session.commit()
            return True

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            try:
                db.session.rollback()
            except Exception as ex:
                print(ex)
                ExceptionLog.other_error(ex.__str__())
            return False
コード例 #5
0
    def add(cname, ctype, classweek, classtime, rid, tid, credit, cnum, caid):

        now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        course = Courses(cname=cname,
                         ctype=ctype,
                         classweek=classweek,
                         classtime=classtime,
                         rid=rid,
                         tid=tid,
                         cretime=now_time,
                         updtime=now_time,
                         credit=credit,
                         cnum=cnum,
                         caid=caid)
        try:
            db.session.add(course)
            db.session.commit()
            return True

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            try:
                db.session.rollback()
            except Exception as ex:
                print(ex)
                ExceptionLog.other_error(ex.__str__())

            return False
コード例 #6
0
    def course_refuse(cid_li):
        """审批拒绝操作"""
        for cid in cid_li:
            try:
                course = Courses.query.get(int(cid))
                course.isexamine = 1
                db.session.add(course)

            except Exception as e:
                print(e)
                ExceptionLog.model_error(e.__str__())
                try:
                    db.session.rollback()
                except Exception as ex:
                    print(ex)
                    ExceptionLog.other_error(ex.__str__())
                return False

        try:
            db.session.commit()
            return True
        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return False
コード例 #7
0
    def permission_refuse(id_li):
        for id in id_li:
            try:
                admin = Admins.query.get(int(id))
                if admin.examine == 1:
                    admin.examine = 0
                    db.session.add(admin)

            except Exception as e:
                print(e)
                ExceptionLog.model_error(e.__str__())
                try:
                    db.session.rollback()
                except Exception as ex:
                    print(ex)
                    ExceptionLog.other_error(ex.__str__())
                return False

        try:
            db.session.commit()
            return True

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            try:
                db.session.rollback()
            except Exception as ex:
                print(ex)
                ExceptionLog.other_error(ex.__str__())
            return False
コード例 #8
0
 def get_by_id(cls, rid):
     try:
         room = Classrooms.query.get(rid)
         return cls.list_to_dict([room])[0]
     except Exception as e:
         print(e)
         ExceptionLog.model_error(e.__str__())
         return None
コード例 #9
0
 def get_by_caid(cls, caid):
     try:
         room_li = Classrooms.query.filter_by(caid=caid)
         return cls.list_to_dict(room_li)
     except Exception as e:
         print(e)
         ExceptionLog.model_error(e.__str__())
         return list()
コード例 #10
0
    def get_apply_course(cls):
        try:
            course_li = Courses.query.filter_by(isexamine=0)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
コード例 #11
0
    def get_by_id(cls, caid):
        try:
            campus_li = Campuses.query.get(caid)
            return cls.list_to_dict([campus_li])[0]

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #12
0
    def get_all(cls):
        try:
            campus_li = Campuses.query.all()
            return cls.list_to_dict(campus_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #13
0
    def get_by_gradepoint(cls, gradepoint):
        try:
            achi_li = Achievements.query.filter_by(gradepoint=gradepoint)
            return cls.list_to_dict(achi_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #14
0
    def get_by_credit(cls, credit):
        try:
            achi_li = Achievements.query.filter_by(credit=credit)
            return cls.list_to_dict(achi_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return None
コード例 #15
0
    def get_by_cid_count(cid):
        count = 0
        try:
            count = Achievements.query.filter_by(cid=cid).count()

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
        return count
コード例 #16
0
    def get_by_cidgreat(cls, cid):
        try:
            achi_li = Achievements.query.filter(Achievements.cid==cid, or_(Achievements.isgreat==0, Achievements.isgreat==1))
            return cls.list_to_dict(achi_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #17
0
    def get_by_cid(cls, cid):
        try:
            achi_li = Achievements.query.filter_by(cid=cid, isgreat=-1)
            return cls.list_to_dict(achi_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #18
0
    def get_end(cls):
        try:
            seltime = Coseltime.query.filter_by(isend=1)
            return cls.list_to_dict(seltime)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return None
コード例 #19
0
    def get_by_cid(cls, cid):
        try:
            cosel_li = Selcourses.query.filter_by(cid=cid)
            return cls.list_to_dict(cosel_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #20
0
 def get_rname(rid):
     try:
         room = Classrooms.query.get(rid)
         if room is not None:
             return str(room.rname)
     except Exception as e:
         print(e)
         ExceptionLog.model_error(e.__str__())
     return "error"
コード例 #21
0
    def get_all(cls):
        try:
            level_li = Levels.query.all()
            return cls.list_to_dict(level_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #22
0
    def get_by_credit(cls, credit):
        try:
            course_li = Courses.query.filter_by(credit=credit)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #23
0
    def get_by_place(cls, classplace):
        try:
            course_li = Courses.query.filter_by(classplace=classplace)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #24
0
    def get_by_tid_pass(cls, tid):
        try:
            course_li = Courses.query.filter_by(tid=tid, ispass=1, isexamine=1)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #25
0
    def get_all(cls):
        try:
            seltime_li = Coseltime.query.all()
            return cls.list_to_dict(seltime_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #26
0
    def get_all(cls):
        try:
            admin_li = Admins.query.filter_by(issuper=0)
            return cls.list_to_dict(admin_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return None
コード例 #27
0
    def get_by_pass(cls, tid):
        """获取教师任教课程业务"""
        try:
            course_li = Courses.query.filter_by(tid=tid, ispass=1, isend=0)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #28
0
    def get_load_course(cls):
        """获取要加载缓存的课程"""
        try:
            course_li = Courses.query.filter_by(ispass=1, isexamine=1, isend=0)
            return cls.list_to_dict(course_li)

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return list()
コード例 #29
0
    def get_by_id(cls, acid):
        try:
            achi = Achievements.query.get(acid)
            if achi is None:
                return achi
            else:
                return cls.list_to_dict(achi)[0]

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return None
コード例 #30
0
    def get_can_add_to_redis(cls, caid):
        try:
            course_li = Courses.query.filter_by(caid=caid,
                                                isend=0,
                                                ispass=1,
                                                isexamine=1)
            return course_li

        except Exception as e:
            print(e)
            ExceptionLog.model_error(e.__str__())
            return None