本文整理汇总了Python中gitshell.gsuser.models.GsuserManager.get_thirdpartyUser_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python GsuserManager.get_thirdpartyUser_by_id方法的具体用法?Python GsuserManager.get_thirdpartyUser_by_id怎么用?Python GsuserManager.get_thirdpartyUser_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitshell.gsuser.models.GsuserManager
的用法示例。
在下文中一共展示了GsuserManager.get_thirdpartyUser_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_username_email
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def change_username_email(request):
current = 'change_username_email'; title = u'设置 / 修改用户名和邮箱'
thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
response_dictionary = {'current': current, 'title': title, 'thirdpartyUser': thirdpartyUser}
return render_to_response('settings/change_username_email.html',
response_dictionary,
context_instance=RequestContext(request))
示例2: thirdparty
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def thirdparty(request):
current = 'thirdparty'; title = u'设置 / 第三方'
thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
response_dictionary = {'current': current, 'title': title, 'thirdpartyUser': thirdpartyUser}
return render_to_response('settings/thirdparty.html',
response_dictionary,
context_instance=RequestContext(request))
示例3: profile
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def profile(request):
current = 'profile'; title = u'设置 / 个人信息'
thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
userprofileForm = UserprofileForm(instance = request.userprofile)
if request.method == 'POST':
userprofileForm = UserprofileForm(request.POST, instance = request.userprofile)
if userprofileForm.is_valid():
userprofileForm.save()
response_dictionary = {'current': current, 'title': title, 'userprofileForm': userprofileForm, 'thirdpartyUser': thirdpartyUser}
return render_to_response('settings/profile.html',
response_dictionary,
context_instance=RequestContext(request))
示例4: login_github
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def login_github(request):
code = request.GET.get('code')
if request.GET.get('code') is None:
return HttpResponseRedirect('/login/')
access_token = github_oauth_access_token(code)
if access_token == '':
return HttpResponseRedirect('/login/')
thirdpartyUser = github_get_thirdpartyUser(access_token)
if thirdpartyUser is None or thirdpartyUser.tp_id is None or thirdpartyUser.tp_username is None:
return HttpResponseRedirect('/login/')
user = github_authenticate(thirdpartyUser)
if user is not None:
request.session.set_expiry(2592000)
user.backend='django.contrib.auth.backends.ModelBackend'
auth_login(request, user)
thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(user.id)
if thirdpartyUser.init == 0:
return HttpResponseRedirect('/settings/change_username_email/')
return HttpResponseRedirect('/dashboard/')
示例5: change
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def change(request):
thirdpartyUser = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
user = None
is_user_exist = True
is_exist_repo = False
username = request.POST.get('username')
if username is not None and re.match("^[a-zA-Z0-9_-]+$", username) and username != request.user.username and username not in MAIN_NAVS and not username.startswith('-'):
repo_count = RepoManager.count_repo_by_userId(request.user.id)
if repo_count > 0:
return json_httpResponse({'is_exist_repo': True})
user = GsuserManager.get_user_by_name(username)
if user is None:
request.user.username = username
request.userprofile.username = username
request.user.save()
request.userprofile.save()
for repo in RepoManager.list_repo_by_userId(request.user.id, 0, 100):
repo.username = username
repo.save()
is_user_exist = False
goto = ''
email = request.POST.get('email')
if email is not None and email_re.match(email):
user = GsuserManager.get_user_by_email(email)
if user is None:
Mailer().send_change_email(request.user, email)
email_suffix = email.split('@')[-1]
if email_suffix in COMMON_EMAIL_DOMAIN:
goto = COMMON_EMAIL_DOMAIN[email_suffix]
is_user_exist = False
if thirdpartyUser is not None:
thirdpartyUser.init = 1
thirdpartyUser.save()
if username == request.user.username:
is_user_exist = False
response_dictionary = { 'is_exist_repo': is_exist_repo, 'is_user_exist': is_user_exist, 'goto': goto, 'new_username': username, 'new_email': email }
return json_httpResponse(response_dictionary)
示例6: login_github_relieve
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_thirdpartyUser_by_id [as 别名]
def login_github_relieve(request):
thirdpartyUser_find = GsuserManager.get_thirdpartyUser_by_id(request.user.id)
if thirdpartyUser_find is not None:
thirdpartyUser_find.delete()
response_dictionary = {'code': 200, 'result': 'success'}
return json_httpResponse(response_dictionary)