Exemplo n.º 1
0
 def txn():
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         logging.error("Task '%s/%s' does not exist", domain_identifier,
                       task_identifier)
         return None
     parent_task = api.get_task(domain_identifier,
                                task.parent_task_identifier())
     if parent_task:
         parent_index = TaskIndex.get_by_key_name(
             parent_task.identifier(), parent=parent_task.key())
         if not parent_index:
             logging.error("Missing index for parent task '%s/%s'",
                           domain_identifier, parent_identifier)
             self.error(400)  # Retry later
             return None
         hierarchy = list(parent_index.hierarchy)
         hierarchy.append(parent_task.identifier())
         level = parent_task.derived_level + 1
     else:  # root task
         hierarchy = []
         level = 0
     index = TaskIndex.get_by_key_name(task_identifier, parent=task)
     if not index:
         index = TaskIndex(parent=task, key_name=task_identifier)
     index.hierarchy = hierarchy
     index.put()
     task.derived_level = level
     task.put()
     return task
Exemplo n.º 2
0
 def txn():
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         logging.error("Task '%s/%s' does not exist",
                       domain_identifier, task_identifier)
         return None
     parent_task = api.get_task(domain_identifier,
                                task.parent_task_identifier())
     if parent_task:
         parent_index = TaskIndex.get_by_key_name(
             parent_task.identifier(),
             parent=parent_task.key())
         if not parent_index:
             logging.error("Missing index for parent task '%s/%s'",
                           domain_identifier, parent_identifier)
             self.error(400) # Retry later
             return None
         hierarchy = list(parent_index.hierarchy)
         hierarchy.append(parent_task.identifier())
         level = parent_task.derived_level + 1
     else:               # root task
         hierarchy = []
         level = 0
     index = TaskIndex.get_by_key_name(task_identifier, parent=task)
     if not index:
         index = TaskIndex(parent=task, key_name=task_identifier)
     index.hierarchy = hierarchy
     index.put()
     task.derived_level = level
     task.put()
     return task
Exemplo n.º 3
0
Arquivo: main.py Projeto: edrijver/sps
 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))
Exemplo n.º 4
0
    def post(self):
        domain_identifier = self.request.get('domain')
        task_identifier = self.request.get('task')
        task = api.get_task(domain_identifier, task_identifier)
        if not task:
            logging.error("No task '%s/%s'", domain_identifier, task_identifier)
            return
        index = AssigneeIndex.get_by_key_name(task.identifier(),
                                              parent=task)
        if not index:
            logging.error("No assignee index for task '%s'", task)
            return

        assignees = index.assignees
        description = ""
        if len(assignees) == 1:
            user = api.get_user_from_identifier(assignees[0])
            description = user.name
        elif len(assignees) == 2:
            user0 = api.get_user_from_identifier(assignees[0])
            user1 = api.get_user_from_identifier(assignees[1])
            description = "%s, %s" % (user0.name, user1.name)
        elif len(assignees) > 2:
            user = api.get_user_from_identifier(assignees[0])
            description = "%s and %d others" % (user, len(assignees) - 1)
        task.baked_assignee_description = description
        task.put()
Exemplo n.º 5
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))
Exemplo n.º 6
0
    def post(self):
        domain_identifier = self.request.get('domain')
        task_identifier = self.request.get('task')
        task = api.get_task(domain_identifier, task_identifier)
        if not task:
            logging.error("No task '%s/%s'", domain_identifier,
                          task_identifier)
            return
        index = AssigneeIndex.get_by_key_name(task.identifier(), parent=task)
        if not index:
            logging.error("No assignee index for task '%s'", task)
            return

        assignees = index.assignees
        description = ""
        if len(assignees) == 1:
            user = api.get_user_from_identifier(assignees[0])
            description = user.name
        elif len(assignees) == 2:
            user0 = api.get_user_from_identifier(assignees[0])
            user1 = api.get_user_from_identifier(assignees[1])
            description = "%s, %s" % (user0.name, user1.name)
        elif len(assignees) > 2:
            user = api.get_user_from_identifier(assignees[0])
            description = "%s and %d others" % (user, len(assignees) - 1)
        task.baked_assignee_description = description
        task.put()
Exemplo n.º 7
0
Arquivo: main.py Projeto: edrijver/sps
 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))
Exemplo n.º 8
0
 def txn():
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         logging.error("Task '%s/%s' does not exist", domain_identifier, task_identifier)
         return
     index = TaskIndex.get_by_key_name(task_identifier, parent=task)
     if not index:
         index = TaskIndex(parent=task, key_name=task_identifier)
     # Get all subtasks. The ancestor queries are strongly
     # consistent, so when propagating upwards through the
     # hierarchy the changes are reflected.
     subtasks = list(Task.all().ancestor(domain_key).filter("parent_task =", task.key()))
     if not subtasks:  # atomic task
         task.derived_completed = task.completed
         task.derived_size = 1
         task.derived_atomic_task_count = 1
         task.derived_has_open_tasks = task.open()
         assignee_identifier = task.assignee_identifier()
         if assignee_identifier:
             index.assignees = [assignee_identifier]
             if not DEV_SERVER:
                 # Uses a multi entity group transaction to get the name
                 # of the assignee. This is cached in the record for
                 # quick descriptions.
                 assignee = api.get_user(assignee_identifier)
                 name = assignee.name if assignee else "<Missing>"
             else:
                 name = "temp"
             task.derived_assignees[task.assignee_identifier()] = {
                 "id": task.assignee_identifier(),
                 "name": name,
                 "completed": int(task.is_completed()),
                 "all": 1,
             }
     else:  # composite task
         task.derived_completed = all(t.is_completed() for t in subtasks)
         task.derived_size = 1 + sum(t.derived_size for t in subtasks)
         task.derived_atomic_task_count = sum(t.atomic_task_count() for t in subtasks)
         task.derived_has_open_tasks = any(t.has_open_tasks() for t in subtasks)
         # Compute derived assignees, and sum the total of all
         # their assigned and completed subtasks.
         assignees = {}
         for subtask in subtasks:
             subtask_assignees = subtask.derived_assignees
             for id, record in subtask_assignees.iteritems():
                 if not id in assignees:
                     assignees[id] = {"id": id, "name": record["name"], "completed": 0, "all": 0}
                 assignees[id]["completed"] += record["completed"]
                 assignees[id]["all"] += record["all"]
         task.derived_assignees = assignees
         index.assignees = list(assignees.iterkeys())
     task.put()
     index.completed = task.is_completed()
     index.has_open_tasks = task.has_open_tasks()
     index.atomic = task.atomic()
     index.put()
     # Propagate further upwards
     if task.parent_task_identifier():
         UpdateTaskCompletion.enqueue(domain_identifier, task.parent_task_identifier(), transactional=True)
Exemplo n.º 9
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))
Exemplo n.º 10
0
 def txn():
     index = AssigneeIndex.get_by_key_name(task.identifier(), parent=task)
     if index:
         return
     instance = api.get_task(task.domain_identifier(), task.identifier())
     if instance.assignee_key():
         workers.UpdateAssigneeIndex.queue_worker(
             instance, add_assignee=instance.assignee_identifier())
Exemplo n.º 11
0
Arquivo: repl.py Projeto: lrn-guru/lrn
def check_progress(cmd):
    task = api.get_task()
    test = task['test']
    test_dir = api.get_tests_dir()

    command = "python {}/{}.py {}".format(test_dir, test, cmd)
    status = call(command.split())
    return status
Exemplo n.º 12
0
 def txn():
     index = AssigneeIndex.get_by_key_name(task.identifier(),
                                           parent=task)
     if index:
         return
     instance = api.get_task(task.domain_identifier(),
                             task.identifier())
     if instance.assignee_key():
         workers.UpdateAssigneeIndex.queue_worker(
             instance,
             add_assignee=instance.assignee_identifier())
Exemplo n.º 13
0
    def get(self):
        try:
            domain_identifier = self.request.get('domain')
            task_identifier = self.request.get('task')
            view = self.request.get('view')
            level = int(self.request.get('level', 0))
            show_radio_buttons = bool(self.request.get('radio', False))
        except (ValueError, TypeError):
            self.error(400)
            return
        user = api.get_and_validate_user(domain_identifier)
        if not user:
            self.error(403)
            return

        domain = api.get_domain(domain_identifier)
        task = api.get_task(domain_identifier, task_identifier)
        if view == 'yours':
            tasks = api.get_assigned_tasks(domain_identifier,
                                           user,
                                           root_task=task,
                                           limit=200)
        elif view == 'open':
            tasks = api.get_open_tasks(domain_identifier,
                                       root_task=task,
                                       limit=200)
        else:  # view == 'all' or None
            view = 'all'
            user_id = user.identifier()
            tasks = api.get_all_direct_subtasks(domain_identifier,
                                                root_task=task,
                                                limit=200,
                                                user_identifier=user_id)
        template_values = {
            'domain_name': domain.name,
            'domain_identifier': domain_identifier,
            'user_name': user.name,
            'user_identifier': user.identifier(),
            'tasks': _task_template_values(tasks, user, level=level + 1),
            'view_mode': view,
            'show_radio_buttons': show_radio_buttons,
        }
        self.response.out.write(
            render_template('templates/get-subtasks.html', template_values))
