Exemplo n.º 1
0
  def context(self):
    """Returns the context for this view.
    """
    task = self.data.task

    context = {
      'page_name': '%s - %s' %(task.title, task.org.name),
      'task': task,
      'is_mentor': self.data.mentorFor(task.org),
      'task_info': TaskInformation(self.data),
    }

    if task.deadline:
      context['complete_percentage'] = timeline_helper.completePercentage(
          end=task.deadline, duration=(task.time_to_complete*3600))

    if self.data.is_visible:
      context['work_submissions'] = WorkSubmissions(self.data)
      context['comment_ids'] = [i.key().id() for i in self.data.comments]
      context['comments'] = CommentsTemplate(self.data)

    if not context['is_mentor']:
      # Programmatically change css for non-mentors, to for instance show
      # the open cog when a task can be claimed.
      if task.status == 'Closed':
        block_type = 'completed'
      elif task_logic.isOwnerOfTask(task, self.data.profile):
        block_type = 'owned'
      elif task.status in ACTIVE_CLAIMED_TASK:
        block_type = 'claimed'
      else:
        block_type = 'open'
      context['block_task_type'] = block_type

    return context
Exemplo n.º 2
0
  def completePercentage(self):
    """Computes the remaining time percentage

    It is VERY IMPORTANT TO NOTE here that this percentage is between the
    task opening date and the date task can be last claimed.

    However if the all work stop deadline is set after the task claim date
    that will only be visible on per task basis, this percentage would still
    return zero.
    """
    start = self.tasksPubliclyVisibleOn()
    end = self.tasksClaimEndOn()
    return timeline_helper.completePercentage(start, end)
Exemplo n.º 3
0
    def completePercentage(self):
        """Computes the remaining time percentage

    It is VERY IMPORTANT TO NOTE here that this percentage is between the
    task opening date and the date task can be last claimed.

    However if the all work stop deadline is set after the task claim date
    that will only be visible on per task basis, this percentage would still
    return zero.
    """
        start = self.tasksPubliclyVisibleOn()
        end = self.tasksClaimEndOn()

        if not start or not end:
            return 0.0

        return timeline_helper.completePercentage(start, end)
Exemplo n.º 4
0
    def context(self, data, check, mutator):
        """Returns the context for this view."""
        task = data.task

        context = {
            'page_name': '%s - %s' % (task.title, task.org.name),
            'task': task,
            'is_mentor': data.mentorFor(task.org.key()),
            'task_info': TaskInformation(data),
        }

        if task.deadline:
            # TODO(nathaniel): This is math - move it to a helper function.
            context[
                'complete_percentage'] = timeline_helper.completePercentage(
                    end=task.deadline, duration=(task.time_to_complete * 3600))

        if data.is_visible:
            context['work_submissions'] = WorkSubmissions(data)
            context['comment_ids'] = [i.key().id() for i in data.comments]
            context['comments'] = CommentsTemplate(data)

        if not context['is_mentor']:
            # Programmatically change css for non-mentors, to for instance show
            # the open cog when a task can be claimed.
            if task.status == 'Closed':
                block_type = 'completed'
            elif task_logic.isOwnerOfTask(task, data.ndb_profile):
                block_type = 'owned'
            elif task.status in ACTIVE_CLAIMED_TASK:
                block_type = 'claimed'
            else:
                block_type = 'open'
            context['block_task_type'] = block_type

        return context