Exemple #1
0
 def get(self, domain_identifier, task_identifier):
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         self.error(404)
         return
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     user = api.get_user()
     domain = api.get_domain(domain_identifier)
     subtasks = api.get_all_subtasks(domain_identifier, task)
     parent_task = task.parent_task
     parent_identifier = parent_task.identifier() if parent_task else ""
     parent_title = parent_task.title() if parent_task else ""
     template_values = {
         'domain_name': domain.name,
         'domain_identifier': domain_identifier,
         'user_name': user.name,
         'user_identifier': user.identifier(),
         'messages': get_and_delete_messages(session),
         'task_title': task.title(),
         'task_description': task.description_body(),
         'task_assignee': assignee_description(task),
         'task_identifier': task.identifier(),
         'task_can_assign_to_self': api.can_assign_to_self(task, user),
         'subtasks': _task_template_values(subtasks, user),
         'parent_identifier': parent_identifier,
         'parent_title': parent_title,
     }
     path = os.path.join(os.path.dirname(__file__),
                         'templates/taskdetail.html')
     self.response.out.write(template.render(path, template_values))
Exemple #2
0
def _task_template_values(tasks, user, level=0):
    """
    Returns a list of dictionaries containing the template values for
    each task.

    Args:
        tasks: A list of Task model instance
        user: A User model instance

    Returns a list of dictionaries for each task, in the same order.
    """
    user_identifier = user.identifier()
    return [
        {
            'title': task.title(),
            # There are only 4 levels available in the css
            'level': min(level, 3),
            'completed': task.is_completed(),
            'is_assigned': task.assignee_key() != None,
            'can_assign_to_self': api.can_assign_to_self(task, user),
            'assignee_description': task.assignee_description(),
            'can_complete': api.can_complete_task(task, user),
            'summary': task.personalized_summary(user_identifier),
            'active': task.is_active(user_identifier),
            'atomic': task.atomic(),
            'id': task.identifier()
        } for task in tasks
    ]
Exemple #3
0
def _task_template_values(tasks, user, level=0):
    """
    Returns a list of dictionaries containing the template values for
    each task.

    Args:
        tasks: A list of Task model instance
        user: A User model instance

    Returns a list of dictionaries for each task, in the same order.
    """
    user_identifier = user.identifier()
    return [{ 'title': task.title(),
              # There are only 4 levels available in the css
              'level': min(level, 3),
              'completed': task.is_completed(),
              'is_assigned': task.assignee_key() != None,
              'can_assign_to_self': api.can_assign_to_self(task, user),
              'assignee_description': task.assignee_description(),
              'can_complete': api.can_complete_task(task, user),
              'summary': task.personalized_summary(user_identifier),
              'remaining': task.subtasks_remaining(user_identifier),
              'active': task.is_active(user_identifier),
              'atomic': task.atomic(),
              'id': task.identifier() }
            for task in tasks]
Exemple #4
0
    def get(self, domain_identifier, task_identifier):
        task = api.get_task(domain_identifier, task_identifier)
        user = api.get_and_validate_user(domain_identifier)
        view = self.request.get('view', 'all')
        if not task or not user:
            self.error(404)
            return
        session = Session(writer='cookie',
                          wsgiref_headers=self.response.headers)
        user = api.get_logged_in_user()
        domain = api.get_domain(domain_identifier)
        if view == 'yours':
            subtasks = api.get_assigned_tasks(domain_identifier,
                                              user,
                                              root_task=task,
                                              limit=200)
            subtasks_heading = "Subtasks of '%s' Assigned to You" % task.title(
            )
            no_subtasks_description = "No subtasks are assigned to you."
        elif view == 'open':
            subtasks = api.get_open_tasks(domain_identifier,
                                          root_task=task,
                                          limit=200)
            subtasks_heading = "Open Subtasks of '%s'" % task.title()
            no_subtasks_description = "No open subtasks for this task."
        else:  # view == 'all' or None
            view = 'all'
            user_id = user.identifier()
            subtasks = api.get_all_direct_subtasks(domain_identifier,
                                                   root_task=task,
                                                   limit=200,
                                                   user_identifier=user_id)
            subtasks_heading = "All Subtasks of '%s'" % task.title()
            no_subtasks_description = "No subtasks for this task."

        parent_task = task.parent_task
        parent_identifier = parent_task.identifier() if parent_task else ""
        parent_title = parent_task.title() if parent_task else ""
        template_values = {
            'domain_name': domain.name,
            'domain_identifier': domain_identifier,
            'view_mode': view,
            'user_name': user.name,
            'user_identifier': user.identifier(),
            'messages': get_and_delete_messages(session),
            'task_title': task.title(),
            'task_description': task.description_body(),
            'task_assignee': task.assignee_description(),
            'task_identifier': task.identifier(),
            'task_has_subtasks': not task.atomic(),
            'task_can_assign_to_self': api.can_assign_to_self(task, user),
            'task_can_edit': api.can_edit_task(domain, task, user),
            'subtasks': _task_template_values(subtasks, user),
            'parent_identifier': parent_identifier,
            'parent_title': parent_title,
            'subtasks_heading': subtasks_heading,
            'no_subtasks_description': no_subtasks_description,
        }
        self.response.out.write(
            render_template('templates/taskdetail.html', template_values))
