async def hashmarksByObjTags(taglist, **kw): tags = iptags.ipTagsFormatList(taglist, **kw) filter = Q(objtags__name__in=tags) for tag in tags: filter = filter | Q(objtags__name__icontains=tag) return await Hashmark.filter(filter)
async def hashmarksByTags(taglist, strict=False, limit=0, **kw): tags = iptags.ipTagsFormatList(taglist, **kw) filter = Q(iptags__name__in=tags) for tag in tags: if strict: filter = filter | Q(iptags__name=tag) else: filter = filter | Q(iptags__name__icontains=tag) return await Hashmark.filter(filter).limit(limit if limit > 0 else 32768)
async def hashmarkTagsUpdate(hashmark, tagsl: list, type='iptags'): tags = iptags.ipTagsFormatList(tagsl) for tag in tags: if not isinstance(tag, str): continue itag = await ipTagAdd(tag) if type == 'iptags': await hashmark.iptags.add(itag) await itag.revhashmarks.add(hashmark) elif type == 'objtags': await hashmark.objtags.add(itag)
async def hashmarksByObjTagLatest(tag): tags = iptags.ipTagsFormatList([tag]) return await Hashmark.filter(objtags__name__in=tags ).order_by('-datecreated').first()