Project repository views

Return to Views.

RepositoryView

class projector.views.project_repository.RepositoryView(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project.ProjectView

Base repository view.

View attributes

  • perms_private: ['view_project', 'can_read_repository']
check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

response(request, *args, **kwargs)

Should be overridden at subclass. It always requires django.http.HttpRequest instance to be passed as first positional argument.

May return a dict or django.http.HttpResponse instance. If dict is returned it is treated as context and view would try to render it using self.template_name.

Returns:dict or django.http.HttpResponse instance

RepositoryBrowse

class projector.views.project_repository.RepositoryBrowse(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryView

Repository browsing view.

In fact, this is only a wrapper for vcs.web.simplevcs.views.browse_repository view.

View attributes

  • template_name: 'projector/project/repository/browse.html'

Wrapped view

browse_repository(request, template_name, repository=None, repository_path=None, repository_alias=None, revision=None, node_path='', extra_context={})

Generic repository browser view.

Required arguments:

  • Either repository or (repository_path and repository_alias is required
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • revision: object with which backend may identify changeset. In example, mercurial backend recognizes hex or short strings, revision numbers (given as integer or string) or tip string. If none specified, most recent changeset (sometimes called tip) is taken.
  • node_path: relative location of the node in the repository (location to file or directory). By default this is an empty string which would retrieve root node from repository.
  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • changeset: based on the given revision or tip if none given
  • root: repository’s node on the given node_path
  • readme_node: FileNode instance if returning root is a DirNode and a readme file can be found at it’s file listing (can be a file which name starts with README, with or without any extension, case is irrelevant); if no readme file could be found, None is returned
check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

RepositoryFileDiff

class projector.views.project_repository.RepositoryFileDiff(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryView

View presenting differences between two file nodes.

In fact, this is only a wrapper for vcs.web.simplevcs.views.browse_repository view.

View attributes

  • template_name: 'projector/project/repository/diff.html'

Wrapped view

diff_file(request, file_path, template_name, repository=None, repository_path=None, repository_alias=None, revision_old=None, revision_new=None, extra_context=None)

Generic repository browser view showing diff of specified file.

Required arguments:

  • Either repository or (repository_path and repository_alias is required)
  • file_path: relative location of the file node in the repository.
  • revision_old: object identifying changeset at backend.
  • revision_new: object identifying changeset at backend.
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • file_old: FileNode retrieved by backend for given revision_old param
  • file_new: FileNode retrieved by backend for given revision_new param
  • diff_content: unified diff for retrieved file_old and file_new contents
check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

RepositoryFileRaw

class projector.views.project_repository.RepositoryFileRaw(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryView

This view returns FileNode from repository as file attachment.

check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

RepositoryFileAnnotate

class projector.views.project_repository.RepositoryFileAnnotate(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryBrowse

View presenting file from repository but with additional annotate information (shows changeset for which each line was added/changed).

View attributes

  • template_name: 'projector/project/repository/annotate.html'

In fact, annotate is done at the template level.

check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

RepositoryChangesetList

class projector.views.project_repository.RepositoryChangesetList(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryView

Shows list of changesets for requested project’s repository.

View attributes

  • template_name: 'projector/project/repository/changeset_list.html'

Additional context variables

  • repository: repository for requested project
  • CHANGESETS_PAGINATE_BY: number of changesets to be shown at template for each page. Taken from project configuration’s changesets_paginate_by attribute.
check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

RepositoryChangesetDetail

class projector.views.project_repository.RepositoryChangesetDetail(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project_repository.RepositoryView

Shows detailed information about requested commit.

In fact, this is only a wrapper for vcs.web.simplevcs.views.diff_changeset view.

View attributes

  • template_name: 'projector/project/repository/changeset_detail.html'

Wrapped view

diff_changeset(request, template_name, repository=None, repository_path=None, repository_alias=None, revision=None, extra_context=None)

Generic repository browser view showing diffs for given revision.

Required arguments:

  • Either repository or (repository_path and repository_alias is required
  • revision: object identifying changeset at backend.
  • template_name: The full name of a template to use in rendering the page.

Optional arguments:

  • extra_context: A dictionary of values to add to the template context. By default, this is an empty dictionary.

Template context:

In addition to extra_context, the template’s context will be:

  • repository: same what was given or computed from repository_path and repository_alias
  • changeset: Changeset retrieved by backend for given revision param; nodes from added and changed attributes of the changeset have one extra attribute: diff which is instance of vcs.utils.diffs.DiffProcessor
check_permissions()

Checks if user has permissions to call this view. By default, this method would perform checks using requested Project instance and permission list retrieved by get_required_perms method.

get_error_response()

Combined with has_errors could be used like this:

def response(self, request):
    if self.has_errors:
        return self.get_error_response()
    ...
get_required_perms()

Returns list of required perms based on instance’s attributes. If modified, make sure it’s thread-safe, i.e. don’t change self.perms directly but create new temporary list of permissions.

Table Of Contents

Previous topic

Project views

Next topic

Users views

This Page