Exemple #5
0
 def get(self, domain_identifier, task_identifier):
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         self.error(404)
         return
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     user = api.get_user()
     domain = api.get_domain(domain_identifier)
     subtasks = api.get_all_subtasks(domain_identifier, task)
     parent_task = task.parent_task
     parent_identifier = parent_task.identifier() if parent_task else ""
     parent_title = parent_task.title() if parent_task else ""
     template_values = {
         'domain_name': domain.name,
         'domain_identifier': domain_identifier,
         'user_name': user.name,
         'user_identifier': user.identifier(),
         'messages': get_and_delete_messages(session),
         'task_title' : task.title(),
         'task_description': task.description_body(),
         'task_assignee': assignee_description(task),
         'task_identifier': task.identifier(),
         'task_can_assign_to_self': api.can_assign_to_self(task, user),
         'subtasks': _task_template_values(subtasks, user),
         'parent_identifier': parent_identifier,
         'parent_title': parent_title,
         }
     path = os.path.join(os.path.dirname(__file__),
                         'templates/taskdetail.html')
     self.response.out.write(template.render(path, template_values))
Exemple #6
0
    def get(self, domain_identifier, task_identifier):
        task = api.get_task(domain_identifier, task_identifier)
        user = api.get_and_validate_user(domain_identifier)
        view = self.request.get('view', 'all')
        if not task or not user:
            self.error(404)
            return
        session = Session(writer='cookie',
                          wsgiref_headers=self.response.headers)
        user = api.get_logged_in_user()
        domain = api.get_domain(domain_identifier)
        if view == 'yours':
            subtasks = api.get_assigned_tasks(domain_identifier,
                                              user,
                                              root_task=task,
                                              limit=200)
            subtasks_heading = "Subtasks of '%s' Assigned to You" % task.title()
            no_subtasks_description = "No subtasks are assigned to you."
        elif view == 'open':
            subtasks = api.get_open_tasks(domain_identifier,
                                          root_task=task,
                                          limit=200)
            subtasks_heading = "Open Subtasks of '%s'" % task.title()
            no_subtasks_description = "No open subtasks for this task."
        else:                   # view == 'all' or None
            view = 'all'
            user_id = user.identifier()
            subtasks = api.get_all_direct_subtasks(domain_identifier,
                                                   root_task=task,
                                                   limit=200,
                                                   user_identifier=user_id)
            subtasks_heading = "All Subtasks of '%s'" % task.title()
            no_subtasks_description = "No subtasks for this task."

        parent_task = task.parent_task
        parent_identifier = parent_task.identifier() if parent_task else ""
        parent_title = parent_task.title() if parent_task else ""
        template_values = {
            'domain_name': domain.name,
            'domain_identifier': domain_identifier,
            'view_mode': view,
            'user_name': user.name,
            'user_identifier': user.identifier(),
            'messages': get_and_delete_messages(session),
            'task_title' : task.title(),
            'task_description': task.description_body(),
            'task_assignee': task.assignee_description(),
            'task_identifier': task.identifier(),
            'task_has_subtasks': not task.atomic(),
            'task_can_assign_to_self': api.can_assign_to_self(task, user),
            'task_can_edit': api.can_edit_task(domain, task, user),
            'subtasks': _task_template_values(subtasks, user),
            'parent_identifier': parent_identifier,
            'parent_title': parent_title,
            'subtasks_heading': subtasks_heading,
            'no_subtasks_description': no_subtasks_description,
            }
        self.response.out.write(render_template('templates/taskdetail.html',
                                                template_values))
