Commit d6c45659 by Alex Gaynor

The abstraction we needed already exists.

parent f759697f
...@@ -32,6 +32,7 @@ class TagBase(models.Model): ...@@ -32,6 +32,7 @@ class TagBase(models.Model):
trans_kwargs = {} trans_kwargs = {}
i = 0 i = 0
while True: while True:
i += 1
try: try:
sid = transaction.savepoint(**trans_kwargs) sid = transaction.savepoint(**trans_kwargs)
res = super(TagBase, self).save(*args, **kwargs) res = super(TagBase, self).save(*args, **kwargs)
......
...@@ -123,7 +123,8 @@ class ArticleTag(Tag): ...@@ -123,7 +123,8 @@ class ArticleTag(Tag):
proxy = True proxy = True
def slugify(self, tag, i=None): def slugify(self, tag, i=None):
slug = "category-%s" % tag slug = "category-%s" % tag.lower()
if i is not None: if i is not None:
slug += "-%d" % i slug += "-%d" % i
return slug return slug
...@@ -132,9 +133,9 @@ class ArticleTaggedItem(TaggedItem): ...@@ -132,9 +133,9 @@ class ArticleTaggedItem(TaggedItem):
class Meta: class Meta:
proxy = True proxy = True
# Basically we want to overide the tag ForeignKey to point at the proxy @classmethod
# inherited ArticleTag so we can get the right slugify, unfortunately I def tag_model(self):
# can't seem to figure out how to do this, so we're on hold ATM. return ArticleTag
class Article(models.Model): class Article(models.Model):
title = models.CharField(max_length=100) title = models.CharField(max_length=100)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment