summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2014-05-13 21:11:10 -0400
committerluxagraf <sng@luxagraf.net>2014-05-13 21:11:10 -0400
commit750746d3d6f3cd297902a8d8ccd5d7519a9956e0 (patch)
treeb4cd33925598ca41850e4b8359051e378db453e0
parent0fa249a811fe6266e198c6cf82658a2ebe0d101b (diff)
Remaned the bookhighlight model to be singlar and imported all the json
data I have
-rw-r--r--README3
-rw-r--r--app/books/admin.py8
-rw-r--r--app/books/kindleparser.py6
-rw-r--r--app/books/models.py25
4 files changed, 30 insertions, 12 deletions
diff --git a/README b/README
index 9e2aa95..829e6c9 100644
--- a/README
+++ b/README
@@ -1,10 +1,7 @@
TODO:
[] Look into multimarkdown support along with preprocessor for addin srcset to image tags
-[] Experiement with pagespeed optionsa
-[] figure out memchached
[] Install PHP for Adatptive images
-[] Switch Gunicorn to run as nobody -- didn't work, causing internal error
[] Write out geojson data for natparks into site/projects/natparks/parkid
[] Redo template on natparks page to call new location
[] Update view fuction to add project name (for now just hard code it)
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