def get_git_path_info(path): path_split = path.split("/") git_name = path_split[1] # raw path: project_id.git if git_name.endswith('.git'): project = Project.get_by_name(git_name[:-4]) if project: path_split[1] = "%s.git" % project.id return '/'.join(path_split) else: owner_name, git_name = path_split[1:3] # user project: user/project.git user = User.get_by_name(owner_name) if user: project = Project.get_by_name_and_owner(git_name[:-4], user.id) if project: path_split[1] = "" path_split[2] = "%s.git" % project.id return '/'.join(path_split[1:]) return # org project: org/project.git org = Organization.get_by_name(owner_name) if org: project = Project.get_by_name_and_owner(git_name[:-4], user.id) if project: path_split[1] = "" path_split[2] = "%s.git" % project.id return '/'.join(path_split[1:])
def api_list_user(users): rs = [] for username in users: user = User.get_by_name(username) rs.append({'username': user.username, 'avatar_url': user.avatar_url, 'email': user.email, 'url': user.url, }) return rs
def __init__(self, repo, commit): self.repo = repo self._commit = commit self.type = 'commit' self.repo_name = repo.name parent = commit['parent'][0] if commit['parent'] else None self.parent = parent self.parents = commit['parent'] message = ("%s\n\n%s" % ( commit['message'], remove_unknown_character(commit['body'])) ).strip() self.message = message self.message_header = commit['message'] self.message_body = commit['body'] self.sha = commit['sha'] self.tree = commit['tree'] author_name = commit['author']['name'] self.author_name = author_name author_email = email_normalizer(author_name, commit['author']['email']) self.author_email = author_email self.email = author_email # FIXME: user #author = User(name=author_name, email=author_email) author = User.get_by_name(author_name) self.author = author author_date = datetime.fromtimestamp(commit['author']['time'], FixedOffset(commit['author']['offset'])) author_timestamp = str(commit['author']['time']) self.author_time = author_date self.author_timestamp = author_timestamp self.time = author_date committer_name = commit['committer']['name'] committer_email = email_normalizer( committer_name, commit['committer']['email']) # FIXME: user #committer = User(name=committer_name, email=committer_email) committer = User.get_by_name(committer_name) self.committer = committer committer_date = datetime.fromtimestamp(commit['committer']['time'], FixedOffset(commit['committer']['offset'])) self.committer_time = committer_date
def __init__(self, repo, commit): self.repo = repo self._commit = commit self.type = 'commit' self.repo_name = repo.name parent = commit['parent'][0] if commit['parent'] else None self.parent = parent self.parents = commit['parent'] message = ("%s\n\n%s" % (commit['message'], remove_unknown_character( commit['body']))).strip() self.message = message self.message_header = commit['message'] self.message_body = commit['body'] self.sha = commit['sha'] self.tree = commit['tree'] author_name = commit['author']['name'] self.author_name = author_name author_email = email_normalizer(author_name, commit['author']['email']) self.author_email = author_email self.email = author_email # FIXME: user #author = User(name=author_name, email=author_email) author = User.get_by_name(author_name) self.author = author author_date = datetime.fromtimestamp( commit['author']['time'], FixedOffset(commit['author']['offset'])) author_timestamp = str(commit['author']['time']) self.author_time = author_date self.author_timestamp = author_timestamp self.time = author_date committer_name = commit['committer']['name'] committer_email = email_normalizer(committer_name, commit['committer']['email']) # FIXME: user #committer = User(name=committer_name, email=committer_email) committer = User.get_by_name(committer_name) self.committer = committer committer_date = datetime.fromtimestamp( commit['committer']['time'], FixedOffset(commit['committer']['offset'])) self.committer_time = committer_date
def _q_index(request): if request.method == 'POST': name = request.get_form_var('login') password = request.get_form_var('password') user = User.get_by_name(name) if user and user.validate_password(password): session = request.session session.set_user(user.id) return request.redirect('/') return st('login.html')
def api_list_user(users): rs = [] for username in users: user = User.get_by_name(username) rs.append({ 'username': user.username, 'avatar_url': user.avatar_url, 'email': user.email, 'url': user.url, }) return rs
def _q_lookup(request, name): if name in ['static', 'js', 'css']: return StaticUI(request, name) user = User.get_by_name(name) if user: return UserUI(user) org = Organization.get_by_name(name) if org: return OrganizationUI(org) raise TraversalError
def _q_lookup(self, request, name): from code.views.api.v1.users import UserUI from code.views.api.v1.organizations import OrganizationUI user = User.get_by_name(name) if user: return UserUI(user) org = Organization.get_by_name(name) if org: return OrganizationUI(org) raise TraversalError
def __init__(self, header): self.login = None self.passwd = None self.user = None try: auth_type, auth_string = header.split() login, passwd = b64decode(auth_string).split(':') self.login = login self.passwd = passwd self.user = User.get_by_name(login) except ValueError: pass except TypeError: pass