Exemplo n.º 1
0
 def approval_query(self, stime, etime, userid):
     """自定义审批记录查询,注意此处返回是字典,key为日期"""
     max_query_day = DEFAULT_ATTENDENCE_RULE.get('MAX_QUERY_DAYS')
     s = Schedule()
     ret = {}
     if not stime or not etime or not userid:
         return ret
     days = [day for day in Schedule.iter_diffdays(stime, etime)]
     if len(days) > max_query_day:
         return ret
     try:
         approval_objs = self.filter(originator_userid=userid,
                                     status="COMPLETED",
                                     result='agree')
         for day in days:
             tmp = []
             for approval_obj in approval_objs:
                 stime = approval_obj.start_time.split()[0]
                 etime = approval_obj.end_time.split()[0]
                 if s.check_time_in_range(day, stime, etime):
                     tmp.append(approval_obj)
             ret[day] = tmp
     except ObjectDoesNotExist:
         pass
     return ret
Exemplo n.º 2
0
 def record_query(self, userid, record_dates=None):
     """查询指定用户 指定日期范围内的请休假记录,返回{day : info,}"""
     s = Schedule()
     ret = {}
     try:
         approval_objs = self.filter(originator_userid=userid,
                                     status="COMPLETED",
                                     result='agree')
         for day in record_dates:
             tmp = []
             for approval_obj in approval_objs:
                 stime = approval_obj.start_time.split()[0]
                 etime = approval_obj.end_time.split()[0]
                 if s.check_time_in_range(day, stime, etime):
                     tmp.append(approval_obj)
             ret[day] = tmp
     except ObjectDoesNotExist:
         pass
     return ret