def _q_lookup(self, request, part): # TODO: check no '/' in tag name name = part target_type = self.target.tag_type target_id = self.target.id tag = TagName.get_by_name_and_target_id(name, target_type, target_id) if tag: return TagUI(self.target, tag) raise TraversalError
def _q_lookup(self, request, part): # TODO: check no '/' in tag name name = part target_type = self.target.tag_type target_id = self.target.id tag = TagName.get_by_name_and_target_id(name, target_type, target_id) if tag: return TagUI(self.target, tag) raise TraversalError
def remove_tag(self, tag, type, target_id): # check if tag exists tag_name = TagName.get_by_name_and_target_id(tag, type, target_id) if not tag_name: return # delete tag relationship if exists issue_tag = Tag.get_by_type_id_and_tag_id( type, self.issue_id, tag_name.id) if issue_tag: issue_tag.delete()
def remove_tag(self, tag, type, target_id): # check if tag exists tag_name = TagName.get_by_name_and_target_id(tag, type, target_id) if not tag_name: return # delete tag relationship if exists issue_tag = Tag.get_by_type_id_and_tag_id(type, self.issue_id, tag_name.id) if issue_tag: issue_tag.delete()
def test_delete(self): name = "tag" author = "test" target_type = 2 target_id = 3 newtag = TagName.add(name, author, target_type, target_id) newtag.delete() tag = TagName.get_by_name_and_target_id(name, target_type, target_id) assert tag is None tag = TagName.get_by_id(newtag.id) assert tag is None
def test_delete(self): name = "tag" author = "test" target_type = 2 target_id = 3 newtag = TagName.add(name, author, target_type, target_id) newtag.delete() tag = TagName.get_by_name_and_target_id(name, target_type, target_id) assert tag is None tag = TagName.get_by_id(newtag.id) assert tag is None
def add_tag(self, tag, type, target_id, author=None): author_id = author if author else self.creator_id # create tag if not exists tag_name = TagName.get_by_name_and_target_id(tag, type, target_id) if not tag_name: tag_name = TagName.add(tag, author_id, type, target_id) if not tag_name: return # add tag to issue if not already be added issue_tag = Tag.get_by_type_id_and_tag_id( type, self.issue_id, tag_name.id) if issue_tag: return Tag.add_to_issue( tag_name.id, type, self.issue_id, author_id, target_id)
def add_tag(self, tag, type, target_id, author=None): author_id = author if author else self.creator_id # create tag if not exists tag_name = TagName.get_by_name_and_target_id(tag, type, target_id) if not tag_name: tag_name = TagName.add(tag, author_id, type, target_id) if not tag_name: return # add tag to issue if not already be added issue_tag = Tag.get_by_type_id_and_tag_id(type, self.issue_id, tag_name.id) if issue_tag: return Tag.add_to_issue(tag_name.id, type, self.issue_id, author_id, target_id)
def test_get(self): name = "tag" author = "test" target_type = 2 target_id = 3 newtag = TagName.add(name, author, target_type, target_id) tag = TagName.get_by_name_and_target_id(name, target_type, target_id) assert tag.id == newtag.id assert tag.name == name assert tag.author_id == author assert tag.target_type == target_type assert tag.target_id == target_id tag = TagName.get_by_id(newtag.id) assert tag.id == newtag.id assert tag.name == name assert tag.author_id == author assert tag.target_type == target_type assert tag.target_id == target_id
def test_get(self): name = "tag" author = "test" target_type = 2 target_id = 3 newtag = TagName.add(name, author, target_type, target_id) tag = TagName.get_by_name_and_target_id(name, target_type, target_id) assert tag.id == newtag.id assert tag.name == name assert tag.author_id == author assert tag.target_type == target_type assert tag.target_id == target_id tag = TagName.get_by_id(newtag.id) assert tag.id == newtag.id assert tag.name == name assert tag.author_id == author assert tag.target_type == target_type assert tag.target_id == target_id