本文整理汇总了Python中gitshell.gsuser.models.GsuserManager.get_userViaRef_by_refhash方法的典型用法代码示例。如果您正苦于以下问题:Python GsuserManager.get_userViaRef_by_refhash方法的具体用法?Python GsuserManager.get_userViaRef_by_refhash怎么用?Python GsuserManager.get_userViaRef_by_refhash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitshell.gsuser.models.GsuserManager
的用法示例。
在下文中一共展示了GsuserManager.get_userViaRef_by_refhash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: join_via_ref
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_userViaRef_by_refhash [as 别名]
def join_via_ref(request, ref_hash):
joinForm = JoinForm()
joinForm.fields['ref_hash'].initial = ref_hash
userViaRef = GsuserManager.get_userViaRef_by_refhash(ref_hash)
tip = ''
if userViaRef:
tip = userViaRef.ref_message
if userViaRef and userViaRef.email:
joinForm.fields['email'].initial = userViaRef.email
joinForm.fields['username'].initial = userViaRef.email.split('@')[0]
if userViaRef and userViaRef.username:
joinForm.fields['username'].initial = userViaRef.username
return _join(request, joinForm, 'ref', tip, '0')
示例2: bind
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_userViaRef_by_refhash [as 别名]
def bind(request, ref_hash):
userViaRef = None
if ref_hash:
userViaRef = GsuserManager.get_userViaRef_by_refhash(ref_hash)
GsuserManager.handle_user_via_refhash(request.user, ref_hash)
if userViaRef:
is_verify = 1
if userViaRef.ref_type == REF_TYPE.VIA_REPO_MEMBER:
GsuserManager.add_useremail(request.user, userViaRef.email, is_verify)
return HttpResponseRedirect('/%s/%s/' % (userViaRef.first_refname, userViaRef.second_refname))
elif userViaRef.ref_type == REF_TYPE.VIA_TEAM_MEMBER:
GsuserManager.add_useremail(request.user, userViaRef.email, is_verify)
return HttpResponseRedirect('/%s/' % (userViaRef.first_refname))
return HttpResponseRedirect('/dashboard/')
示例3: _join
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_userViaRef_by_refhash [as 别名]
def _join(request, joinForm, joinVia, tip, step):
if step is None:
step = '0'
error = u''; title = u'注册'
if step == '0' and request.method == 'POST':
joinForm = JoinForm(request.POST)
if joinForm.is_valid():
email = joinForm.cleaned_data['email']
username = joinForm.cleaned_data['username']
password = joinForm.cleaned_data['password']
ref_hash = joinForm.cleaned_data['ref_hash']
user_by_email = GsuserManager.get_user_by_email(email)
user_by_username = GsuserManager.get_user_by_name(username)
if user_by_email is None and user_by_username is None:
if ref_hash:
userViaRef = GsuserManager.get_userViaRef_by_refhash(ref_hash)
if userViaRef and _create_user_and_authenticate(request, username, email, password, ref_hash, True):
return HttpResponseRedirect('/join/3/')
client_ip = _get_client_ip(request)
cache_join_client_ip_count = cache.get(CacheKey.JOIN_CLIENT_IP % client_ip)
if cache_join_client_ip_count is None:
cache_join_client_ip_count = 0
cache_join_client_ip_count = cache_join_client_ip_count + 1
cache.set(CacheKey.JOIN_CLIENT_IP % client_ip, cache_join_client_ip_count)
if cache_join_client_ip_count < 10 and _create_user_and_authenticate(request, username, email, password, ref_hash, False):
return HttpResponseRedirect('/join/3/')
Mailer().send_verify_account(email, username, password, ref_hash)
goto = ''
email_suffix = email.split('@')[-1]
if email_suffix in COMMON_EMAIL_DOMAIN:
goto = COMMON_EMAIL_DOMAIN[email_suffix]
return HttpResponseRedirect('/join/1/?goto=' + goto)
error = u'欢迎回来, email: %s 或者 name: %s 已经注册过了, 您只需要直接登陆就行。' % (email, username)
else:
error = u'啊? 邮箱或验证码有误输入。注意大小写和前后空格。'
if len(step) > 1:
email = cache.get(step + '_email')
username = cache.get(step + '_username')
password = cache.get(step + '_password')
ref_hash = cache.get(step + '_ref_hash')
if email is None or username is None or password is None or not email_re.match(email) or not re.match("^[a-zA-Z0-9_-]+$", username) or username.startswith('-') or username in MAIN_NAVS:
return HttpResponseRedirect('/join/4/')
if _create_user_and_authenticate(request, username, email, password, ref_hash, True):
return HttpResponseRedirect('/join/3/')
else:
error = u'啊? 用户名或密码有误输入,注意大小写和前后空格。'
response_dictionary = {'step': step, 'error': error, 'title': title, 'joinForm': joinForm, 'joinVia': joinVia, 'tip': tip}
return render_to_response('user/join.html',
response_dictionary,
context_instance=RequestContext(request))