Skip to content

Commit

Permalink
added tag cleaning to mark tags function
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfadeev committed Apr 16, 2014
1 parent 3265dfb commit 27738db
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions askbot/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ def clean_marked_tagnames(tagnames):
if tagname == '':
continue
if tagname.endswith('*'):
if tagname.count('*') > 1:
if tagname.count('*') > 1 or len(tagname) == 1:
continue
else:
wildcards.append(tagname)
base_tag = tagname[:-1]
cleaned_base_tag = clean_tag(base_tag, look_in_db=False)
wildcards.append(cleaned_base_tag + '*')
else:
pure_tags.append(tagname)
pure_tags.append(clean_tag(tagname))

return pure_tags, wildcards

Expand Down Expand Up @@ -354,7 +356,7 @@ def __init__(self, *args, **kwargs):
self.min_length = askbot_settings.MIN_ANSWER_BODY_LENGTH


def clean_tag(tag_name):
def clean_tag(tag_name, look_in_db=True):
"""a function that cleans a single tag name"""
tag_length = len(tag_name)
if tag_length > askbot_settings.MAX_TAG_LENGTH:
Expand Down Expand Up @@ -383,6 +385,8 @@ def clean_tag(tag_name):
if askbot_settings.FORCE_LOWERCASE_TAGS:
#a simpler way to handle tags - just lowercase thew all
return tag_name.lower()
elif look_in_db == False:
return tag_name
else:
from askbot import models
matching_tags = models.Tag.objects.filter(name__iexact=tag_name)
Expand Down

0 comments on commit 27738db

Please sign in to comment.