From: Aleksander Ɓukasz Date: Mon, 13 May 2013 09:30:24 +0000 (+0200) Subject: Refactoring X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/23f0993732ac597e0a4ab1330b62b970c09d476c?ds=sidebyside Refactoring --- diff --git a/apps/libraries/models.py b/apps/libraries/models.py index 1ed43ad77..c6db612b9 100644 --- a/apps/libraries/models.py +++ b/apps/libraries/models.py @@ -17,7 +17,7 @@ class Catalog(models.Model): @models.permalink def get_absolute_url(self): - return ('library_view', [self.slug]) + return ('libraries_catalog_view', [self.slug]) class Library(models.Model): diff --git a/apps/libraries/templates/libraries/catalog_view.html b/apps/libraries/templates/libraries/catalog_view.html new file mode 100644 index 000000000..b109fa1b3 --- /dev/null +++ b/apps/libraries/templates/libraries/catalog_view.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block titleextra %}{% trans 'Libraries directory' %}{% endblock %} + + +{% block body %} +

{% trans 'Libraries directory' %}: {{ catalog.name }}

+ +
+ {% for library in catalog.libraries.all %} +
+ +
+ + {% autoescape off %}{{library.description}}{% endautoescape%} +
+
+ {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/apps/libraries/templates/libraries/library_view.html b/apps/libraries/templates/libraries/library_view.html deleted file mode 100644 index b109fa1b3..000000000 --- a/apps/libraries/templates/libraries/library_view.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block titleextra %}{% trans 'Libraries directory' %}{% endblock %} - - -{% block body %} -

{% trans 'Libraries directory' %}: {{ catalog.name }}

- -
- {% for library in catalog.libraries.all %} -
- -
- - {% autoescape off %}{{library.description}}{% endautoescape%} -
-
- {% endfor %} -
- -{% endblock %} \ No newline at end of file diff --git a/apps/libraries/urls.py b/apps/libraries/urls.py index 92621144b..fe0fd6b96 100644 --- a/apps/libraries/urls.py +++ b/apps/libraries/urls.py @@ -5,5 +5,5 @@ from django.http import HttpResponseRedirect urlpatterns = patterns('libraries.views', url(r'^$', 'main_view', name='libraries_main_view'), url(r'^/$', lambda x: HttpResponseRedirect(x.path[:-1])), - url(r'^/(?P[a-zA-Z0-9_-]+)$', 'library_view', name='library_view'), + url(r'^/(?P[a-zA-Z0-9_-]+)$', 'catalog_view', name='libraries_catalog_view'), ) \ No newline at end of file diff --git a/apps/libraries/views.py b/apps/libraries/views.py index baf7baaf4..88f993d68 100644 --- a/apps/libraries/views.py +++ b/apps/libraries/views.py @@ -9,7 +9,7 @@ def main_view(request): context['catalogs'] = Catalog.objects.all() return render_to_response('libraries/main_view.html', context_instance = context) -def library_view(request, slug): +def catalog_view(request, slug): context = RequestContext(request) context['catalog'] = get_object_or_404(Catalog.objects.filter(slug = slug).select_related()) - return render_to_response('libraries/library_view.html', context_instance = context) \ No newline at end of file + return render_to_response('libraries/catalog_view.html', context_instance = context) \ No newline at end of file