Beispiel #1
0
 def do_get(self, req, args):
     """
     Perform a get for the given ticket id, or all the tickets if 
     no id is provided.
     """
     ticket_id = args.get('id')
     command = None
     if ticket_id:
         command = TicketController.GetTicketCommand(self.env,
                                                     ticket=ticket_id)
         command.native = True
     else:
         # Now artificially limited to 20 to avoid explosion
         # TODO: support paging here
         command = TicketController.ListTicketsCommand(self.env, limit=20)
     result = TicketController(self.env).process_command(command)
     # AT: really needed?
     assert result != None
     if not isinstance(result, list):
         result = [result]
     # send the serialized list back
     ticket_module = AgiloTicketModule(self.env)
     return [
         ticket_module.ticket_as_json(req, ticket.id) for ticket in result
     ]
Beispiel #2
0
 def backlog_as_json(self, req, name, scope):
     from agilo.ticket.web_ui import AgiloTicketModule
     ticket_module = AgiloTicketModule(self.env)
     json_data = []
     backlog =  self._get_backlog(name, scope)
     for backlog_item in backlog:
         ticket_dict = ticket_module.ticket_as_json(req, backlog_item.ticket)
         json_data.append(ticket_dict)
     return json_data
Beispiel #3
0
 def backlog_as_json(self, req, name, scope):
     from agilo.ticket.web_ui import AgiloTicketModule
     ticket_module = AgiloTicketModule(self.env)
     json_data = []
     backlog = self._get_backlog(name, scope)
     for backlog_item in backlog:
         ticket_dict = ticket_module.ticket_as_json(req,
                                                    backlog_item.ticket)
         json_data.append(ticket_dict)
     return json_data
Beispiel #4
0
 def call_ticket_module(self, req, method_name):
     ticket_module = AgiloTicketModule(self.env)
     try:
         getattr(ticket_module, method_name)(req)
         return False
     except RequestDone:
         return True
Beispiel #5
0
 def do_get(self, req, args):
     """
     Perform a get for the given ticket id, or all the tickets if 
     no id is provided.
     """
     ticket_id = args.get('id')
     command = None
     if ticket_id:
         command = TicketController.GetTicketCommand(self.env, ticket=ticket_id)
         command.native = True
     else:
         # Now artificially limited to 20 to avoid explosion
         # TODO: support paging here
         command = TicketController.ListTicketsCommand(self.env, limit=20)
     result = TicketController(self.env).process_command(command)
     # AT: really needed?
     assert result != None
     if not isinstance(result, list):
         result = [result]
     # send the serialized list back
     ticket_module = AgiloTicketModule(self.env)
     return [ticket_module.ticket_as_json(req, ticket.id) for ticket in result]
Beispiel #6
0
    def test_create_related_tickets(self):
        """
        Test the list of possible related ticket to create given a type and
        a login permissions.
        """
        req = self.teh.mock_request(name_product_owner)
        story = self.teh.create_ticket(Type.USER_STORY,
                                       props={
                                           Key.OWNER: name_product_owner,
                                           Key.STORY_PRIORITY: 'Mandatory'
                                       })
        # Build a fake data dictionary containing the ticket
        data = {Key.TICKET: story}
        AgiloTicketModule(self.env)._prepare_create_referenced(req, data)
        # Now check that being a Product Owner there is no link to create a task
        self.assert_false(Type.TASK in data['create_referenced'])

        # Now login as a team member and the link should be there
        req.perm = PermissionCache(self.env, name_team_member)
        req.authname = name_team_member
        AgiloTicketModule(self.env)._prepare_create_referenced(req, data)
        allowed_links = data['create_referenced']
        allowed_destination_types = [l.dest_type for l in allowed_links]
        self.assert_true(Type.TASK in allowed_destination_types)
Beispiel #7
0
 def test_can_edit_ticket_from_ticket_module(self):
     """
     Test the can_edit_ticket method directly on the TicketModule
     using a Mocked Request Object
     """
     task = self.teh.create_ticket(Type.TASK,
                                   props={Key.OWNER: name_team_member})
     req = self.teh.mock_request(name_team_member)
     self.assert_true(
         AgiloTicketModule(self.env).can_edit_ticket(req, task),
         "No permission to edit: %s as: %s!!!" % (task, req.authname))
     # Now make sure that the product owner can't edit task
     req = self.teh.mock_request(name_product_owner)
     self.assert_false(
         AgiloTicketModule(self.env).can_edit_ticket(req, task),
         "Permission to edit: %s as: %s!!!" % (task, req.authname))
     # Now create a Story, both role should be able to edit it
     story = self.teh.create_ticket(Type.USER_STORY,
                                    props={
                                        Key.OWNER: name_product_owner,
                                        Key.STORY_PRIORITY: 'Mandatory'
                                    })
     self.assert_true(
         AgiloTicketModule(self.env).can_edit_ticket(req, story),
         "No permission to edit: %s as: %s!!!" % (story, req.authname))
     # Now the team member too
     req = self.teh.mock_request(name_team_member)
     self.assert_false(
         AgiloTicketModule(self.env).can_edit_ticket(req, story))
     # Now a Requirement that should only be touched by the Product Owner
     requirement = self.teh.create_ticket(Type.REQUIREMENT,
                                          props={
                                              Key.OWNER: name_product_owner,
                                              Key.BUSINESS_VALUE: '2000'
                                          })
     self.assert_false(
         AgiloTicketModule(self.env).can_edit_ticket(req, requirement),
         "Permission to edit: %s as: %s!!!" % (requirement, req.authname))
     # Now the team member too
     req = self.teh.mock_request(name_product_owner)
     self.assert_true(
         AgiloTicketModule(self.env).can_edit_ticket(req, requirement),
         "No permission to edit: %s as: %s!!!" %
         (requirement, req.authname))
Beispiel #8
0
 def get_ticket_as_json(self, req, ticket_id):
     # trac's TicketModule will instantiate a ticket directly which
     # circumvents all our caches so we need to ignore the caches
     # as well...
     ticket = self._ticket_without_cache(ticket_id)
     return AgiloTicketModule(self.env).ticket_as_json(req, ticket)
Beispiel #9
0
 def field_for_template(self, field_name):
     template, data, content_type = AgiloTicketModule(
         self.env).process_request(self.req)
     fields = data['fields']
     return self.field_with_name(fields, field_name)