From 79c73b2502f0beae5fb6fd587f8beb364174fa70 Mon Sep 17 00:00:00 2001 From: oyvinlek Date: Sun, 6 Mar 2011 18:01:15 +0000 Subject: [PATCH] Lagt til html-visning av kategorier og en oversikt over hyller. --- python/web/library/views.py | 17 ++++++++++++++--- python/web/templates/category/index.html | 14 ++++++++++++++ python/web/templates/category/view.html | 23 +++++++++++++++++++++++ python/web/templates/map/index.html | 15 +++++++++++++++ python/web/templates/map/view.html | 4 ++-- python/web/urls.py | 5 ++++- 6 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 python/web/templates/category/index.html create mode 100644 python/web/templates/category/view.html create mode 100644 python/web/templates/map/index.html diff --git a/python/web/library/views.py b/python/web/library/views.py index 949dbf6..09a7b36 100644 --- a/python/web/library/views.py +++ b/python/web/library/views.py @@ -32,8 +32,8 @@ def BookView(request,book_identifier): return render_to_response('book/view.html', {'book' : book, 'people' : people, 'shelves' : shelves, 'contributors' : contributors}) def BookRedirect(request,book_identifier): - ident=get_object_or_404(Id,id=book_identifier) - return HttpResponseRedirect('/book/'+ident.book.isbn) + ident=get_object_or_404(Id,id=book_identifier) + return HttpResponseRedirect('/book/'+ident.book.isbn) def PersonView(request,person_identifier): global relations @@ -51,11 +51,22 @@ def PersonView(request,person_identifier): contributed[relation][1].append(book) return render_to_response('person/view.html', {'title' : 'Worblehat: person '+person.first_name+' '+person.last_name, 'person' : person, 'books' : books, 'contributed' : contributed }) +def MapIndex(request): + return render_to_response('map/index.html', {'shelves': Placement.get_all_shelves()}) + def MapView(request,shelf_identifier): if shelf_identifier not in Placement.get_all_shelves(): raise Http404() shelf_list = Placement.shelf_as_list_row_then_col(shelf_identifier) - return render_to_response('map/view.html', {'shelf': shelf_list}) + return render_to_response('map/view.html', {'shelf_name': shelf_identifier, 'shelf': shelf_list}) + +def CategoryIndex(request): + return render_to_response('category/index.html', {'categories': Category.objects.all()}) + +def CategoryView(request,category_identifier): + category = get_object_or_404(Category,id=category_identifier) + book_list = category.book_set.all() + return render_to_response('category/view.html', {'category': category, 'book_list': book_list}) def IndexView(request): return render_to_response('index.html') diff --git a/python/web/templates/category/index.html b/python/web/templates/category/index.html new file mode 100644 index 0000000..fc00aca --- /dev/null +++ b/python/web/templates/category/index.html @@ -0,0 +1,14 @@ +{% extends "base/main.html" %} + +{%block title%} +Worblehat 0.1: Kategorier +{% endblock %} + +{% block content %} +

Kategorier:

+ +{% endblock %} diff --git a/python/web/templates/category/view.html b/python/web/templates/category/view.html new file mode 100644 index 0000000..0991f56 --- /dev/null +++ b/python/web/templates/category/view.html @@ -0,0 +1,23 @@ +{% extends "base/main.html" %} + +{%block title%} +Worblehat 0.1: Kategori: {{ category }} +{% endblock %} + +{% block content %} + +{{ category }}
+ +{% if not book_list %} +Det finnes ingen bøker i denne kategorien. +{% else %} +Følgende bøker finnes i denne kategorien: + +{% endif %} + +{% endblock %} + diff --git a/python/web/templates/map/index.html b/python/web/templates/map/index.html new file mode 100644 index 0000000..b8a3545 --- /dev/null +++ b/python/web/templates/map/index.html @@ -0,0 +1,15 @@ +{% extends "base/main.html" %} + +{%block title%} +Worblehat 0.1: Fresh, detailed, life-saving maps! +{% endblock %} + +{% block content %} +Hyller: + +{% endblock %} + diff --git a/python/web/templates/map/view.html b/python/web/templates/map/view.html index bc7bb7a..7ec2497 100644 --- a/python/web/templates/map/view.html +++ b/python/web/templates/map/view.html @@ -1,7 +1,7 @@ {% extends "base/main.html" %} {%block title%} -Worblehat 0.1: Fresh, detailed, life-saving maps! +Worblehat 0.1: Hylle {{ shelf_name }} {% endblock %} {% block content %} @@ -12,7 +12,7 @@ Worblehat 0.1: Fresh, detailed, life-saving maps! {% for category in column %} - + {% endfor %}
{{ category }}
{{ category }}
diff --git a/python/web/urls.py b/python/web/urls.py index 074414f..56c107c 100644 --- a/python/web/urls.py +++ b/python/web/urls.py @@ -15,7 +15,10 @@ urlpatterns = patterns('', (r'^bok/(?P\d+)/$','web.library.views.BookView'), (r'^bok/(?P\S+)/$','web.library.views.BookRedirect'), (r'^person/(?P\S+)/$','web.library.views.PersonView'), - (r'^kart/(?P\S+)/$', 'web.library.views.MapView'), + (r'^kart/$','web.library.views.MapIndex'), + (r'^kart/(?P\S+)/$','web.library.views.MapView'), + (r'^kategori/$','web.library.views.CategoryIndex'), + (r'^kategori/(?P\S+)/$','web.library.views.CategoryView'), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), (r'^let/','web.library.views.SearchView'),