Models

Return to API Reference.

Project

class projector.models.Project(*args, **kwargs)

Most important model within whole application. It provides connection with all other models.

add_timeline_entry(action, author)

Initially wanted to implement as models.signal handler - as used in django-issues. Ended up with simple wrapper for expending project’s timeline. Some more logic may be added over time.

config

Returns Config for this project.

create_all_transitions()

Creates Transition objects linking all projects’ statuses with each other providing default task workflow schema.

create_config()

Creates default configuration for given project.

If successful, project should change it’s state to State.CONFIG_CREATED. Note, that this method doesn’t make any database related queries - state should be flushed manually.

create_repository(vcs_alias=None)

Creates repository for this project.

vcs_alias is retrieved using get_vcs_alias method but may be overridden by passing parameter directly.

If successful, project should change it’s state to State.REPOSITORY_CREATED. Note, that this method doesn’t make any database related queries - state should be flushed manually.

Parameters:
  • vcs_alias – alias for vcs backend, if None given this value is retrieved using get_vcs_alias instance’s method
Raises:
  • ImproperlyConfigured – if given vcs_alias is not one of enabled backends
  • ProjectorError – if repository is already created, or given vcs_alias is not one of vcs supported backends
create_workflow(workflow=None)

Creates default workflow for the project. We need to create objects required to work on issues (components, types, statuses with their transitions if custom workflow is used).

Workflow is retrieved using get_workflow method on the instance but may be overridden by passing parameter directly.

If successful, project should change it’s state to State.WORKFLOW_CREATED. Note, that this method doesn’t make any database related queries - state should be flushed manually.

Parameters:
  • workflow – python object defining tuples of dicts with information on project metadata; may be a string pointing to the object; if parameter is None, value would be retrieved using get_workflow instance’s method
fork(user, force_private=False)

Creates fork from internal context. As we use django-treebeard, we need to use it’s api to create a child.

Parameters:
  • user – new author for forked project
  • force_private – if set to True, project would be created as private
Returns:

projector.models.Project

Raises:
  • django.core.exceptions.PermissionDenied – when user is anonymous, not active or cannot access this project
  • projector.core.exceptions.ForkError – when user has already forked this project
get_actions()

Returns activity stream for this projcet.

get_all_forks()

Returns all forks for this project, starting from root. Returned object is a list (not Queryset) and contains this instance.

get_clone_cmd()

Returns client command to run in order to clone this repository.

get_config()

Returns Config for this project.

get_fork_for_user(user)

Returns fork of this project’s root for the given user. If user haven’t forked project from this instance’s tree, None is returned.

get_repo_url()

Returns full url of the project (with domain based on django sites framework).

get_transitions()

Returns queryset of Transition objects related with this project.

get_vcs_alias()

Returns vcs_alias which should be already configured for this project. Defaulting to PROJECTOR_DEFAULT_VCS_BACKEND.

is_fork()

Returns True if this instance is a fork (has parent), False otherwise.

set_author_permissions()

Creates all permissions for project’s author.

If successful, project should change it’s state to State.AUTHOR_PERMISSIONS_CREATED. Note, that this method doesn’t make any database related queries - state should be flushed manually.

set_memberships()

Creates Membership for this project and it’s author. If author is a team, we need to create Team object too.

If successful, project should change it’s state to State.MEMBERSHIPS_CREATED. Note, that this method doesn’t make any database related queries - state should be flushed manually.

set_vcs_alias(vcs_alias)

Prepares this project for repository creation process. Note that ProjectorError is raised if repository for this instance has been already created. Same exception is raised if vcs does not support backend for the given alias.

Parameters:
  • vcs_alias – alias for vcs backend
setup(vcs_alias=None, workflow=None)

Should be called AFTER instance is saved into database as all methods here creates necessary models for the project and in order to create relations it is needed that instance is persisted first.

See also ProjectManager.

Config

class projector.models.Config(*args, **kwargs)

This model stores configuration on “per project” basis.

Milestone

class projector.models.Milestone(*args, **kwargs)

Milestone(id, project_id, name, slug, description, author_id, created_at, deadline, date_completed)

Component

class projector.models.Component(*args, **kwargs)

