diff --git a/db.txt b/db.txt index 64b92df..18b45ba 100644 --- a/db.txt +++ b/db.txt @@ -1,6 +1,6 @@ Tabeller: -bok (primærnøkkel: (isbn,id)) +bok (primærnøkkel: (isbn)) isbn id (tekst) tittel @@ -20,11 +20,11 @@ bokserie tittel alternativ_tittel - bok (isbn, id) + bok (isbn) alt_tittel eksemplar - bok (isbn, id) + bok (isbn) nummer eier («PVV» eller brukernavn) @@ -34,7 +34,7 @@ person fornavn bokperson - bok (isbn, id) + bok (isbn) person (id) relasjon (forfatter, redaktør, etc) diff --git a/python/web/library/models.py b/python/web/library/models.py index 21bcbf2..65b3270 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -1,22 +1,27 @@ from django.db import models -class Book(models.Model): - isbn = models.CharField(max_length=13) -# id = models.CharField(max_length=255, unique=True) - title = models.CharField(max_length=511) - subtitle = models.CharField(max_length=511) -# category = - publisher = models.CharField(max_length=255) - published_year = models.IntegerField() - edition = models.IntegerField() - num_pages = models.IntegerField() -# series = - description = models.CharField(max_length=1023) - picture = models.ImageField('%Y/%m/%d/pictures') - thumbnail = models.ImageField('%Y/%m/%d/thumbnails') +class Category(models.Model): + id = models.CharField(max_length=255, primary_key=True) + name = models.CharField(max_length=255) class BookSeries(models.Model): - title = models.CharField(max_length=500) + id = models.CharField(max_length=20, primary_key=True) + title = models.CharField(max_length=511) + +class Book(models.Model): + isbn = models.CharField(max_length=13, primary_key=True) + id = models.CharField(max_length=255, unique=True) + title = models.CharField(max_length=511) + subtitle = models.CharField(max_length=511, null=True, blank=True) + category = models.ForeignKey(Category) + publisher = models.CharField(max_length=255, null=True, blank=True) + published_year = models.IntegerField(null=True, blank=True) + edition = models.IntegerField(null=True, blank=True) + num_pages = models.IntegerField(null=True, blank=True) + series = models.ForeignKey(BookSeries, null=True, blank=True) + description = models.CharField(max_length=1023, null=True, blank=True) + picture = models.ImageField(upload_to='%Y/%m/%d/pictures', null=True, blank=True) + thumbnail = models.ImageField(upload_to='%Y/%m/%d/thumbnails', null=True, blank=True) class AlternativeTitle(models.Model): book = models.ForeignKey(Book) @@ -25,17 +30,28 @@ class AlternativeTitle(models.Model): class Copy(models.Model): book = models.ForeignKey(Book) number = models.IntegerField() - owner = models.CharField(max_length=255) + owner = models.CharField(max_length=9) class Person(models.Model): + id = models.CharField(max_length=255, primary_key=True) first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) +class Relation(models.Model): + name = models.CharField(max_length=31) + class BookPerson(models.Model): book = models.ForeignKey(Book) person = models.ForeignKey(Person) - relation = models.CharField(max_length=255) + relation = models.ForeignKey(Relation) + +class ReferenceType(models.Model): + name = models.CharField(max_length=31) class Reference(models.Model): - reference_type = models.CharField(max_length=255) + reference_type = models.ForeignKey(ReferenceType) text = models.CharField(max_length=1023) + +class Placement(models.Model): + category = models.ForeignKey(Category) + shelf = models.CharField(max_length=10) diff --git a/python/web/settings.py b/python/web/settings.py index 9cdd939..2f6a233 100644 --- a/python/web/settings.py +++ b/python/web/settings.py @@ -9,11 +9,11 @@ ADMINS = ( MANAGERS = ADMINS -DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = 'web/test_database' # Or path to database file if using sqlite3. -DATABASE_USER = '' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +DATABASE_NAME = 'oysteini_pbb' # Or path to database file if using sqlite3. +DATABASE_USER = 'oysteini_pbb' # Not used with sqlite3. +DATABASE_PASSWORD = 'lio5Aide' # Not used with sqlite3. +DATABASE_HOST = 'postgres.pvv.ntnu.no' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: