From: Marek Stępniowski Date: Fri, 5 Sep 2008 08:41:50 +0000 (+0200) Subject: Renamed tagged_book_list to tagged_object_list. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/83559fba0846ad77721b31231d1d807a91e52157 Renamed tagged_book_list to tagged_object_list. --- 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_book_list.html deleted file mode 100644 index 3aa9a36b4..000000000 --- a/templates/catalogue/tagged_book_list.html +++ /dev/null @@ -1,146 +0,0 @@ -{% extends "base.html" %} -{% load catalogue_tags pagination_tags %} - -{% block title %}{% title_from_tags tags %} w WolneLektury.pl{% endblock %} - -{% block bodyid %}books{% endblock %} - -{% block extrahead %} - -{% endblock %} - -{% block body %} -

{% title_from_tags tags %}

- {% breadcrumbs tags %} - - {% autopaginate object_list 10 %} -
- {% with tags|last as last_tag %} - {% if last_tag.has_description %} -
- {{ last_tag.description|safe }} -
-

Zwiń opis ▲

- {% endif %} - {% endwith %} -
    - {% for book in object_list %} -
  1. {{ book.short_html }}
  2. - {% endfor %} -
- {% paginate %} -
-
-
- {% if categories.set %} -

Zestawy

- - {% endif %} -
-
- {% if categories.author %} -

Autorzy

- - {% endif %} -
-
- {% if categories.epoch %} -

Epoki

- - {% endif %} -
-
- {% if categories.kind %} -

Rodzaje

- - {% endif %} -
-
- {% if categories.genre %} -

Gatunki literackie

- - {% endif %} -
-
- {% if categories.theme %} -

Motywy

- - {% endif %} -
-
-
- -
-

* Ładowanie

-
-
-{% endblock %} \ No newline at end of file diff --git a/templates/catalogue/tagged_object_list.html b/templates/catalogue/tagged_object_list.html new file mode 100644 index 000000000..3aa9a36b4 --- /dev/null +++ b/templates/catalogue/tagged_object_list.html @@ -0,0 +1,146 @@ +{% extends "base.html" %} +{% load catalogue_tags pagination_tags %} + +{% block title %}{% title_from_tags tags %} w WolneLektury.pl{% endblock %} + +{% block bodyid %}books{% endblock %} + +{% block extrahead %} + +{% endblock %} + +{% block body %} +

{% title_from_tags tags %}

+ {% breadcrumbs tags %} + + {% autopaginate object_list 10 %} +
+ {% with tags|last as last_tag %} + {% if last_tag.has_description %} +
+ {{ last_tag.description|safe }} +
+

Zwiń opis ▲

+ {% endif %} + {% endwith %} +
    + {% for book in object_list %} +
  1. {{ book.short_html }}
  2. + {% endfor %} +
+ {% paginate %} +
+
+
+ {% if categories.set %} +

Zestawy

+ + {% endif %} +
+
+ {% if categories.author %} +

Autorzy

+ + {% endif %} +
+
+ {% if categories.epoch %} +

Epoki

+ + {% endif %} +
+
+ {% if categories.kind %} +

Rodzaje

+ + {% endif %} +
+
+ {% if categories.genre %} +

Gatunki literackie

+ + {% endif %} +
+
+ {% if categories.theme %} +

Motywy

+ + {% endif %} +
+
+
+ +
+

* Ładowanie

+
+
+{% endblock %} \ No newline at end of file