def get_context_data(self, **kwargs): context = super(TaskDetailView, self).get_context_data(**kwargs) task = self.object if self.request.user.has_perm('indigo_api.change_task'): context['change_task_permission'] = True if has_transition_perm(task.submit, self): context['submit_task_permission'] = True if has_transition_perm(task.reopen, self): context['reopen_task_permission'] = True if has_transition_perm(task.unsubmit, self): context['unsubmit_task_permission'] = True if has_transition_perm(task.close, self): context['close_task_permission'] = True context['possible_workflows'] = Workflow.objects.unclosed().filter( country=task.country, locality=task.locality).all() Task.decorate_potential_assignees([task], self.country) return context
def get_context_data(self, *args, **kwargs): context = super(WorkflowDetailView, self).get_context_data(**kwargs) # stats self.object.n_tasks = self.object.tasks.count() self.object.n_done = self.object.tasks.closed().count() self.object.pct_done = self.object.n_done / (self.object.n_tasks or 1) * 100.0 context['form'] = self.form tasks = self.form.filter_queryset(self.object.tasks) \ .select_related('document__language', 'document__language__language')\ .defer('document__document_xml', 'document__search_text', 'document__search_vector')\ .all() context['tasks'] = tasks context['has_tasks'] = self.object.n_tasks > 0 context['task_groups'] = Task.task_columns( ['open', 'pending_review', 'assigned'], tasks) context['possible_tasks'] = self.place.tasks\ .unclosed()\ .exclude(workflows=self.object) \ .select_related('document__language', 'document__language__language') \ .defer('document__document_xml', 'document__search_text', 'document__search_vector')\ .all() Task.decorate_potential_assignees(tasks, self.country) context[ 'may_close'] = not self.object.closed and self.object.n_tasks == self.object.n_done context['may_reopen'] = self.object.closed stream = any_stream(self.object) context['activity_stream'] = self.coalesce_entries(stream) return context
def get_context_data(self, **kwargs): context = super(WorkTasksView, self).get_context_data(**kwargs) context['tasks'] = context['work'].tasks.all() context['task_groups'] = Task.task_columns( ['open', 'assigned', 'pending_review', 'done', 'cancelled'], context['tasks']) Task.decorate_potential_assignees(context['tasks'], self.country) return context
def get_context_data(self, **kwargs): context = super(TaskListView, self).get_context_data(**kwargs) context['task_labels'] = TaskLabel.objects.all() context['form'] = self.form context['frbr_uri'] = self.request.GET.get('frbr_uri') context['task_groups'] = Task.task_columns( self.form.cleaned_data['state'], context['tasks']) Task.decorate_potential_assignees(context['tasks'], self.country) return context
def get_context_data(self, **kwargs): context = super(TaskDetailView, self).get_context_data(**kwargs) task = self.object # merge actions and comments actions = task.action_object_actions.all() task_content_type = ContentType.objects.get_for_model(self.model) comments = list(Comment.objects\ .filter(content_type=task_content_type, object_pk=task.id)\ .select_related('user')) # get the annotation for the particular task try: task_annotation = task.annotation except Annotation.DoesNotExist: task_annotation = None # for the annotation that is linked to the task, get all the replies if task_annotation: # get the replies to the annotation annotation_replies = Annotation.objects.filter(in_reply_to=task_annotation)\ .select_related('created_by_user') comments.extend([ Comment(user=a.created_by_user, comment=a.text, submit_date=a.created_at) for a in annotation_replies ]) context['task_timeline'] = sorted( chain(comments, actions), key=lambda x: x.submit_date if hasattr(x, 'comment') else x.timestamp) context['possible_workflows'] = Workflow.objects.unclosed().filter( country=task.country, locality=task.locality).all() # warn when submitting task on behalf of another user Task.decorate_submission_message([task], self) Task.decorate_potential_assignees([task], self.country) Task.decorate_permissions([task], self) # add work to context if task.work: context['work'] = task.work context['work_json'] = json.dumps( WorkSerializer(instance=task.work, context={ 'request': self.request }).data) return context
def get_context_data(self, **kwargs): context = super(TaskListView, self).get_context_data(**kwargs) context['task_labels'] = TaskLabel.objects.all() context['form'] = self.form context['frbr_uri'] = self.request.GET.get('frbr_uri') context['task_groups'] = Task.task_columns(self.form.cleaned_data['state'], context['tasks']) # warn when submitting task on behalf of another user Task.decorate_submission_message(context['tasks'], self) Task.decorate_potential_assignees(context['tasks'], self.country) Task.decorate_permissions(context['tasks'], self) return context
def get_context_data(self, **kwargs): context = super(WorkTasksView, self).get_context_data(**kwargs) context['tasks'] = context['work'].tasks.all() context['task_groups'] = Task.task_columns( ['open', 'assigned', 'pending_review', 'done', 'cancelled'], context['tasks']) # warn when submitting task on behalf of another user Task.decorate_submission_message(context['tasks'], self) Task.decorate_potential_assignees(context['tasks'], self.country) Task.decorate_permissions(context['tasks'], self) return context
def get_context_data(self, **kwargs): context = super(TaskDetailView, self).get_context_data(**kwargs) task = self.object # merge actions and comments actions = task.action_object_actions.all() task_content_type = ContentType.objects.get_for_model(self.model) comments = Comment.objects\ .filter(content_type=task_content_type, object_pk=task.id)\ .select_related('user') context['task_timeline'] = sorted( chain(comments, actions), key=lambda x: x.submit_date if hasattr(x, 'comment') else x.timestamp) context['possible_workflows'] = Workflow.objects.unclosed().filter( country=task.country, locality=task.locality).all() Task.decorate_potential_assignees([task], self.country) Task.decorate_permissions([task], self) return context
def get_context_data(self, *args, **kwargs): context = super(WorkflowDetailView, self).get_context_data(**kwargs) # stats self.object.n_tasks = self.object.tasks.count() self.object.n_done = self.object.tasks.closed().count() self.object.pct_done = self.object.n_done / (self.object.n_tasks or 1) * 100.0 context['form'] = self.form tasks = self.form.filter_queryset(Task.objects.filter(workflows=self.object)) \ .select_related('document__language', 'document__language__language')\ .defer('document__document_xml')\ .all() context['tasks'] = tasks context['has_tasks'] = self.object.n_tasks > 0 context['task_groups'] = Task.task_columns( ['open', 'pending_review', 'assigned'], tasks) context['possible_tasks'] = Task.objects.filter(country=self.country, locality=self.locality)\ .unclosed()\ .exclude(workflows=self.object) \ .select_related('document__language', 'document__language__language') \ .defer('document__document_xml')\ .all() # warn when submitting task on behalf of another user Task.decorate_submission_message(tasks, self) Task.decorate_potential_assignees(tasks, self.country) Task.decorate_permissions(tasks, self) context[ 'may_close'] = not self.object.closed and self.object.n_tasks == self.object.n_done context['may_reopen'] = self.object.closed stream = any_stream(self.object) context['activity_stream'] = self.coalesce_entries(stream) return context