Project views

Return to Views.

ProjectView

class projector.views.project.ProjectView(request, username=None, project_slug=None, *args, **kwargs)

Base class for all projector views.

Logic should be implemented at response method.

Would check necessary permissions defined by class attributes: perms, perms_GET and perms_POST.

perms are always checked, perms_POST are additional checks which would be made for GET method requests only and perms_POST would be made for POST method requests. perms_private would be checked for private projects only.

Note

This view class should be considered as abstract - it does not implement response method.

View attributes

  • perms: []
  • perms_private: ['view_project']
  • perms_GET: []
  • perms_POST: []
  • template_error_name: projector/project/error.html
  • template_pending_name: projector/project/pending.html

Required parameters

  • request: django.http.HttpRequest instance, which is always passed as first positional argument
  • username: Project would be fetched using this parameter as User‘s username attribute lookup
  • project_slug: Project would be fetched using this parameter as Project‘s slug attribute lookup

Context variables

  • project: Project instance fetched using provided parameters
  • STATES: class describing project states (projector.models.State)
  • project_root: Project instance which is a root in requested project forks tree. If requested project is a root, value of this variable would be same as project variable.
  • forks: list of Project instances which are fork of the requested project. If requested project is a root, list would contain only requested project (would be same as project variable).
  • user_fork: Project instance representing request.user‘s own fork of requested project. If user haven’t forked this project then user_fork would be None.
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_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.

ProjectDetailView

class projector.views.project.ProjectDetailView(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project.ProjectView

Returns selected project’s detail for user given in request. We make necessary permission checks after dispatching between normal and mercurial request, as mercurial requests has it’s own permission requirements.

View attributes

  • template_name: projector/project/detail.html
  • csrf_exempt: True
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_required_perms()

Returns empty list if request is identified as mercurial request. For mercurial requests lets underlying view to manage permissions checks.

ProjectListView

class projector.views.project.ProjectListView(request, *args, **kwargs)

Bases: projector.core.controllers.View

Project listing view.

View attributes

  • template_name: projector/project/list.html

Additional context variables

  • project_list: Project queryset filtered for request’s user. Additionally, projects are annotated with Task count (available as task__count attribute on each retrieved project).

ProjectCreateView

class projector.views.project.ProjectCreateView(request, *args, **kwargs)

Bases: projector.core.controllers.View

New project creation view.

Additional context variables

static can_create(user, request=None)

Checks if given user can create project. Note that this function will not validate project itself. If PROJECTOR_MILIS_BETWEEN_PROJECT_CREATION is greater than miliseconds since last time this user has created a project then he or she is allowed to create new one.

If user is trying to create more project than specified by PROJECTOR_MAX_PROJECTS_PER_USER configuration value then we disallow.

If request is given, sends messages.

ProjectForkView

class projector.views.project.ProjectForkView(request, username=None, project_slug=None, *args, **kwargs)

Bases: projector.views.project.ProjectView

Project fork (internal fork) view.

See also

Forking

Additional context variables

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_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

Views

Next topic

Project repository views

This Page