Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Normalized, slugified, and made tags unique. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachnid committed Oct 17, 2009
1 parent 94814ae commit 387acfc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class TagsContentGenerator(ListingContentGenerator):

@classmethod
def get_resource_list(cls, post):
return post.tags
return post.normalized_tags

@classmethod
def _filter_query(cls, resource, q):
q.filter('tags =', resource)
q.filter('normalized_tags =', resource)
generator_list.append(TagsContentGenerator)


Expand Down
2 changes: 1 addition & 1 deletion handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class PostForm(djangoforms.ModelForm):
class Meta:
model = models.BlogPost
exclude = [ 'path', 'published', 'updated', 'deps' ]
exclude = [ 'path', 'published', 'updated', 'deps', 'normalized_tags' ]


def with_post(fun):
Expand Down
2 changes: 1 addition & 1 deletion lib/aetycoon
Submodule aetycoon updated 1 files
+68 −0 __init__.py
6 changes: 5 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ class BlogPost(db.Model):
path = db.StringProperty()
title = db.StringProperty(required=True, indexed=False)
body = db.TextProperty(required=True)
tags = db.StringListProperty()
tags = aetycoon.SetProperty(basestring, indexed=False)
published = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
deps = aetycoon.PickleProperty()

@aetycoon.TransformProperty(tags)
def normalized_tags(tags):
return list(set(utils.slugify(x.lower()) for x in tags))

@property
def summary(self):
"""Returns a summary of the blog post."""
Expand Down
2 changes: 1 addition & 1 deletion themes/default/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2><a href="{{post.path}}">{{post.title|escape}}</a></h2>
Posted by {{config.author_name}}
{% if post.tags %}
| Filed under
{% for tag in post.tags %}
{% for tag in post.normalized_tags %}
<a href="/tag/{{tag|escape}}">{{tag|escape}}</a>{% if not forloop.last %},{% endif %}
{% endfor %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion themes/default/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>{{post.title|escape}}</h2>
Posted by {{config.author_name}}
{% if post.tags %}
| Filed under
{% for tag in post.tags %}
{% for tag in post.normalized_tags %}
<a href="/tag/{{tag|escape}}">{{tag|escape}}</a>{% if not forloop.last %},{% endif %}
{% endfor %}
{% endif %}
Expand Down

0 comments on commit 387acfc

Please sign in to comment.