コード例 #1
0
ファイル: relative.py プロジェクト: imzihuang/edu_project
 def school_id_by_phone(self, phone=""):
     # get first school's id of student
     if not phone:
         return
     relative_infos = db_api.relative_list(phone=phone)
     relative_ids = [relative_info.id for relative_info in relative_infos]
     relation_list = db_api.relation_list(relative_id=relative_ids)
     if relation_list:
         student_info = db_api.student_get(relation_list[0].student_id)
         return student_info.school_id
コード例 #2
0
ファイル: relative.py プロジェクト: imzihuang/edu_project
 def info(self, id):
     if not id:
         return
     relative_info = db_api.relative_get(id)
     relative_info = self.views(relative_info)
     _relation_list = self._get_relations_by_relative(relative_id=id)
     if _relation_list:
         student_info = db_api.student_get(_relation_list[0].student_id)
         relative_info.update({"school_id": student_info.school_id})
     return relative_info
コード例 #3
0
 def input(self, student_id, status, describe=""):
     if not student_id or not status:
         LOG.error("student_id name or status is None")
         return
     if not db_api.student_get(id=student_id):
         return
     values = {
         "student_id": student_id,
         "status": status,
         "describe": describe
     }
     _ = db_api.student_history_create(values)
     return values
コード例 #4
0
    def infos(self, id="", student_id="", student_name="", status="", limit=100, offset=1):
        offset = (offset-1)*limit if offset > 0 else 0
        filters = dict()
        if id:
            filters.update({"id": id})
        if student_id or student_name:
            if not student_id:
                _student_list = db_api.student_list(name=student_name)
                if _student_list:
                    student_id = [student_info.id for student_info in _student_list]
            filters.update({"student_id": student_id})
        if status:
            filters.update({"status": status})

        history_list = db_api.student_history_list(offset=offset, limit=limit, **filters)
        views_list = self.views(history_list)
        for view in views_list:
            student_info = db_api.student_get(id=view.get("student_id"))
            if student_info:
                view.update({"student_name": student_info.name})
        history_count = db_api.student_history_count(**filters)
        return {"count": history_count, "state": 0, "message": "query success", "data": views_list}
コード例 #5
0
ファイル: student.py プロジェクト: imzihuang/edu_project
    def info_detail_for_sign(self, id="", start_date="", end_date=""):
        if not id:
            raise exception.ParamNone(id=id)
        student_info = db_api.student_get(id)
        if not student_info:
            raise exception.NotFound(id=id)

        LOG.info("student_id%s"%id)
        # 关联学校和班级,还有学生得签到(学生亲属的签到信息)
        student_info = self.views(student_info)
        sign_detail = self.com_sign_detail(id, start_date, end_date)
        sign_data = []
        for sign_status in sign_detail:
            sign_data.append({
                "date": datetime.strftime(sign_status.sign_date, "%Y-%m-%d"),
                "status": sign_status.status,
                "morning": sign_status.morning if sign_status.morning else "",
                "afternoon": sign_status.afternoon if sign_status.afternoon else ""
            })
            #result.update({datetime.strftime(sign_status.sign_date, "%Y-%m-%d"): sign_status.status})

        student_info.update({"sign_data": sign_data})
        return student_info