diff options
Diffstat (limited to 'app/books')
-rw-r--r-- | app/books/admin.py | 8 | ||||
-rw-r--r-- | app/books/kindleparser.py | 6 | ||||
-rw-r--r-- | app/books/models.py | 25 |
3 files changed, 30 insertions, 9 deletions
diff --git a/app/books/admin.py b/app/books/admin.py index 2bf7cdc..0b9b7b7 100644 --- a/app/books/admin.py +++ b/app/books/admin.py @@ -1,11 +1,11 @@ from django.contrib import admin -from .models import Book,BookHighlights +from .models import Book,BookHighlight class BookAdmin(admin.ModelAdmin): - list_display = ('title', 'author_name', 'read_date') + list_display = ('title', 'isbn', 'author_name', 'read_date') -class BookHighlightsAdmin(admin.ModelAdmin): +class BookHighlightAdmin(admin.ModelAdmin): list_display = ('book', 'date_added') admin.site.register(Book, BookAdmin) -admin.site.register(BookHighlights, BookHighlightsAdmin) +admin.site.register(BookHighlight, BookHighlightAdmin) diff --git a/app/books/kindleparser.py b/app/books/kindleparser.py index b2f0191..6b708d9 100644 --- a/app/books/kindleparser.py +++ b/app/books/kindleparser.py @@ -6,7 +6,7 @@ This script then parses that json and tries to load it into the django database import json import datetime from django.core.exceptions import ObjectDoesNotExist -from books.models import Book, BookHighlights +from books.models import Book, BookHighlight def parse_kindle_clippings(path): json_data = open(path) @@ -43,11 +43,11 @@ def parse_kindle_clippings(path): ) try: #see if we already this highlight - row = BookHighlights.objects.get(book__title=clip['title'], date_added=clip_date ) + row = BookHighlight.objects.get(book__title=clip['title'], date_added=clip_date ) #if we don't create a new book highlight except ObjectDoesNotExist: book = Book.objects.get(title=clip['title']) - bh, created = BookHighlights.objects.get_or_create( + bh, created = BookHighlight.objects.get_or_create( book = book, page = page, location = location, diff --git a/app/books/models.py b/app/books/models.py index 8c9fe9b..173b5f6 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -1,5 +1,7 @@ from django.db import models from django.template.defaultfilters import slugify +from taggit.managers import TaggableManager + class Book(models.Model): title = models.CharField(max_length=200) @@ -9,6 +11,22 @@ class Book(models.Model): read_date = models.DateTimeField() isbn = models.CharField(max_length=100, blank=True, null=True) + body_html = models.TextField(null=True, blank=True) + + url = models.CharField(max_length=200, blank=True, null=True) + + #tags = TaggableManager(blank=True, null=True) + tags = models.CharField(max_length=200,blank=True, null=True) + RATINGS = ( + ('1', "1 Star"), + ('2', "2 Stars"), + ('3', "3 Stars"), + ('4', "4 Stars"), + ('5', "5 Stars"), + ) + rating = models.CharField(max_length=1, choices=RATINGS, null=True) + enable_comments = models.BooleanField(default=False) + class Meta: ordering = ('-read_date',) @@ -19,15 +37,18 @@ class Book(models.Model): self.slug = slugify(self.title[:50]) super(Book, self).save() -class BookHighlights(models.Model): +class BookHighlight(models.Model): book = models.ForeignKey(Book) page = models.PositiveSmallIntegerField(null=True) location = models.PositiveSmallIntegerField(null=True) date_added = models.DateTimeField() body_markdown = models.TextField() + class Meta: + ordering = ('-date_added',) + def __str__(self): return "%s%s" %(self.book.title, self.id) -class BookNotes(BookHighlights): +class BookNote(BookHighlight): pass |