예제 #1
0
파일: tags.py 프로젝트: jackfrued/code-1
 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
예제 #2
0
파일: tags.py 프로젝트: leeccong/code
 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
예제 #3
0
파일: issue.py 프로젝트: leeccong/code
 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()
예제 #4
0
 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()
예제 #5
0
파일: test_tag.py 프로젝트: leeccong/code
    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
예제 #6
0
    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
예제 #7
0
파일: issue.py 프로젝트: leeccong/code
 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)
예제 #8
0
 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)
예제 #9
0
파일: test_tag.py 프로젝트: leeccong/code
    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
예제 #10
0
    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