def get_for_project(self, project): """ Returns Task instance with default values set related to given project. """ from projector.models import Task status = get_first_or_None(project.status_set.filter(is_initial=True)) type = get_first_or_None(project.tasktype_set) priority = get_first_or_None(project.priority_set) component = get_first_or_None(project.component_set) task = Task( project=project, status=status, type=type, priority=priority, component=component, ) return task
def get_for_project(self, project): """ Returns Task instance with default values set related to given project. """ from projector.models import Task status = get_first_or_None( project.status_set.filter(is_initial=True)) type = get_first_or_None(project.tasktype_set) priority = get_first_or_None(project.priority_set) component = get_first_or_None(project.component_set) task = Task( project = project, status = status, type = type, priority = priority, component = component, ) return task
def response(self, request, username, project_slug): _max_order_status = get_first_or_None( self.project.status_set.only('order').order_by('-order')) status = Status(project=self.project, order=_max_order_status and _max_order_status.order+1 or 1) form = StatusForm(request.POST or None, instance=status) if request.method == 'POST' and form.is_valid(): form.save() msg = _("Status added successfully") messages.success(request, msg) return redirect(self.project.get_workflow_url()) context = { 'project': self.project, 'form': form, } return context
def response(self, request, username, project_slug): _max_order_status = get_first_or_None( self.project.status_set.only('order').order_by('-order')) status = Status(project=self.project, order=_max_order_status and _max_order_status.order + 1 or 1) form = StatusForm(request.POST or None, instance=status) if request.method == 'POST' and form.is_valid(): form.save() msg = _("Status added successfully") messages.success(request, msg) return redirect(self.project.get_workflow_url()) context = { 'project': self.project, 'form': form, } return context