summaryrefslogtreecommitdiff
path: root/app/books/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/books/models.py')
-rw-r--r--app/books/models.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/books/models.py b/app/books/models.py
new file mode 100644
index 0000000..8c9fe9b
--- /dev/null
+++ b/app/books/models.py
@@ -0,0 +1,33 @@
+from django.db import models
+from django.template.defaultfilters import slugify
+
+class Book(models.Model):
+ title = models.CharField(max_length=200)
+ author_name = models.CharField(max_length=200)
+ slug = models.CharField(max_length=50)
+ year_pub = models.CharField(max_length=4, blank=True, null=True)
+ read_date = models.DateTimeField()
+ isbn = models.CharField(max_length=100, blank=True, null=True)
+
+ class Meta:
+ ordering = ('-read_date',)
+
+ def __str__(self):
+ return self.title
+
+ def save(self, *args, **kwargs):
+ self.slug = slugify(self.title[:50])
+ super(Book, self).save()
+
+class BookHighlights(models.Model):
+ book = models.ForeignKey(Book)
+ page = models.PositiveSmallIntegerField(null=True)
+ location = models.PositiveSmallIntegerField(null=True)
+ date_added = models.DateTimeField()
+ body_markdown = models.TextField()
+
+ def __str__(self):
+ return "%s%s" %(self.book.title, self.id)
+
+class BookNotes(BookHighlights):
+ pass