def clean(self): cleaned_data = super(WechatEditForm, self).clean() shortname = cleaned_data.get("shortname") token = wechat_utils.get_weichat_token() if not wechat_utils.validate_weichat_user(shortname,token): #validate failed self.add_error('shortname','wechat validate error. Please ensure you have follow DSA account.')
def clean(self): cleaned_data = super(WechatEditForm, self).clean() shortname = cleaned_data.get("shortname") token = wechat_utils.get_weichat_token() if not wechat_utils.validate_weichat_user(shortname, token): #validate failed self.add_error( 'shortname', 'wechat validate error. Please ensure you have follow DSA account.' )
def task_weichat_notice(req): users = User.objects.all() token = wechat_utils.get_weichat_token() for user in users: ref_weichat = user_weichat.objects.filter(userid=user.id) if ref_weichat: attends = Attend.objects.filter(userId=user.id,lock_time__gte = datetime.datetime.today().strftime("%Y-%m-%d")).order_by('lock_time') show_list = attendance_utils.filter_day_record(attends) if len(show_list) > 1: delta_time = show_list[-1].lock_time - show_list[0].lock_time work_hour = float('%.2f' % (delta_time.total_seconds()/3600)) msg_str = wechat_utils.msg_templete %(ref_weichat[0].weichatname,work_hour) wechat_utils.weichat_msg(msg_str,token) else: msg_str = wechat_utils.msg_templete %(ref_weichat[0].weichatname,0) wechat_utils.weichat_msg(msg_str,token) return HttpResponseRedirect("/")
def task_weichat_notice(req): users = User.objects.all() token = wechat_utils.get_weichat_token() for user in users: ref_weichat = user_weichat.objects.filter(userid=user.id) if ref_weichat: attends = Attend.objects.filter( userId=user.id, lock_time__gte=datetime.datetime.today().strftime( "%Y-%m-%d")).order_by('lock_time') show_list = attendance_utils.filter_day_record(attends) if len(show_list) > 1: delta_time = show_list[-1].lock_time - show_list[0].lock_time work_hour = float('%.2f' % (delta_time.total_seconds() / 3600)) msg_str = wechat_utils.msg_templete % ( ref_weichat[0].weichatname, work_hour) wechat_utils.weichat_msg(msg_str, token) else: msg_str = wechat_utils.msg_templete % ( ref_weichat[0].weichatname, 0) wechat_utils.weichat_msg(msg_str, token) return HttpResponseRedirect("/")