View for list of catalogs
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 10 May 2013 08:48:01 +0000 (10:48 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 10 May 2013 08:48:01 +0000 (10:48 +0200)
apps/libraries/locale/pl/LC_MESSAGES/django.mo
apps/libraries/locale/pl/LC_MESSAGES/django.po
apps/libraries/models.py
apps/libraries/templates/libraries/library_view.html [new file with mode: 0644]
apps/libraries/templates/libraries/main_view.html
apps/libraries/urls.py
apps/libraries/views.py
wolnelektury/urls.py

index a29a7b0..4aa3d52 100644 (file)
Binary files a/apps/libraries/locale/pl/LC_MESSAGES/django.mo and b/apps/libraries/locale/pl/LC_MESSAGES/django.mo differ
index 3c3e2bc..0b0a8a4 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-05-09 16:09+0200\n"
+"POT-Creation-Date: 2013-05-10 10:38+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -19,7 +19,7 @@ msgstr ""
 "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
 "|| n%100>=20) ? 1 : 2);\n"
 
-#: models.py:8 models.py:22
+#: models.py:8 models.py:26
 msgid "name"
 msgstr "nazwa"
 
@@ -35,22 +35,28 @@ msgstr "katalog"
 msgid "catalogs"
 msgstr "katalogi"
 
-#: models.py:24
+#: models.py:28
 msgid "url"
 msgstr "url"
 
-#: models.py:25
+#: models.py:29
 msgid "description"
 msgstr "opis"
 
-#: models.py:28
+#: models.py:32
 msgid "library"
 msgstr "biblioteka"
 
-#: models.py:29
+#: models.py:33
 msgid "libraries"
 msgstr "biblioteki"
 
-#: templates/libraries/main_view.html:4 templates/libraries/main_view.html:8
+#: templates/libraries/library_view.html:4
+#: templates/libraries/library_view.html:8
 msgid "Libraries directory"
 msgstr "Katalog bibliotek"
+
+#: templates/libraries/main_view.html:4 templates/libraries/main_view.html:8
+msgid "Library directories"
+msgstr "Katalogi bibliotek"
+
index db6c6a5..1ed43ad 100644 (file)
@@ -15,7 +15,11 @@ class Catalog(models.Model):
     def __unicode__(self):\r
         return self.name\r
         \r
-    \r
+    @models.permalink\r
+    def get_absolute_url(self):\r
+        return ('library_view', [self.slug])\r
+        \r
+        \r
 class Library(models.Model):\r
     """Represent a single library in the libraries dictionary"""\r
 \r
diff --git a/apps/libraries/templates/libraries/library_view.html b/apps/libraries/templates/libraries/library_view.html
new file mode 100644 (file)
index 0000000..b109fa1
--- /dev/null
@@ -0,0 +1,22 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block titleextra %}{% trans 'Libraries directory' %}{% endblock %}
+
+
+{% block body %}
+    <h1>{% trans 'Libraries directory' %}: {{ catalog.name }}</h1>
+
+    <div class="libraries-list">
+        {% for library in catalog.libraries.all %}
+        <div class="libraries-list-item">
+            <div class="libraries-list-item-header"><a href="{{library.url}}">{{library.name}}</a></div>
+            <div class="libraries-list-item-description">
+                
+                {% autoescape off %}{{library.description}}{% endautoescape%}
+            </div>
+        </div>
+        {% endfor %}
+    </div>
+
+{% endblock %}
\ No newline at end of file
index b109fa1..f732a2a 100644 (file)
@@ -1,22 +1,15 @@
-{% extends "base.html" %}
-{% load i18n %}
-
-{% block titleextra %}{% trans 'Libraries directory' %}{% endblock %}
-
-
-{% block body %}
-    <h1>{% trans 'Libraries directory' %}: {{ catalog.name }}</h1>
-
-    <div class="libraries-list">
-        {% for library in catalog.libraries.all %}
-        <div class="libraries-list-item">
-            <div class="libraries-list-item-header"><a href="{{library.url}}">{{library.name}}</a></div>
-            <div class="libraries-list-item-description">
-                
-                {% autoescape off %}{{library.description}}{% endautoescape%}
-            </div>
-        </div>
+{% extends "base.html" %}\r
+{% load i18n %}\r
+\r
+{% block titleextra %}{% trans 'Library directories' %}{% endblock %}\r
+\r
+\r
+{% block body %}\r
+    <h1>{% trans 'Library directories' %}</h1>
+    <ul>
+        {% for catalog in catalogs %}
+            <li><a href="{{catalog.get_absolute_url}}">{{catalog}}</a></li>
         {% endfor %}
-    </div>
-
+    </ul>\r
+\r
 {% endblock %}
\ No newline at end of file
index b4af54b..9262114 100644 (file)
@@ -1,6 +1,9 @@
 from django.conf.urls.defaults import patterns, url
+from django.http import HttpResponseRedirect
 
 
 urlpatterns = patterns('libraries.views',
-    url(r'^(?P<slug>[a-zA-Z0-9_-]+)$', 'main_view', name='libraries_main_view'),
+    url(r'^$', 'main_view', name='libraries_main_view'),
+    url(r'^/$', lambda x: HttpResponseRedirect(x.path[:-1])),
+    url(r'^/(?P<slug>[a-zA-Z0-9_-]+)$', 'library_view', name='library_view'),
 )
\ No newline at end of file
index 45e60dd..baf7baa 100644 (file)
@@ -4,7 +4,12 @@ from django.template import RequestContext, Template, TemplateSyntaxError
 from libraries.models import Catalog\r
 \r
 \r
-def main_view(request, slug):\r
+def main_view(request):\r
+    context = RequestContext(request)\r
+    context['catalogs'] = Catalog.objects.all()\r
+    return render_to_response('libraries/main_view.html', context_instance = context)\r
+\r
+def library_view(request, slug):\r
     context = RequestContext(request)\r
     context['catalog'] = get_object_or_404(Catalog.objects.filter(slug = slug).select_related())\r
-    return render_to_response('libraries/main_view.html', context_instance = context)
\ No newline at end of file
+    return render_to_response('libraries/library_view.html', context_instance = context)
\ No newline at end of file
index 9801733..e99b081 100644 (file)
@@ -35,7 +35,7 @@ urlpatterns += patterns('',
     url(r'^ludzie/', include('social.urls')),
     url(r'^uzytkownik/', include('allauth.urls')),
     url(r'^czekaj/', include('waiter.urls')),
-    url(r'^biblioteki/', include('libraries.urls')),
+    url(r'^biblioteki', include('libraries.urls')),
 
     # Admin panel
     url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),