diff --git a/python/web/library/models.py b/python/web/library/models.py
index 7a02e20..c54696f 100644
--- a/python/web/library/models.py
+++ b/python/web/library/models.py
@@ -208,7 +208,7 @@ class BookPerson(models.Model):
return self.person.first_name +u' '+ self.person.last_name+ u' '+ self.relation.name+ u' of '+self.book.title
class Placement(models.Model):
- category = models.ForeignKey(Category,related_name='placement')
+ category = models.ForeignKey(Category, related_name='placement')
shelf = models.CharField(max_length=10)
def __unicode__(self):
diff --git a/python/web/library/views.py b/python/web/library/views.py
index 335c0b4..8874222 100644
--- a/python/web/library/views.py
+++ b/python/web/library/views.py
@@ -3,19 +3,54 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.db.models import Q
+
+relations = {'Author' : u'Forfatter', 'Illustrator' : u'Tegner', 'Translator' : u'Oversetter'}
+
+
+# Create your views here.
def BookView(request,book_identifier):
- book=get_object_or_404(Book,isbn=book_identifier)
- people = book.persons.all()
- return render_to_response('book/view.html', {'book' : book, 'people' : people})
+ book=get_object_or_404(Book,isbn=book_identifier)
+ people = book.persons.all()
+ shelves = None
+ global relations
+ if book.category:
+ if book.category.placement:
+ shelves = book.category.placement.all()
+ contributors = {}
+ for person in people:
+ print person.relation
+ if str(person.relation) in relations:
+ relation = relations[str(person.relation)]
+ else:
+ relation = 'Medvirkende'
+ if not relation in contributors:
+ contributors[relation] = [0, []]
+# contributors[person.relation] = "%s %s" % (person.person.first_name, person.person.last_name)
+# else:
+ contributors[relation][0] += 1
+ contributors[relation][1].append(person)
+ print contributors
+ 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)
def PersonView(request,person_identifier):
- person = get_object_or_404(Person,id=person_identifier)
- books = person.books.all()
- return render_to_response('person/view.html', {'title' : 'Worblehat: person '+person.first_name+' '+person.last_name,'person' : person, 'books' : books})
+ global relations
+ person = get_object_or_404(Person,id=person_identifier)
+ books = person.books.all()
+ contributed = {}
+ for book in books:
+ if str(book.relation) in relations:
+ relation = relations[str(book.relation)]
+ else:
+ relation = 'Medvirkende'
+ if not relation in contributed:
+ contributed[relation] = [0, []]
+ contributed[relation][0] += 1
+ 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 MapView(request,shelf_identifier):
if shelf_identifier not in Placement.get_all_shelves():
diff --git a/python/web/media/styles/scaffold.css b/python/web/media/styles/scaffold.css
index 6742cee..2fb22b6 100644
--- a/python/web/media/styles/scaffold.css
+++ b/python/web/media/styles/scaffold.css
@@ -75,6 +75,9 @@ img.aligncenter {
}
.img {
+ float: left;
+ display: inline;
+ margin-right: 10px;
text-align: left;
}
diff --git a/python/web/templates/book/view.html b/python/web/templates/book/view.html
index 20e3844..9e20ff3 100644
--- a/python/web/templates/book/view.html
+++ b/python/web/templates/book/view.html
@@ -1,15 +1,56 @@
{% extends "base/main.html" %}
{%block title%}
-Worblehat 0.1: {{ book.title }}
+Worblehat: {{ book.title }}
{% endblock %}
{% block content %}
+{% if book.thumbnail %}
+
+
+
+{% endif %}
+
+{{ book.title }}
+{% if book.subtitle %}
+ {{ book.subtitle }}
+{% endif %}
+
+{% for relation, persons in contributors.iteritems %}
+{{ relation }}{% if persons.0 != 1 and relation != 'Medvirkende' %}e{% endif %}:
+{% for person in persons.1 %}
+{{ person.person.first_name }} {{ person.person.last_name }}{% if not forloop.last %}, {% endif %}
+{% endfor %}
+
+{% endfor %}
+{% if book.category %}
+ Kategori: {{ book.category }}
+{% endif %}
+{% if book.shelves %}
+ Hylle: {{ book.shelves }}
+{% endif %}
+{% if book.published_year %}
+ År: {{ book.published_year }}
+{% endif %}
+{% if book.edition %}
+ Utgave: {{ book.edition }}
+{% endif %}
+{% if book.num_pages %}
+ Antall sider: {{ book.num_pages }}
+{% endif %}
+{% if book.series %}
+ Serie: {{ book.series }}
+{% endif %}
+{% if book.description %}
+ Beskrivelse: {{ book.description }}
+{% endif %}
+ISBN: {{ book.isbn }}
+
{% endblock %}
diff --git a/python/web/templates/person/view.html b/python/web/templates/person/view.html
index fae65a9..f8d9483 100644
--- a/python/web/templates/person/view.html
+++ b/python/web/templates/person/view.html
@@ -1,12 +1,22 @@
{% extends "base/main.html" %}
{% block title%}
-Worblehat 0.1: {{ person.first_name }} {{ person.last_name }}
+Worblehat: {{ person.first_name }} {{ person.last_name }}
{% endblock %}
{% block content %}
-Name: {{person.first_name}} {{person.last_name}}
+