This commit is contained in:
Daniel Quinn
2016-02-17 23:07:54 +00:00
parent eb01bcf98b
commit 1e7ece81ee
3 changed files with 18 additions and 9 deletions

View File

@@ -86,7 +86,19 @@ class Tag(SluggedModel):
return "{}: \"{}\" ({})".format(
self.name, self.match, self.get_matching_algorithm_display())
@classmethod
def match_all(cls, text, tags=None):
if tags is None:
tags = cls.objects.all()
text = text.lower()
for tag in tags:
if tag.matches(text):
yield tag
def matches(self, text):
# Check that match is not empty
if self.match.strip() == "":
return False