fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of http://github.com/fnp/wolnelektury
[wolnelektury.git]
/
apps
/
catalogue
/
models.py
diff --git
a/apps/catalogue/models.py
b/apps/catalogue/models.py
index
d63581f
..
2008f09
100644
(file)
--- a/
apps/catalogue/models.py
+++ b/
apps/catalogue/models.py
@@
-102,8
+102,10
@@
class Tag(TagBase):
def get_tag_list(tags):
if isinstance(tags, basestring):
real_tags = []
def get_tag_list(tags):
if isinstance(tags, basestring):
real_tags = []
+ ambiguous_slugs = []
category = None
category = None
- for name in tags.split('/'):
+ tags_splitted = tags.split('/')
+ for index, name in enumerate(tags_splitted):
if name in Tag.categories_rev:
category = Tag.categories_rev[name]
else:
if name in Tag.categories_rev:
category = Tag.categories_rev[name]
else:
@@
-111,10
+113,22
@@
class Tag(TagBase):
real_tags.append(Tag.objects.get(slug=name, category=category))
category = None
else:
real_tags.append(Tag.objects.get(slug=name, category=category))
category = None
else:
- real_tags.append(Tag.objects.get(slug=name))
+ try:
+ real_tags.append(Tag.objects.exclude(category='book').get(slug=name))
+ except Tag.MultipleObjectsReturned, e:
+ ambiguous_slugs.append(name)
+
if category:
if category:
- raise Http404
- return real_tags
+ # something strange left off
+ raise Tag.DoesNotExist()
+ if ambiguous_slugs:
+ # some tags should be qualified
+ e = Tag.MultipleObjectsReturned()
+ e.tags = real_tags
+ e.ambiguous_slugs = ambiguous_slugs
+ raise e
+ else:
+ return real_tags
else:
return TagBase.get_tag_list(tags)
else:
return TagBase.get_tag_list(tags)