Exemple #7
0
def _task_template_values(tasks, user):
    """
    Returns a list of dictionaries containing the template values for
    each task.

    Args:
        tasks: A list of Task model instance
        user: A User model instance

    Returns a list of dictionaries for each task, in the same order.
    """
    return [{ 'title': task.title(),
              'levels': range(task.level),
              'completed': task.completed,
              'is_assigned': task.assignee_key() != None,
              'can_assign_to_self': api.can_assign_to_self(task, user),
              'assignee_description': assignee_description(task),
              'can_complete': api.can_complete_task(task, user),
              'num_subtasks': task.number_of_subtasks,
              'id': task.identifier() }
            for task in tasks]
Exemple #8
0
def _task_template_values(tasks, user):
    """
    Returns a list of dictionaries containing the template values for
    each task.

    Args:
        tasks: A list of Task model instance
        user: A User model instance

    Returns a list of dictionaries for each task, in the same order.
    """
    return [{
        'title': task.title(),
        'levels': range(task.level),
        'completed': task.completed,
        'is_assigned': task.assignee_key() != None,
        'can_assign_to_self': api.can_assign_to_self(task, user),
        'assignee_description': assignee_description(task),
        'can_complete': api.can_complete_task(task, user),
        'num_subtasks': task.number_of_subtasks,
        'id': task.identifier()
    } for task in tasks]
Exemple #9
0
    def get(self, *args):
        domain_identifier = args[0]
        user = api.get_and_validate_user(domain_identifier)
        if not user:
            self.abort(404)

        task_identifier = args[1] if len(args) > 1 else None
        if task_identifier:
            task = api.get_task(domain_identifier, task_identifier)
            if not task:
                self.abort(404)
        else:
            task = None         # No task specified
        view = self.request.get('view', 'all')
        session = Session(writer='cookie',
                          wsgiref_headers=self.response.headers)

        domain = api.get_domain(domain_identifier)
        if view == 'yours':
            subtasks = api.get_assigned_tasks(domain_identifier,
                                              user,
                                              root_task=task,
                                              limit=500)
            no_tasks_description = "No tasks are assigned to you."
        elif view == 'open':
            subtasks = api.get_open_tasks(domain_identifier,
                                          root_task=task,
                                          limit=500)
            no_tasks_description = "No open tasks for this task."
        else:                   # view == 'all' or None
            view = 'all'
            user_id = user.identifier()
            subtasks = api.get_all_direct_subtasks(domain_identifier,
                                                   root_task=task,
                                                   limit=500,
                                                   user_identifier=user_id)
            no_tasks_description = "No subtasks for this task."

        parent_task = task.parent_task if task else None
        parent_identifier = parent_task.identifier() if parent_task else ""
        parent_title = parent_task.title() if parent_task else ""

        if task:
            task_values = {
                'task_title' : task.title(),
                'task_description': task.description_body(),
                'task_assignee': task.assignee_description(),
                'task_creator': task.user_name(),
                'task_identifier': task.identifier(),
                'task_has_subtasks': not task.atomic(),
                'task_can_assign_to_self': api.can_assign_to_self(task, user),
                'task_can_edit': api.can_edit_task(domain, task, user),
                }
        else:
            task_values = {}
        base_url = '/d/' + domain_identifier
        if task:
            base_url += '/task/' + task_identifier
        template_values = {
            'domain_name': domain.name,
            'domain_identifier': domain_identifier,
            'view_mode': view,
            'user_name': user.name,
            'user_identifier': user.identifier(),
            'messages': get_and_delete_messages(session),
            'subtasks': _task_template_values(subtasks, user),
            'task_identifier': task_identifier, # None if no task is selected
            'parent_identifier': parent_identifier,
            'parent_title': parent_title,
            'no_tasks_description': no_tasks_description,
            'base_url': base_url,
            }
        template_values.update(task_values)
        self.render_template('taskdetail.html', **template_values)