コード例 #1
0
ファイル: models.py プロジェクト: drew-sj/gitshell
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict(
            (x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict(
            (x.id, x)
            for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[
                    notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge(
            ) or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(
                    notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages
コード例 #2
0
ファイル: views.py プロジェクト: drew-sj/gitshell
def _convert_to_commit_dict(request, commit_ids):
    commit_dict = {}
    allowed_view_access_repoId_set = Set()
    commits = RepoManager.list_commits_by_ids(commit_ids)
    repos = RepoManager.list_repo_by_ids(
        list(Set([x.repo_id for x in commits])))
    for repo in repos:
        if repo.auth_type == 2:
            if not request.user.is_authenticated(
            ) or not RepoManager.is_allowed_view_access_repo(
                    repo, request.user):
                continue
        allowed_view_access_repoId_set.add(repo.id)
    for commit in commits:
        if commit.repo_id in allowed_view_access_repoId_set:
            commit_dict[commit.id] = commit
    return commit_dict
コード例 #3
0
ファイル: views.py プロジェクト: drew-sj/gitshell
def explore(request):
    repo_ids = get_hot_repo_ids()
    raw_repos = RepoManager.list_repo_by_ids(repo_ids)
    repos = [x for x in raw_repos if x.auth_type != 2]
    user_ids = [x.user_id for x in repos]
    users_dict = GsuserManager.map_users(user_ids)
    username_dict = dict([(users_dict[x]['id'], users_dict[x]['username']) for x in users_dict])
    userimgurl_dict = dict([(users_dict[x]['id'], users_dict[x]['imgurl']) for x in users_dict])

    feedAction = FeedAction()
    latest_feeds = feedAction.get_latest_feeds(0, 100)
    feeds_as_json = latest_feeds_as_json(request, latest_feeds)

    response_dictionary = {'repos': repos, 'users_dict': users_dict, 'username_dict': username_dict, 'userimgurl_dict': userimgurl_dict, 'feeds_as_json': feeds_as_json}
    return render_to_response('explore/explore.html',
                          response_dictionary,
                          context_instance=RequestContext(request))
コード例 #4
0
ファイル: models.py プロジェクト: ZheYuan/gitshell
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict((x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict((x.id, x) for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge() or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages