Exemplo n.º 1
0
 def save_form(self):
     set_value('hotline_complain_last',
               self.kw.get('hotline_complain_last'))
     set_value('hotline_complain_this',
               self.kw.get('hotline_complain_this'))
     set_value('yinji_duty', self.kw.get('yinji_duty'))
     set_value('director_duty', self.kw.get('director_duty'))
     set_value('infoer_duty', self.kw.get('infoer_duty'))
Exemplo n.º 2
0
 def save_form(self):
     ls = [
         'beian_info',
         'copyright',
     ]
     for k, v in self.kw.items():
         if k in ls and v:
             set_value(k, v)
Exemplo n.º 3
0
    def wrap_fail_info(self, infodc):
        old_count = int(get_value(self.count_key, 0, gte=self.code_life))
        old_count = old_count + 1
        set_value(self.count_key, old_count)

        if old_count > 5:
            code, url = code_and_url()
            set_value(self.code_key, code)
            infodc.update({'validate_img': url})
        infodc.update({'success': False})
        return infodc
Exemplo n.º 4
0
 def save_form(self):
     ls = [
         'qq',
         'wechat_gzh',
         'wechat_slogan',
         'service_phone',
         'service_time',
     ]
     for k, v in self.kw.items():
         if k in ls and v:
             set_value(k, v)
Exemplo n.º 5
0
def date_order(key, digit=6):
    # 20190101xxxxxx
    datestr = timezone.now().strftime('%Y%m%d')
    crt_value = get_value(key, datestr + '0' * digit)
    if crt_value[:8] == datestr:
        point = int(crt_value[8:])
        crt_point = point + 1
    else:
        crt_point = 0

    pointstr = '%%0%sd' % digit
    rt = datestr + pointstr % crt_point
    set_value(key, rt)
    return rt
Exemplo n.º 6
0
 def save_form(self):
     set_value('company_cert_protocol',
               self.kw.get('company_cert_protocol'))
     set_value('worker_cert_protocol',
               self.kw.get('worker_cert_protocol'))
     set_value('company_empoly_protocol',
               self.kw.get('company_empoly_protocol'))
     set_value('apply_job_protocol', self.kw.get('apply_job_protocol'))
Exemplo n.º 7
0
def get_date_sequence(key='_data_sequence',fill=6,how_many=1):
  """以日期为依据,生成随机序列
  
  @key:在kv数据库里面的key,可以用默认的
  
  """
  now = timezone.now()
  date_str = now.strftime('%Y%m%d')   
  inst  = lock_kv_inst(key,default='')
  v = inst.value
  #v = get_value(key,None)

  if v and v.startswith(date_str):
    start = int(v[8:])+1
  else:
    start = 1
  date_int = int( now.strftime('%Y%m%d') ) * 10**fill
  ls = [date_int+x for x in range(start,start+how_many) ]
  set_value(key,ls[-1])
  return ls
Exemplo n.º 8
0
def get_case_number(code):

    url = settings.SANGO_BRIDGE + '/rq'

    data = {
        'fun': 'keeper_case_count',
        'day': datetime.today().strftime('%Y-%m-%d'),
        'code': code,
    }
    rt = requests.post(url, data=json.dumps(data), proxies=proxies)
    case_list = json.loads(rt.text)
    normed_list = []
    for row in case_list:
        dc = {}
        for k, v in row.items():
            dc[k.lower()] = v
        normed_list.append(dc)

    set_value('inspector_case_%s' % code, json.dumps(normed_list))
    #value = get_value('inspector_case_%s' % code,'[]')

    return len(normed_list)
Exemplo n.º 9
0
 def save_form(self):
     ls = ['cunwei_names', 'enterprise_names', 'hotline_name_map']
     for k, v in self.kw.items():
         if k in ls:
             set_value(k, v)
Exemplo n.º 10
0
def save_test_com_list(com_list):
    set_value('dev_com_list', com_list)
Exemplo n.º 11
0
 def save_form(self): 
     bb = self.kw.get('wexin_name_list')
     bb = bb.replace(',', ',')
     bb = bb.replace(' ', '')
     set_value('wexin_name_list', bb)
Exemplo n.º 12
0
 def save_json_str(self, json_str):
     set_value('inspector_case', json_str)
Exemplo n.º 13
0
def getMyjson(text):
    return set_value('my-json', text)
Exemplo n.º 14
0
 def save_form(self): 
     ls = ['sha_pan_link', 'huxing_link', ]
     for k, v in self.kw.items():
         if k in ls and v:
             set_value(k, v)
Exemplo n.º 15
0
def gen_code():
    code, url = code_and_url()
    uuid = short_uuid()
    set_value('_validat_code_%s' % uuid, code)
    return {'key': uuid, 'image': url}
Exemplo n.º 16
0
def run(row):
    """
    为了实现token登录,需要添加中间件
    MIDDLEWARE = [
       'helpers.director.middleware.tokenuser.TokenUser',
       ...
    ]

    ##调用接口登录

    ```
    
    [POST]    /dapi/do_login     
    
        参数:
        {"username":"******","password":"******"}
    
        返回:
        {
            "data": {
                "token": "i7u62v4o5340950xt3jguyilxgmodvxp",
                "success": true
            },
            "success": true
        }
     ```
    
     用户登录后,有多种方式携带登录信息进行其他api的请求。
           
     1. 直接用cookies。后台已经自动设置和http请求的cookies,如果携带cookies请求,可以直接请求其他api接口。
     
     2. 采用token。如果传递cookies有困难,直接将token放在http的header中,进行请求.字段名为 `Authorization:token`
     
     3. 如果设置header有困难,可以直接挂在url上请求,例如 : `api_url?token=xxx`
     
     
     **跨域问题**
     
     在浏览器中肯会存在跨域问题。后端进行了设置是允许跨域请求的,但是浏览器默认是不允许传递cookies等敏感信息,所以需要进行一定的设置。
     以jquery的请求为例,需要设置`withCredentials: true`
             
     ``` 
         $.ajax({
             url: a_cross_domain_url,
             xhrFields: {
                 withCredentials: true
             }
         });
     ```
    """
    if getattr(settings, 'DIRECTOR_LOGIN_BACKEND', None):
        loginClass = import_element(settings.DIRECTOR_LOGIN_BACKEND)
        loger = loginClass(row)
    else:
        loger = Login(row)

    if not loger.check_code():
        code, url = code_and_url()
        set_value(loger.code_key, code)
        return {
            'success': False,
            'errors': {
                'validate_code': [_('验证码错误')]
            },
            'validate_img': url
        }
    rt = loger.check_and_login()
    return rt
Exemplo n.º 17
0
 def save_form(self):
     set_value('my-json', self.kw.get('content'))