コード例 #1
0
ファイル: osfstorage.py プロジェクト: 545zhou/osf.io
 def remove_tag(self, tag, auth, save=True, log=True):
     from website.models import Tag, NodeLog  # Prevent import error
     tag = Tag.load(tag)
     if tag and tag in self.tags and not self.node.is_registration:
         self.tags.remove(tag)
         if log:
             self.add_tag_log(NodeLog.FILE_TAG_REMOVED, tag._id, auth)
         if save:
             self.save()
         return True
     return False
コード例 #2
0
ファイル: osfstorage.py プロジェクト: wearpants/osf.io
 def remove_tag(self, tag, auth, save=True, log=True):
     from website.models import Tag, NodeLog  # Prevent import error
     tag = Tag.load(tag)
     if tag and tag in self.tags and not self.node.is_registration:
         self.tags.remove(tag)
         if log:
             self.add_tag_log(NodeLog.FILE_TAG_REMOVED, tag._id, auth)
         if save:
             self.save()
         return True
     return False
コード例 #3
0
ファイル: osfstorage.py プロジェクト: monikagrabowska/osf.io
 def add_tag(self, tag, auth, save=True, log=True):
     from website.models import Tag, NodeLog  # Prevent import error
     if tag not in self.tags and not self.node.is_registration:
         new_tag = Tag.load(tag)
         if not new_tag:
             new_tag = Tag(_id=tag)
         new_tag.save()
         self.tags.append(new_tag)
         if log:
             self.add_tag_log(NodeLog.FILE_TAG_ADDED, tag, auth)
         if save:
             self.save()
         return True
     return False
コード例 #4
0
ファイル: verify_nodes.py プロジェクト: wearpants/osf_models
def verify_tags(node, modm_node):
    modm_tag_keys = [x for x in sorted(set(modm_node.tags._to_primary_keys())) if MODMTag.load(x)]
    django_tag_keys = sorted(set(node.tags.filter(
        system=False).values_list('_id',
                                  flat=True)))
    modm_system_tag_keys = sorted(set(modm_node.system_tags))
    django_system_tag_keys = sorted(set(
        node.system_tags.values_list('_id',
                                     flat=True)))

    assert modm_tag_keys == django_tag_keys, 'Modm tags {} don\'t match django tags {} in node {}:{}'.format(
        modm_tag_keys, django_tag_keys, modm_node._id, node._guid.guid)
    assert modm_system_tag_keys == django_system_tag_keys, 'Modm system tag keys {} don\'t match django system tags {}'.format(
        modm_system_tag_keys, django_system_tag_keys)
コード例 #5
0
ファイル: osfstorage.py プロジェクト: ccfair/osf.io
 def add_tag(self, tag, auth, save=True, log=True):
     from website.models import Tag, NodeLog  # Prevent import error
     if tag not in self.tags and not self.node.is_registration:
         new_tag = Tag.load(tag)
         if not new_tag:
             new_tag = Tag(_id=tag)
         new_tag.save()
         self.tags.append(new_tag)
         if log:
             self.add_tag_log(NodeLog.FILE_TAG_ADDED, tag, auth)
         if save:
             self.save()
         return True
     return False
コード例 #6
0
ファイル: verify_nodes.py プロジェクト: wearpants/osf_models
def verify_tags(node, modm_node):
    modm_tag_keys = [
        x for x in sorted(set(modm_node.tags._to_primary_keys()))
        if MODMTag.load(x)
    ]
    django_tag_keys = sorted(
        set(node.tags.filter(system=False).values_list('_id', flat=True)))
    modm_system_tag_keys = sorted(set(modm_node.system_tags))
    django_system_tag_keys = sorted(
        set(node.system_tags.values_list('_id', flat=True)))

    assert modm_tag_keys == django_tag_keys, 'Modm tags {} don\'t match django tags {} in node {}:{}'.format(
        modm_tag_keys, django_tag_keys, modm_node._id, node._guid.guid)
    assert modm_system_tag_keys == django_system_tag_keys, 'Modm system tag keys {} don\'t match django system tags {}'.format(
        modm_system_tag_keys, django_system_tag_keys)
コード例 #7
0
ファイル: osfstorage.py プロジェクト: monikagrabowska/osf.io
    def remove_tag(self, tag, auth, save=True, log=True):
        from website.models import Tag, NodeLog  # Prevent import error
        if self.node.is_registration:
            # Can't perform edits on a registration
            raise NodeStateError

        tag = Tag.load(tag)
        if not tag:
            raise InvalidTagError
        elif tag not in self.tags:
            raise TagNotFoundError
        else:
            self.tags.remove(tag)
            if log:
                self.add_tag_log(NodeLog.FILE_TAG_REMOVED, tag._id, auth)
            if save:
                self.save()
            return True
コード例 #8
0
ファイル: osfstorage.py プロジェクト: ccfair/osf.io
    def remove_tag(self, tag, auth, save=True, log=True):
        from website.models import Tag, NodeLog  # Prevent import error
        if self.node.is_registration:
            # Can't perform edits on a registration
            raise NodeStateError

        tag = Tag.load(tag)
        if not tag:
            raise InvalidTagError
        elif tag not in self.tags:
            raise TagNotFoundError
        else:
            self.tags.remove(tag)
            if log:
                self.add_tag_log(NodeLog.FILE_TAG_REMOVED, tag._id, auth)
            if save:
                self.save()
            return True