Exemplo n.º 14
0
    def get(self):
        try:
            domain_identifier = self.request.get('domain')
            task_identifier = self.request.get('task')
            view = self.request.get('view')
            level = int(self.request.get('level', 0))
            show_radio_buttons = bool(self.request.get('radio', False))
        except (ValueError,TypeError):
            self.error(400)
            return
        user = api.get_and_validate_user(domain_identifier)
        if not user:
            self.error(403)
            return

        domain = api.get_domain(domain_identifier)
        task = api.get_task(domain_identifier, task_identifier)
        if view == 'yours':
            tasks = api.get_assigned_tasks(domain_identifier,
                                           user,
                                           root_task=task,
                                           limit=200)
        elif view == 'open':
            tasks = api.get_open_tasks(domain_identifier,
                                       root_task=task,
                                       limit=200)
        else:                   # view == 'all' or None
            view = 'all'
            user_id = user.identifier()
            tasks = api.get_all_direct_subtasks(domain_identifier,
                                                root_task=task,
                                                limit=200,
                                                user_identifier=user_id)
        template_values = {
            'domain_name': domain.name,
            'domain_identifier': domain_identifier,
            'user_name': user.name,
            'user_identifier': user.identifier(),
            'tasks': _task_template_values(tasks, user, level=level+1),
            'view_mode': view,
            'show_radio_buttons': show_radio_buttons,
            }
        self.response.out.write(render_template('templates/get-subtasks.html',
                                                template_values))
Exemplo n.º 15
0
        def txn():
            task = api.get_task(domain_identifier, task_identifier)
            description = "%s/%s" % (domain_identifier, task_identifier)
            if not task:
                logging.error("Task '%s/%s' does not exist", description)
                return None, False

            index = _get_index(task)
            if index.sequence < sequence: # Not our time yet, retry later
                self.error(500)
                return task, False
            if index.sequence > sequence: # passed us, must be a duplicate
                return task, False

            reference_counts = json.loads(index.reference_counts)
            update_reference_count(reference_counts)
            propagate_add_assignee = add_assignee
            propagate_remove_assignee = remove_assignee
            if reference_counts.get(add_assignee, None) == 1:
                # New assignee entry
                index.assignees.append(add_assignee)
            else:
                propagate_add_assignee = None # do not propagate
            if reference_counts.get(remove_assignee, None) == 0:
                # Assignee is completely gone
                del reference_counts[remove_assignee]
                index.assignees.remove(remove_assignee)
            else:
                propagate_remove_assignee = None # do not propagate

            index.assignee_count = len(index.assignees)
            index.reference_counts = json.dumps(reference_counts)
            index.sequence = index.sequence + 1 # move forward
            index.put()
            parent_task = task.parent_task
            if parent_task:
                UpdateAssigneeIndex.queue_worker(parent_task,
                                                 propagate_add_assignee,
                                                 propagate_remove_assignee)
            return task, (propagate_add_assignee or propagate_remove_assignee)
Exemplo n.º 16
0
        def txn():
            # Returns (task, changed) tuple, where changed is set if
            # the task index was updated.
            task = api.get_task(domain_identifier, task_identifier)
            if not task:
                logging.error("Task '%s/%s' does not exist",
                              domain_identifier, task_identifier)
                return None, False
            index = TaskIndex.get_by_key_name(task_identifier, parent=task)
            new_index = False
            if not index:
                index = TaskIndex(parent=task,
                                  key_name=task_identifier,
                                  hierarchy=[],
                                  level=0)
                new_index = True
            parent_identifier = task.parent_task_identifier()
            parent_hierarchy = []
            if parent_identifier:
                parent_key = task.parent_task_key()
                parent_index = TaskIndex.get_by_key_name(parent_identifier,
                                                         parent=parent_key)
                if not parent_index:
                    logging.error("Missing index for parent task '%s/%s'",
                                  domain_identifier, parent_identifier)
                    self.error(500) # Retry
                    return None, False
                parent_hierarchy = parent_index.hierarchy

            hierarchy = parent_hierarchy
            if parent_identifier:
                hierarchy.append(parent_identifier)
            if (force_update
                or new_index
                or set(index.hierarchy) ^ set(hierarchy)):
                index.hierarchy = hierarchy
                index.level = len(hierarchy)
                index.put()
                return task, True
            return task, False
Exemplo n.º 17
0
        def txn():
            task = api.get_task(domain_identifier, task_identifier)
            description = "%s/%s" % (domain_identifier, task_identifier)
            if not task:
                logging.error("Task '%s/%s' does not exist", description)
                return None, False

            index = _get_index(task)
            if index.sequence < sequence:  # Not our time yet, retry later
                self.error(500)
                return task, False
            if index.sequence > sequence:  # passed us, must be a duplicate
                return task, False

            reference_counts = json.loads(index.reference_counts)
            update_reference_count(reference_counts)
            propagate_add_assignee = add_assignee
            propagate_remove_assignee = remove_assignee
            if reference_counts.get(add_assignee, None) == 1:
                # New assignee entry
                index.assignees.append(add_assignee)
            else:
                propagate_add_assignee = None  # do not propagate
            if reference_counts.get(remove_assignee, None) == 0:
                # Assignee is completely gone
                del reference_counts[remove_assignee]
                index.assignees.remove(remove_assignee)
            else:
                propagate_remove_assignee = None  # do not propagate

            index.assignee_count = len(index.assignees)
            index.reference_counts = json.dumps(reference_counts)
            index.sequence = index.sequence + 1  # move forward
            index.put()
            parent_task = task.parent_task
            if parent_task:
                UpdateAssigneeIndex.queue_worker(parent_task,
                                                 propagate_add_assignee,
                                                 propagate_remove_assignee)
            return task, (propagate_add_assignee or propagate_remove_assignee)
Exemplo n.º 18
0
        def txn():
            # Returns (task, changed) tuple, where changed is set if
            # the task index was updated.
            task = api.get_task(domain_identifier, task_identifier)
            if not task:
                logging.error("Task '%s/%s' does not exist", domain_identifier,
                              task_identifier)
                return None, False
            index = TaskIndex.get_by_key_name(task_identifier, parent=task)
            new_index = False
            if not index:
                index = TaskIndex(parent=task,
                                  key_name=task_identifier,
                                  hierarchy=[],
                                  level=0)
                new_index = True
            parent_identifier = task.parent_task_identifier()
            parent_hierarchy = []
            if parent_identifier:
                parent_key = task.parent_task_key()
                parent_index = TaskIndex.get_by_key_name(parent_identifier,
                                                         parent=parent_key)
                if not parent_index:
                    logging.error("Missing index for parent task '%s/%s'",
                                  domain_identifier, parent_identifier)
                    self.error(500)  # Retry
                    return None, False
                parent_hierarchy = parent_index.hierarchy

            hierarchy = parent_hierarchy
            if parent_identifier:
                hierarchy.append(parent_identifier)
            if (force_update or new_index
                    or set(index.hierarchy) ^ set(hierarchy)):
                index.hierarchy = hierarchy
                index.level = len(hierarchy)
                index.put()
                return task, True
            return task, False
Exemplo n.º 19
0
    def get(self, domain_identifier, task_identifier):
        task = api.get_task(domain_identifier, task_identifier)
        user = api.get_and_validate_user(domain_identifier)
        if not task or not user:
            self.error(404)
            return

        session = Session(writer='cookie',
                          wsgiref_headers=self.response.headers)
        domain = api.get_domain(domain_identifier)
        if not api.can_edit_task(domain, task, user):
            self.error(403)
            return

        # Tasks that are used to create the navigation tasks for
        # moving the task.
        user_id = user.identifier()
        tasks = api.get_all_direct_subtasks(domain_identifier,
                                            root_task=None,
                                            limit=200,
                                            user_identifier=user_id)

        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,
            'task_identifier': task.identifier(),
            'tasks': _task_template_values(tasks, user),
            'show_radio_buttons': True,
            'view_mode': 'all',
        }
        self.response.out.write(
            render_template('templates/edittask.html', template_values))
