本文整理汇总了Python中gitshell.gsuser.models.GsuserManager.get_user_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python GsuserManager.get_user_by_id方法的具体用法?Python GsuserManager.get_user_by_id怎么用?Python GsuserManager.get_user_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitshell.gsuser.models.GsuserManager
的用法示例。
在下文中一共展示了GsuserManager.get_user_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: github_authenticate
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_id [as 别名]
def github_authenticate(thirdpartyUser):
tp_id, tp_username, tp_email, github_user_info = thirdpartyUser.tp_id, thirdpartyUser.tp_username, thirdpartyUser.tp_email, thirdpartyUser.github_user_info
thirdpartyUser_find = GsuserManager.get_thirdpartyUser_by_type_tpId(ThirdpartyUser.GITHUB, tp_id)
if thirdpartyUser_find is not None:
if thirdpartyUser_find.access_token != thirdpartyUser.access_token:
thirdpartyUser_find.access_token = thirdpartyUser.access_token
thirdpartyUser_find.save()
user_id = thirdpartyUser_find.id
user = GsuserManager.get_user_by_id(user_id)
return user
username = __get_uniq_username(tp_username)
email = __get_uniq_email(tp_email)
password = __get_random_password()
if username is None or email is None or password is None:
return None
create_user = None
try:
create_user = User.objects.create_user(username, email, password)
if create_user is not None and create_user.is_active:
userprofile = Userprofile(username = create_user.username, email = create_user.email, imgurl = hashlib.md5(create_user.email.lower()).hexdigest())
_fill_github_user_info(userprofile, github_user_info)
userprofile.id = create_user.id
userprofile.save()
if username == tp_username and email == tp_email:
thirdpartyUser.init = 1
thirdpartyUser.user_type = ThirdpartyUser.GITHUB
thirdpartyUser.id = create_user.id
thirdpartyUser.save()
except IntegrityError, e:
logger.exception(e)
示例2: get_current_user
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_id [as 别名]
def get_current_user(self, user, userprofile):
current_user_id = userprofile.current_user_id
if current_user_id == 0 or current_user_id == userprofile.id:
return user
teamMember = self.get_teamMember_by_teamUserId_userId(current_user_id, userprofile.id)
if not teamMember:
return user
current_user = GsuserManager.get_user_by_id(current_user_id)
if not current_user:
return user
return current_user
示例3: list_star_user
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_id [as 别名]
def list_star_user(self, repo_id, offset, row_count):
stars = query(Star, None, 'star_l_repoId', [repo_id, offset, row_count])
userprofiles = []
for x in stars:
user = GsuserManager.get_user_by_id(x.user_id)
userprofile = GsuserManager.get_userprofile_by_id(x.user_id)
if userprofile is None or userprofile.visibly == 1:
x.visibly = 1
x.save()
continue
userprofile.date_joined = time.mktime(user.date_joined.timetuple())
userprofile.last_login = time.mktime(user.last_login.timetuple())
userprofiles.append(userprofile)
return userprofiles
示例4: feed_issue_change
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_id [as 别名]
def feed_issue_change(self, user, repo, orgi_issue, current_issue_id):
current_issue = IssueManager.get_issue_by_id(current_issue_id)
if current_issue is None:
return
feed_cate = FEED_CATE.ISSUES
message = ''
if orgi_issue is None and current_issue is not None:
feed_type = FEED_TYPE.ISSUES_CREATE
message = u'新建了问题'
if orgi_issue is not None and (orgi_issue.subject != current_issue.subject or orgi_issue.content != current_issue.content or orgi_issue.category != current_issue.category):
feed_type = FEED_TYPE.ISSUES_UPDATE
message = u'更新了问题'
# status update
status_changes = []
if orgi_issue is not None:
if orgi_issue.tracker != current_issue.tracker:
status_changes.append(u'跟踪: ' + ISSUE_ATTR_DICT.TRACKER[current_issue.tracker])
if orgi_issue.status != current_issue.status:
status_changes.append(u'状态: ' + ISSUE_ATTR_DICT.STATUS[current_issue.status])
if orgi_issue.assigned != current_issue.assigned:
assigned_user = GsuserManager.get_user_by_id(current_issue.assigned)
if assigned_user is not None:
status_changes.append(u'指派给: @' + assigned_user.username)
if orgi_issue.priority != current_issue.priority:
status_changes.append(u'优先级: ' + ISSUE_ATTR_DICT.PRIORITY[current_issue.priority])
if len(status_changes) > 0:
message = ', '.join(status_changes)
feed_type = FEED_TYPE.ISSUES_STATUS_CHANGE
if message != '':
feed = Feed.create(user.id, repo.id, feed_cate, feed_type, current_issue.id)
# TODO
feed.first_refname = message
feed.save()
feedAction = FeedAction()
timestamp = float(time.mktime(feed.create_time.timetuple()))
feedAction.add_repo_feed(repo.id, timestamp, feed.id)
if repo.auth_type == 2:
feedAction.add_pri_user_feed(user.id, timestamp, feed.id)
else:
feedAction.add_pub_user_feed(user.id, timestamp, feed.id)
示例5: keyauth
# 需要导入模块: from gitshell.gsuser.models import GsuserManager [as 别名]
# 或者: from gitshell.gsuser.models.GsuserManager import get_user_by_id [as 别名]
def keyauth(request, fingerprint, command):
command = command.strip()
last_blank_idx = command.rfind(' ')
if last_blank_idx == -1:
return not_git_command()
pre_command = command[0 : last_blank_idx]
short_repo_path = command[last_blank_idx+1 :]
if pre_command == '' or '"' in pre_command or '\'' in pre_command or short_repo_path == '':
return not_git_command()
first_repo_char_idx = -1
slash_idx = -1
last_repo_char_idx = -1
for i in range(0, len(short_repo_path)):
schar = short_repo_path[i]
if first_repo_char_idx == -1 and re.match('\w', schar):
first_repo_char_idx = i
if schar == '/':
slash_idx = i
if re.match('[a-zA-Z0-9_\-]', schar):
last_repo_char_idx = i
if not (first_repo_char_idx > -1 and first_repo_char_idx < slash_idx and slash_idx < last_repo_char_idx):
return not_git_command()
username = short_repo_path[first_repo_char_idx : slash_idx]
reponame = short_repo_path[slash_idx+1 : last_repo_char_idx+1]
if reponame.endswith('.git'):
reponame = reponame[0 : len(reponame)-4]
if not (re.match('^[a-zA-Z0-9_\-]+$', username) and RepoManager.is_allowed_reponame_pattern(reponame)):
return not_git_command()
user = GsuserManager.get_user_by_name(username)
if user is None:
return not_git_command()
userprofile = GsuserManager.get_userprofile_by_id(user.id)
if userprofile is None:
return not_git_command()
if userprofile.used_quote > userprofile.quote:
return not_git_command()
repo = RepoManager.get_repo_by_userId_name(user.id, reponame)
if repo is None:
return not_git_command()
quote = userprofile.quote
# author of the repo
userPubkey = KeyauthManager.get_userpubkey_by_userId_fingerprint(user.id, fingerprint)
if userPubkey is not None:
return response_full_git_command(quote, pre_command, user, user, repo)
userpubkeys = KeyauthManager.list_userpubkey_by_fingerprint(fingerprint)
for userpubkey in userpubkeys:
# member of the repo
repoMember = RepoManager.get_repo_member(repo.id, userpubkey.user_id)
# member of the team user
teamMember = TeamManager.get_teamMember_by_teamUserId_userId(user.id, userpubkey.user_id)
if repoMember or teamMember:
pushUser = GsuserManager.get_user_by_id(userpubkey.user_id)
if 'git-receive-pack' in pre_command:
if RepoManager.is_allowed_access_repo(repo, pushUser, REPO_PERMISSION.WRITE):
return response_full_git_command(quote, pre_command, pushUser, user, repo)
elif RepoManager.is_allowed_access_repo(repo, pushUser, REPO_PERMISSION.READ_ONLY):
return response_full_git_command(quote, pre_command, pushUser, user, repo)
return not_git_command()