Beispiel #1
0
    def get_context_data(self, **ctx):
        context = super(RepoListView, self).get_context_data(**ctx)

        if 'by-last-update' in self.request.GET:
            sort_key = lambda repo: repo.get_last_updated_at()
            reverse = True
        else:
            sort_key = lambda repo: repo.name
            reverse = False

        context['repos'] = sorted(RepoManager.all_repos(), key=sort_key,
                                  reverse=reverse)
        return context
Beispiel #2
0
    def get_context_data(self, **ctx):
        context = super(RepoListView, self).get_context_data(**ctx)

        if 'by-last-update' in self.request.GET:
            sort_key = lambda repo: repo.get_last_updated_at()
            reverse = True
        else:
            sort_key = lambda repo: repo.name
            reverse = False

        context['repos'] = sorted(RepoManager.all_repos(),
                                  key=sort_key,
                                  reverse=reverse)
        return context
Beispiel #3
0
    def get_context_data(self, **ctx):
        context = super(BaseRepoView, self).get_context_data(**ctx)

        repo = RepoManager.get_repo(self.kwargs['repo'])
        rev = self.kwargs.get('rev')
        path = self.kwargs.get('path')
        if isinstance(path, unicode):
            path = path.encode("utf-8")
	if isinstance(rev, unicode):
            rev = rev.encode("utf-8")
        
	if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise RepoException("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise RepoException("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise RepoException("File not found")

        context.update({
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        })

        return context
Beispiel #4
0
    def get_context_data(self, **ctx):
        context = super(BaseRepoView, self).get_context_data(**ctx)

        repo = RepoManager.get_repo(self.kwargs['repo'])
        rev = self.kwargs.get('rev')
        path = self.kwargs.get('path')
        if isinstance(path, unicode):
            path = path.encode("utf-8")

        if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise RepoException("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise RepoException("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise RepoException("File not found")

        context.update({
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        })

        return context