From: Radek Czajka Date: Mon, 10 Mar 2014 13:16:31 +0000 (+0100) Subject: Use BofhFileSystemStorage where file names are preset. X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/7210db1597376df2228e65dcea91141f1d78495f Use BofhFileSystemStorage where file names are preset. --- diff --git a/catalogue/models.py b/catalogue/models.py index 55ee821..edb82f0 100644 --- a/catalogue/models.py +++ b/catalogue/models.py @@ -3,9 +3,11 @@ from django.core.files import File from django.core.urlresolvers import reverse from django.db import models from jsonfield import JSONField +from fnpdjango.storage import BofhFileSystemStorage from curriculum.models import Level, Curriculum, CurriculumCourse import logging +bofh_storage = BofhFileSystemStorage() class Section(models.Model): @@ -13,7 +15,8 @@ class Section(models.Model): slug = models.SlugField(max_length=255, unique=True) order = models.IntegerField() xml_file = models.FileField(upload_to="catalogue/section/xml", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, + storage=bofh_storage) image = models.ImageField(upload_to="catalogue/section/image", null=True, blank=True) @@ -88,17 +91,17 @@ class Lesson(models.Model): description = models.TextField(null=True, blank=True) xml_file = models.FileField(upload_to="catalogue/lesson/xml", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) html_file = models.FileField(upload_to="catalogue/lesson/html", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) package = models.FileField(upload_to="catalogue/lesson/pack", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) student_package = models.FileField(upload_to="catalogue/lesson/student_pack", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) pdf = models.FileField(upload_to="catalogue/lesson/pdf", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) student_pdf = models.FileField(upload_to="catalogue/lesson/student_pdf", - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) class Meta: ordering = ['section', 'level', 'order'] @@ -273,7 +276,7 @@ class Attachment(models.Model): slug = models.CharField(max_length=255) ext = models.CharField(max_length=15) lesson = models.ForeignKey(Lesson) - file = models.FileField(upload_to="catalogue/attachment") + file = models.FileField(upload_to="catalogue/attachment", storage=bofh_storage) class Meta: ordering = ['slug', 'ext'] diff --git a/curriculum/models.py b/curriculum/models.py index b8cd81d..a5d531f 100644 --- a/curriculum/models.py +++ b/curriculum/models.py @@ -3,8 +3,12 @@ import re from django.core.urlresolvers import reverse from django.db import models from django.utils.translation import ugettext_lazy as _, get_language +from fnpdjango.storage import BofhFileSystemStorage from fnpdjango.utils.models.translation import add_translatable +bofh_storage = BofhFileSystemStorage() + + class Section(models.Model): slug = models.SlugField(_('slug')) order = models.IntegerField(_('order')) @@ -70,9 +74,9 @@ class Level(models.Model): meta_name = models.CharField(_('meta name'), max_length=255, unique=True) order = models.IntegerField(_('order')) package = models.FileField(upload_to=lambda i, f: "curriculum/pack/edukacjamedialna_%s.zip" % i.slug, - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) student_package = models.FileField(upload_to=lambda i, f: "curriculum/pack/edukacjamedialna_%s_uczen.zip" % i.slug, - null=True, blank=True, max_length=255) + null=True, blank=True, max_length=255, storage=bofh_storage) class Meta: ordering = ['order']