本文整理匯總了Python中core.models.User.user_type方法的典型用法代碼示例。如果您正苦於以下問題:Python User.user_type方法的具體用法?Python User.user_type怎麽用?Python User.user_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.models.User
的用法示例。
在下文中一共展示了User.user_type方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getdmuser
# 需要導入模塊: from core.models import User [as 別名]
# 或者: from core.models.User import user_type [as 別名]
def getdmuser():
html = StringIO()
url = r'%sgetuser'%DMURL
print datetime.now()
print url
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.SSL_VERIFYHOST, False)
c.setopt(pycurl.SSL_VERIFYPEER, False)
c.setopt(pycurl.WRITEFUNCTION, html.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.perform()
ll = str(html.getvalue())
users = json.loads(ll)
for u in users:
user = User()
p = User_Phone.query.filter(db.or_(User_Phone.phone == u['phone'],User_Phone.phone == u['phone2'])).first()
purchases = u['name']+u'於'+u['gmdate']+u' 在 '+u['gmaddress']+u' 購買了大盒'+str(u['gmbigcount'])+u'盒,小盒'+str(u['gmsmallcount'])+u'盒,備注:'+u['remark']+u',電話:'+u['phone']+','+u['phone2']+u',年齡:'+str(u['ages'])+u',性別:'+u['gender']+u',區域:'+u['area']
if p:
pass#如果存在,不處理20141224
# user = User.query.get_or_404(p.user_id)
# user.operator_id = 1
# user.origin = int(u['origin'])
# user.user_type = 5#服務客戶
# #user.assign_operator_id = 1
# user.purchases = str(user.purchases)+purchases
# user.qxhdm_user_id = u['id']
# user.area = u['area']
# user.pharmacy = u['pharmacy']
# user.promoters = u['promoters']
# user.pharmacystores = u['pharmacystores']
#
# user.qxhdm_time = datetime.now().strftime('%Y-%m-%d')
# db.session.add(user)
#
# #分配記錄
# assign_log = User_Assign_Log()
# assign_log.user_id = user.user_id
# assign_log.assign_operator_id = None
# assign_log.operator_id = 1
# assign_log.user_type = user.user_type
# db.session.add(assign_log)
else:
user.operator_id = 1
user.origin = int(u['origin'])
user.user_type = 5#服務客戶
#user.assign_operator_id = 1
user.name = u['name']
user.phone = u['phone']
user.phone2 = u['phone2']
user.gender = u['gender']
user.ages = u['ages']
user.is_new = u['is_new']
user.disease = u['disease']
user.fugou = u['fugou']
user.remark = u['remark']
user.area = u['area']
user.pharmacy = u['pharmacy']
user.promoters = u['promoters']
user.pharmacystores = u['pharmacystores']
user.purchases = purchases
user.qxhdm_user_id = u['id']
user.qxhdm_time = datetime.now().strftime('%Y-%m-%d')
db.session.add(user)
db.session.flush()
#分配記錄
assign_log = User_Assign_Log()
assign_log.user_id = user.user_id
assign_log.assign_operator_id = None
assign_log.operator_id = 1
assign_log.user_type = user.user_type
db.session.add(assign_log)
db.session.add(User_Phone.add_phone(user.user_id,user.phone))
if user.phone2:
db.session.add(User_Phone.add_phone(user.user_id,user.phone2))
url = r'%supdateuser?id=%s&user_id=%s'%(DMURL,u['id'],user.user_id)
print url
c = pycurl.Curl()
c.setopt(pycurl.URL, url)
c.setopt(pycurl.SSL_VERIFYHOST, False)
c.setopt(pycurl.SSL_VERIFYPEER, False)
c.setopt(pycurl.WRITEFUNCTION, html.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.perform()
db.session.commit()