Example #1
0
 def test_parses_negative_tag_list(self):
     self.assertEqual(
         parse_tag_list("!a !b !c"),
         [("@a", False), ("@b", False), ("@c", False)],
     )
     self.assertEqual(
         parse_tag_list("!@a !@b !@c"),
         [("@a", False), ("@b", False), ("@c", False)],
     )
Example #2
0
 def test_parses_postivie_tag_list(self):
     self.assertEqual(
         parse_tag_list("a b c"),
         [("@a", True), ("@b", True), ("@c", True)],
     )
     self.assertEqual(
         parse_tag_list("@a @b @c"),
         [("@a", True), ("@b", True), ("@c", True)],
     )
Example #3
0
 def test_parses_mixed_tags(self):
     self.assertEqual(
         parse_tag_list("add !remove"),
         [("@add", True), ("@remove", False)],
     )
     self.assertEqual(
         parse_tag_list("!@remove @add"),
         [("@remove", False), ("@add", True)],
     )
Example #4
0
    def on_confirm(self, widget):
        """ Apply changes """
        tags = parse_tag_list(self.tag_entry.get_text())

        # If the checkbox is checked, find all subtasks
        if self.apply_to_subtasks.get_active():
            for task_id in self.tasks:
                task = self.req.get_task(task_id)
                # FIXME: Python not reinitialize the default value of its
                # parameter therefore it must be done manually. This function
                # should be refractored # as far it is marked as depricated
                for subtask in task.get_self_and_all_subtasks(tasks=[]):
                    subtask_id = subtask.get_id()
                    if subtask_id not in self.tasks:
                        self.tasks.append(subtask_id)

        for task_id in self.tasks:
            task = self.req.get_task(task_id)
            for tag, is_positive in tags:
                if is_positive:
                    task.add_tag(tag)
                else:
                    task.remove_tag(tag)
            task.sync()

        # Rember the last actions
        self.last_tag_entry = self.tag_entry.get_text()
        self.last_apply_to_subtasks = self.apply_to_subtasks.get_active()
Example #5
0
    def on_confirm(self, widget):
        """ Apply changes """
        tags = parse_tag_list(self.tag_entry.get_text())

        # If the checkbox is checked, find all subtasks
        if self.apply_to_subtasks.get_active():
            for task_id in self.tasks:
                task = self.req.get_task(task_id)
                # FIXME: Python not reinitialize the default value of its
                # parameter therefore it must be done manually. This function
                # should be refractored # as far it is marked as depricated
                for subtask in task.get_self_and_all_subtasks(tasks=[]):
                    subtask_id = subtask.get_id()
                    if subtask_id not in self.tasks:
                        self.tasks.append(subtask_id)

        for task_id in self.tasks:
            task = self.req.get_task(task_id)
            for tag, is_positive in tags:
                if is_positive:
                    task.add_tag(tag)
                else:
                    task.remove_tag(tag)
            task.sync()

        # Rember the last actions
        self.last_tag_entry = self.tag_entry.get_text()
        self.last_apply_to_subtasks = self.apply_to_subtasks.get_active()
Example #6
0
 def test_parses_negative_single_tag(self):
     self.assertEqual(parse_tag_list("!tag"), [("@tag", False)])
     self.assertEqual(parse_tag_list("!@tag"), [("@tag", False)])
Example #7
0
 def test_parses_positive_single_tag(self):
     self.assertEqual(parse_tag_list("tag"), [("@tag", True)])
     self.assertEqual(parse_tag_list("@tag"), [("@tag", True)])