summaryrefslogtreecommitdiff
path: root/app/books/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2019-12-23 10:01:21 -0500
committerluxagraf <sng@luxagraf.net>2019-12-23 10:01:21 -0500
commit6288785513e1d4590e14c3abfa70c700b6398c64 (patch)
tree6e9cf82b748c0faac070dd1114e6aaddcbdba283 /app/books/models.py
parent4d09849f85a70794dd78b7aee7fab5a67e11ceae (diff)
fixed book hilights to auto add book if not filled in
Diffstat (limited to 'app/books/models.py')
-rw-r--r--app/books/models.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/books/models.py b/app/books/models.py
index 004ed8c..8e8b485 100644
--- a/app/books/models.py
+++ b/app/books/models.py
@@ -109,20 +109,20 @@ class BookHighlight(models.Model):
body_html = models.TextField(blank=True)
class Meta:
- ordering = ('-page', '-date_added')
+ ordering = ('-date_added', '-page',)
+ get_latest_by = 'date_added'
def __str__(self):
- return "%s%s" % (self.book.title, self.id)
-
- def body_html_old(self):
- return markdown_to_html(self.body_markdown)
+ return "%s - %s" % (self.book.title, self.id)
def save(self, *args, **kwargs):
+ if not self.pk:
+ if self.book_id is None:
+ self.book = BookHighlight.objects.latest().book
self.body_html = markdown_to_html(self.body_markdown)
- if not self.book:
- self.book = BookHighlight.objects.latest().book
super(BookHighlight, self).save()
+
class BookSitemap(Sitemap):
changefreq = "never"
priority = 0.7