コード例 #1
0
def cron_weekly_report_hrbp():
    """每周的周一上午10:30发送上周的考勤周报给hrbp"""
    s = Schedule()
    weekday = s.get_weekday(datetime.date.today().strftime('%Y-%m-%d'))
    if int(weekday) == 0:
        weekly = WeeklyReportHrbp()
        weekly.handle(deptname='pro')
コード例 #2
0
 def handle(self, *args, **options):
     s = Schedule()
     year = options.get('year')
     for day in s.iter_yeardays(year):
         weekday = s.get_weekday(day)
         weekday_hunman = DEFAULT_WEEKDAY.get(weekday)
         ret = s.get_holiday(day)
         is_holiday = ret['holiday'] if ret else False
         holiday_info = ret['name'] if ret else None
         try:
             instance = Holiday.objects.get(day=day)
         except Holiday.DoesNotExist:
             instance = None
         ser = HolidaySerializer(data={
             'day': day,
             'weekday': weekday_hunman,
             'is_holiday': is_holiday,
             'holiday_info': holiday_info
         },
                                 instance=instance)
         if ser.is_valid():
             ser.save()
         else:
             logger.warn('%s', ser.errors)