本文整理汇总了Python中gitshell.gsuser.models.GsuserManager.get_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python GsuserManager.get_user_by_email方法的具体用法?Python GsuserManager.get_user_by_email怎么用?Python GsuserManager.get_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitshell.gsuser.models.GsuserManager
的用法示例。
在下文中一共展示了GsuserManager.get_user_by_email方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __get_uniq_email
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def __get_uniq_email(tp_email):
if tp_email is not None:
user = GsuserManager.get_user_by_email(tp_email)
if user is None:
return tp_email
for i in range(0, 1000):
random_email = ('%8x' % random.getrandbits(64)) + '@example.com'
user = GsuserManager.get_user_by_email(random_email)
if user is None:
return random_email
return None
示例2: _set_real_committer_name
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def _set_real_committer_name(self, item):
if 'committer_name' not in item or 'committer_email' not in item:
return
committer_name = item['committer_name']
committer_email = item['committer_email']
item['real_committer_name'] = ''
user = GsuserManager.get_user_by_email(committer_email)
if user:
item['real_committer_name'] = user.username
return
user = GsuserManager.get_user_by_name(committer_name)
if user:
item['real_committer_name'] = user.username
示例3: _set_real_author_name
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def _set_real_author_name(self, item):
if 'author_name' not in item or 'author_email' not in item:
return
author_name = item['author_name']
author_email = item['author_email']
item['real_author_name'] = ''
user = GsuserManager.get_user_by_email(author_email)
if user:
item['real_author_name'] = user.username
return
user = GsuserManager.get_user_by_name(author_name)
if user:
item['real_author_name'] = user.username
示例4: _join
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [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))
示例5: get_gitshell_username
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def get_gitshell_username(name, email):
global NAME_CACHE, EMAIL_CACHE
if email in EMAIL_CACHE:
return EMAIL_CACHE[email]
if name in NAME_CACHE:
return NAME_CACHE[name]
user = GsuserManager.get_user_by_email(email)
if user:
EMAIL_CACHE[email] = user.username
return user.username
user = GsuserManager.get_user_by_name(name)
if user:
NAME_CACHE[name] = user.username
return user.username
示例6: find
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def find(request):
user = None
is_user_exist = False
username = request.POST.get('username')
if username is not None:
if username in MAIN_NAVS:
is_user_exist = True
user = GsuserManager.get_user_by_name(username)
email = request.POST.get('email')
if email is not None:
user = GsuserManager.get_user_by_email(email)
if user is not None:
is_user_exist = True
response_dictionary = { 'is_user_exist': is_user_exist }
return json_httpResponse(response_dictionary)
示例7: validate_email
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def validate_email(request, token):
current = 'validate_email'; title = u'设置 / 验证邮箱'
validate_result = 'success'
email = cache.get(token)
if email is not None:
user = GsuserManager.get_user_by_email(email)
if user is None:
request.user.email = email
request.userprofile.email = email
request.user.save()
request.userprofile.save()
else:
validate_result = 'user_exists'
else:
validate_result = 'token_expired'
response_dictionary = {'current': current, 'title': title, 'validate_result': validate_result}
return render_to_response('settings/validate_email.html',
response_dictionary,
context_instance=RequestContext(request))
示例8: add_member
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [as 别名]
def add_member(request, username):
(teamUser, teamUserprofile) = _get_team_user_userprofile(request, username)
teamMember = None
username_or_email = request.POST.get('username_or_email', '')
if '@' in username_or_email:
user = GsuserManager.get_user_by_email(username_or_email)
if not user:
ref_hash = '%032x' % random.getrandbits(128)
ref_message = u'用户 %s 邀请您注册Gitshell,成为团队 %s 的成员' % (request.user.username, username)
userViaRef = UserViaRef(email=username_or_email, ref_type=REF_TYPE.VIA_TEAM_MEMBER, ref_hash=ref_hash, ref_message=ref_message, first_refid = teamUser.id, first_refname = teamUser.username)
userViaRef.save()
join_url = 'https://gitshell.com/join/ref/%s/' % ref_hash
Mailer().send_join_via_team_addmember(request.user, teamUser, username_or_email, join_url)
return json_failed(301, u'邮箱 %s 未注册,已经发送邮件邀请对方注册' % username_or_email)
teamMember = TeamManager.add_teamMember_by_email(teamUser, username_or_email)
else:
teamMember = TeamManager.add_teamMember_by_username(teamUser, username_or_email)
if not teamMember:
return json_failed(404, u'没有相关用户,不能是团队帐号')
return json_success(u'成功添加用户')
示例9: change
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_email [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)