From 83559fba0846ad77721b31231d1d807a91e52157 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20St=C4=99pniowski?= Date: Fri, 5 Sep 2008 10:41:50 +0200 Subject: [PATCH] Renamed tagged_book_list to tagged_object_list. --- catalogue/models.py | 5 ++--- catalogue/templatetags/catalogue_tags.py | 2 +- catalogue/urls.py | 2 +- catalogue/views.py | 10 +++++----- lib/markupstring.py | 3 +++ .../{tagged_book_list.html => tagged_object_list.html} | 0 6 files changed, 12 insertions(+), 10 deletions(-) rename templates/catalogue/{tagged_book_list.html => tagged_object_list.html} (100%) diff --git a/catalogue/models.py b/catalogue/models.py index c82cf4356..0d3df1603 100644 --- a/catalogue/models.py +++ b/catalogue/models.py @@ -49,7 +49,7 @@ class Tag(TagBase): @permalink def get_absolute_url(self): - return ('catalogue.views.tagged_book_list', [self.slug]) + return ('catalogue.views.tagged_object_list', [self.slug]) class Meta: ordering = ('sort_key',) @@ -130,7 +130,6 @@ class Book(models.Model): from slughifi import slughifi import dcparser from markupstring import MarkupString - import re # Read book metadata book_info = dcparser.parse(xml_file) @@ -163,7 +162,7 @@ class Book(models.Model): for fragment in closed_fragments.values(): text = fragment.to_string() short_text = '' - if (len(re.sub(r'', '', text)) > 240): + if (len(MarkupString(text)) > 240): short_text = MarkupString(text)[:160] new_fragment = Fragment(text=text, short_text=short_text, anchor=fragment.id, book=book) diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index 20c7abd23..0e05fa52a 100644 --- a/catalogue/templatetags/catalogue_tags.py +++ b/catalogue/templatetags/catalogue_tags.py @@ -164,7 +164,7 @@ class CatalogueURLNode(Node): pass if len(tag_slugs) > 0: - return reverse('tagged_book_list', kwargs={'tags': '/'.join(tag_slugs)}) + return reverse('tagged_object_list', kwargs={'tags': '/'.join(tag_slugs)}) else: return reverse('main_page') diff --git a/catalogue/urls.py b/catalogue/urls.py index 5827285d3..2fc293912 100644 --- a/catalogue/urls.py +++ b/catalogue/urls.py @@ -10,6 +10,6 @@ urlpatterns = patterns('catalogue.views', url(r'^lektura/(?P[a-zA-Z0-9-]+)/$', 'book_detail'), url(r'^tags/$', 'tags_starting_with', name='hint'), url(r'^szukaj/$', 'search', name='search'), - url(r'^(?P[a-zA-Z-/]+)/$', 'tagged_book_list', name='tagged_book_list'), + url(r'^(?P[a-zA-Z-/]+)/$', 'tagged_object_list', name='tagged_object_list'), ) diff --git a/catalogue/views.py b/catalogue/views.py index 0d174ce91..8feb63c22 100644 --- a/catalogue/views.py +++ b/catalogue/views.py @@ -13,10 +13,10 @@ from django.utils import simplejson from django.utils.functional import Promise from django.utils.encoding import force_unicode -from newtagging.views import tagged_object_list from catalogue import models from catalogue import forms from catalogue.utils import split_tags +from newtagging import views as newtagging_views class LazyEncoder(simplejson.JSONEncoder): @@ -43,7 +43,7 @@ def search(request): return HttpResponseRedirect(reverse('catalogue.views.main_page')) else: tag_list.append(tag) - return HttpResponseRedirect(reverse('catalogue.views.tagged_book_list', + return HttpResponseRedirect(reverse('catalogue.views.tagged_object_list', kwargs={'tags': '/'.join(tag.slug for tag in tag_list)} )) @@ -96,7 +96,7 @@ def book_list(request): context_instance=RequestContext(request)) -def tagged_book_list(request, tags=''): +def tagged_object_list(request, tags=''): try: tags = models.Tag.get_tag_list(tags) except models.Tag.DoesNotExist: @@ -114,12 +114,12 @@ def tagged_book_list(request, tags=''): related_tags = models.Tag.objects.related_for_model(tags, model, counts=True, extra={'where': [extra_where]}) categories = split_tags(related_tags) - return tagged_object_list( + return newtagging_views.tagged_object_list( request, tag_model=models.Tag, queryset_or_model=model, tags=tags, - template_name='catalogue/tagged_book_list.html', + template_name='catalogue/tagged_object_list.html', extra_context = {'categories': categories }, ) diff --git a/lib/markupstring.py b/lib/markupstring.py index f31e148cd..d3ee955b2 100644 --- a/lib/markupstring.py +++ b/lib/markupstring.py @@ -92,3 +92,6 @@ class MarkupString (unicode): for et in ends[e]: outbuf+= et return MarkupString(outbuf) + def __len__(self): + return len(self.raw) + diff --git a/templates/catalogue/tagged_book_list.html b/templates/catalogue/tagged_object_list.html similarity index 100% rename from templates/catalogue/tagged_book_list.html rename to templates/catalogue/tagged_object_list.html -- 2.20.1