Exemplo n.º 20
0
    def get(self, domain_identifier, task_identifier):
        task = api.get_task(domain_identifier, task_identifier)
        user = api.get_and_validate_user(domain_identifier)
        if not task or not user:
            self.error(404)
            return

        session = Session(writer='cookie',
                          wsgiref_headers=self.response.headers)
        domain = api.get_domain(domain_identifier)
        if not api.can_edit_task(domain, task, user):
            self.error(403)
            return

        # Tasks that are used to create the navigation tasks for
        # moving the task.
        user_id = user.identifier()
        tasks = api.get_all_direct_subtasks(domain_identifier,
                                            root_task=None,
                                            limit=200,
                                            user_identifier=user_id)

        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,
            'task_identifier': task.identifier(),
            'tasks': _task_template_values(tasks, user),
            'show_radio_buttons': True,
            'view_mode': 'all',
            }
        self.response.out.write(render_template('templates/edittask.html',
                                                template_values))
Exemplo n.º 21
0
Arquivo: main.py Projeto: troberti/sps
    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)
Exemplo n.º 22
0
 def txn():
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         logging.error("Task '%s/%s' does not exist", domain_identifier,
                       task_identifier)
         return
     index = TaskIndex.get_by_key_name(task_identifier, parent=task)
     if not index:
         index = TaskIndex(parent=task, key_name=task_identifier)
     # Get all subtasks. The ancestor queries are strongly
     # consistent, so when propagating upwards through the
     # hierarchy the changes are reflected.
     subtasks = list(Task.all().ancestor(domain_key).filter(
         'parent_task =', task.key()))
     if not subtasks:  # atomic task
         task.derived_completed = task.completed
         task.derived_size = 1
         task.derived_atomic_task_count = 1
         task.derived_has_open_tasks = task.open()
         assignee_identifier = task.assignee_identifier()
         if assignee_identifier:
             index.assignees = [assignee_identifier]
             if not DEV_SERVER:
                 # Uses a multi entity group transaction to get the name
                 # of the assignee. This is cached in the record for
                 # quick descriptions.
                 assignee = api.get_user(assignee_identifier)
                 name = assignee.name if assignee else '<Missing>'
             else:
                 name = 'temp'
             task.derived_assignees[task.assignee_identifier()] = {
                 'id': task.assignee_identifier(),
                 'name': name,
                 'completed': int(task.is_completed()),
                 'all': 1
             }
     else:  # composite task
         task.derived_completed = all(t.is_completed()
                                      for t in subtasks)
         task.derived_size = 1 + sum(t.derived_size for t in subtasks)
         task.derived_atomic_task_count = sum(t.atomic_task_count()
                                              for t in subtasks)
         task.derived_has_open_tasks = any(t.has_open_tasks()
                                           for t in subtasks)
         # Compute derived assignees, and sum the total of all
         # their assigned and completed subtasks.
         assignees = {}
         for subtask in subtasks:
             subtask_assignees = subtask.derived_assignees
             for id, record in subtask_assignees.iteritems():
                 if not id in assignees:
                     assignees[id] = {
                         'id': id,
                         'name': record['name'],
                         'completed': 0,
                         'all': 0
                     }
                 assignees[id]['completed'] += record['completed']
                 assignees[id]['all'] += record['all']
         task.derived_assignees = assignees
         index.assignees = list(assignees.iterkeys())
     task.put()
     index.completed = task.is_completed()
     index.has_open_tasks = task.has_open_tasks()
     index.atomic = task.atomic()
     index.put()
     # Propagate further upwards
     if task.parent_task_identifier():
         UpdateTaskCompletion.enqueue(domain_identifier,
                                      task.parent_task_identifier(),
                                      transactional=True)
Exemplo n.º 23
0
Arquivo: lrn.py Projeto: lrn-guru/lrn
def hint():
    task_json = api.get_task()
    print(task_json['hint'])
Exemplo n.º 24
0
Arquivo: lrn.py Projeto: lrn-guru/lrn
def run_tests():
    # get the current branch
    task = api.get_task()
    test = task['test']

    print(test)
Exemplo n.º 25
0
Arquivo: lrn.py Projeto: lrn-guru/lrn
def show_task():
    """ Informs the user of their current task."""
    task = api.get_task()
    l(task['instruction'] + '\n', 'cyan')