summaryrefslogtreecommitdiff
path: root/app/books
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2017-09-23 16:48:54 -0500
committerluxagraf <sng@luxagraf.net>2017-09-23 16:48:54 -0500
commit821fc221c86cd0630042aecc4bb6cddd9464208b (patch)
tree8c3479b1315deeb55e78886ccbe1b9583f90ddbc /app/books
parentef2fbc67a923e4d39f0497943c11dc1eaeb74f5d (diff)
pulled in changes on arch server
Diffstat (limited to 'app/books')
-rw-r--r--app/books/migrations/0004_auto_20161219_1058.py20
-rw-r--r--app/books/models.py6
2 files changed, 25 insertions, 1 deletions
diff --git a/app/books/migrations/0004_auto_20161219_1058.py b/app/books/migrations/0004_auto_20161219_1058.py
new file mode 100644
index 0000000..1b3a952
--- /dev/null
+++ b/app/books/migrations/0004_auto_20161219_1058.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9 on 2016-12-19 10:58
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('books', '0003_auto_20161023_2014'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='book',
+ name='image',
+ field=models.FileField(blank=True, null=True, upload_to='/home/lxf/apps/luxagraf/site/media/images/book-covers/'),
+ ),
+ ]
diff --git a/app/books/models.py b/app/books/models.py
index 4359a3e..4362bc9 100644
--- a/app/books/models.py
+++ b/app/books/models.py
@@ -7,6 +7,10 @@ from django.template.defaultfilters import slugify
from utils.widgets import markdown_to_html
+def get_upload_path(self, filename):
+ return "images/book-covers/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
+
+
class Book(models.Model):
title = models.CharField(max_length=200)
author_name = models.CharField(max_length=200)
@@ -31,7 +35,7 @@ class Book(models.Model):
rating = models.CharField(max_length=1, choices=RATINGS, null=True, blank=True)
enable_comments = models.BooleanField(default=False)
is_public = models.BooleanField(default=True)
- image = models.FileField(upload_to="%s/%s" % (settings.IMAGES_ROOT, 'book-covers/'), null=True, blank=True)
+ image = models.FileField(upload_to=get_upload_path, null=True, blank=True)
class Meta:
ordering = ('-read_date',)