def add_tag(self, tag, auth, save=True, log=True): from osf.models import Tag, NodeLog # Prevent import error if not self.tags.filter(system=False, name=tag).exists() and not self.node.is_registration: new_tag = Tag.load(tag) if not new_tag: new_tag = Tag(name=tag) new_tag.save() self.tags.add(new_tag) if log: self.add_tag_log(NodeLog.FILE_TAG_ADDED, tag, auth) if save: self.save() return True return False
def add_tag(self, tag, auth, save=True, log=True): from osf.models import Tag, NodeLog # Prevent import error if not self.tags.filter( system=False, name=tag).exists() and not self.node.is_registration: new_tag = Tag.load(tag) if not new_tag: new_tag = Tag(name=tag) new_tag.save() self.tags.add(new_tag) if log: self.add_tag_log(NodeLog.FILE_TAG_ADDED, tag, auth) if save: self.save() return True return False
def test_load_loads_by_name(self): tag_name = 'NeONDreams' tag = Tag(name=tag_name) tag.save() assert Tag.load(tag_name).pk == tag.pk