Component(id, project_id, name, slug, description)

Priority

class projector.models.Priority(*args, **kwargs)

Priority(id, name, description, order, project_id, slug)

Status

class projector.models.Status(*args, **kwargs)

Status(id, name, description, order, project_id, is_resolved, is_initial, slug)

can_change_to(new_status)

Checks if Transition object with source set to self and destination to given new_status exists.

Transition

class projector.models.Transition(*args, **kwargs)

Instances allow to change source Status to destination Status. Needed for custom workflows.

TaskType

class projector.models.TaskType(*args, **kwargs)

TaskType(id, name, description, order, project_id)

AbstractTask

class projector.models.Task(*args, **kwargs)

Task(created_at, author_id, author_ip, revision, summary, description, status_id, priority_id, type_id, owner_id, deadline, milestone_id, component_id, id_pk, id, project_id, edited_at, editor_id, editor_ip)

comment

If comment is set, clean method won’t check if there were changes made to task itself

create_revision()

Creates revision (instance of TaskRevision) for this task. If comment has been set, it would be used in revision creation process.

current_revision()

Returns last TaskRevision (not self) attached to this task. If there were no changes made yet, None is returned.

static diff(new, old=None)

Returns differences between old and new task instances, as dict. Fields would become keys of returned dict. Tuples of old value and new value would be dict’s values.

get_long_content()

Returns content of the task, suitable as email message’s body.

get_revisions(force_query=False)

Returns TaskRevision objects related to this Task instance. Each TaskRevision would have additional attribute changes which would containt result of Task.diff method. For first revision changes would be empty dict.

notify(recipient_list=None)

Notifies about task’s status. If recipient_list is None, would send a note to everyone who watch this task.

revisions

Returns TaskRevision objects related to this Task instance. Each TaskRevision would have additional attribute changes which would containt result of Task.diff method. For first revision changes would be empty dict.

TaskRevision

class projector.models.TaskRevision(*args, **kwargs)

TaskRevision(id, created_at, author_id, author_ip, revision, summary, description, status_id, priority_id, type_id, owner_id, deadline, milestone_id, component_id, task_id, comment)

Task

class projector.models.Task(*args, **kwargs)

Task(created_at, author_id, author_ip, revision, summary, description, status_id, priority_id, type_id, owner_id, deadline, milestone_id, component_id, id_pk, id, project_id, edited_at, editor_id, editor_ip)

comment

If comment is set, clean method won’t check if there were changes made to task itself

create_revision()

Creates revision (instance of TaskRevision) for this task. If comment has been set, it would be used in revision creation process.

current_revision()

Returns last TaskRevision (not self) attached to this task. If there were no changes made yet, None is returned.

static diff(new, old=None)

Returns differences between old and new task instances, as dict. Fields would become keys of returned dict. Tuples of old value and new value would be dict’s values.

get_long_content()

Returns content of the task, suitable as email message’s body.

get_revisions(force_query=False)

Returns TaskRevision objects related to this Task instance. Each TaskRevision would have additional attribute changes which would containt result of Task.diff method. For first revision changes would be empty dict.

notify(recipient_list=None)

Notifies about task’s status. If recipient_list is None, would send a note to everyone who watch this task.

revisions

Returns TaskRevision objects related to this Task instance. Each TaskRevision would have additional attribute changes which would containt result of Task.diff method. For first revision changes would be empty dict.

Membership

class projector.models.Membership(*args, **kwargs)

Membership(id, member_id, project_id, joined_at)

Team

class projector.models.Team(*args, **kwargs)

Team(id, group_id, project_id, joined_at)

class projector.managers.TeamManager
convert_from_user(user)

Converts User instance into Team instance. It won’t delete user, his or her profile would simply get team attribute set to newly created Team and is_team attribute would be set to True.

for_user(user=None)

Returns queryset of Team instances of groups for given user.

UserProfile

class projector.models.UserProfile(*args, **kwargs)

Base user profile class for django-projector. Would be abstract if AUTH_PROFILE_MODULE is not set or doesn’t equal to projector.UserProfile.

Table Of Contents

Previous topic

Managers

Next topic

Utils

This Page