コード例 #1
0
ファイル: main.py プロジェクト: wadevries/sps
    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))
コード例 #2
0
ファイル: main.py プロジェクト: wadevries/sps
    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))
コード例 #3
0
ファイル: main.py プロジェクト: troberti/sps
 def get(self):
     user = api.get_logged_in_user()
     domains = api.get_all_domains_for_user(user)
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     template_values = {
         'username' : user.name,
         'domains' : [{ 'identifier': domain.identifier(),
                        'name': domain.name }
                      for domain in domains],
         'messages': get_and_delete_messages(session),
         }
     self.render_template('landing.html', **template_values)
コード例 #4
0
ファイル: main.py プロジェクト: wadevries/sps
 def get(self):
     user = api.get_logged_in_user()
     domains = api.get_all_domains_for_user(user)
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     template_values = {
         'username' : user.name,
         'domains' : [{ 'identifier': domain.identifier(),
                        'name': domain.name }
                      for domain in domains],
         'messages': get_and_delete_messages(session),
         }
     path = os.path.join(os.path.dirname(__file__),
                     'templates/landing.html')
     self.response.out.write(template.render(path, template_values))
コード例 #5
0
ファイル: main.py プロジェクト: troberti/sps
 def post(self):
     try:
         domain_id = self.request.get('domain')
         title = self.request.get('title')
     except (TypeError, ValueError):
         self.error(403)
         return
     user = api.get_logged_in_user()
     domain = api.create_domain(domain_id, title, user)
     if not domain:
         self.response.out.write("Could not create domain")
         return
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     add_message(session, "Created domain '%s'" % domain.key().name())
     self.redirect('/d/%s/' % domain.key().name())
コード例 #6
0
ファイル: main.py プロジェクト: wadevries/sps
 def post(self):
     try:
         domain_id = self.request.get('domain')
         title = self.request.get('title')
     except (TypeError, ValueError):
         self.error(403)
         return
     user = api.get_logged_in_user()
     domain = api.create_domain(domain_id, title, user)
     if not domain:
         self.response.out.write("Could not create domain")
         return
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     add_message(session, "Created domain '%s'" % domain.key().name())
     self.redirect('/d/%s/' % domain.key().name())
コード例 #7
0
ファイル: main.py プロジェクト: wadevries/sps
 def get(self):
     user = api.get_logged_in_user()
     domains = api.get_all_domains_for_user(user)
     session = Session(writer='cookie',
                       wsgiref_headers=self.response.headers)
     template_values = {
         'username':
         user.name,
         'domains': [{
             'identifier': domain.identifier(),
             'name': domain.name
         } for domain in domains],
         'messages':
         get_and_delete_messages(session),
     }
     path = os.path.join(os.path.dirname(__file__),
                         'templates/landing.html')
     self.response.out.write(template.render(path, template_values))