Commit 34d36ec0 authored by Nathalie Rousse's avatar Nathalie Rousse
Browse files

vle-x/trunk,erecord_slm/models.py : Modifying get_upload_to_path to make migrations possible.

parent 0a8127c4
......@@ -20,18 +20,28 @@ from erecord_acs.models_mixins import LockableMixin
from erecord_cmn.configs.config import DOWNLOADS_HOME_APP_VPZ
from erecord_cmn.configs.config import DOWNLOAD_LIFETIME
from django.utils.deconstruct import deconstructible
@deconstructible
class getUploadToPath(object):
def __call__(self, instance, filename):
return instance.get_available_filepath(
root=os.path.join(settings.CLOSEDMEDIA_ROOT,
DOWNLOADS_HOME_APP_VPZ),
sub="download", date=instance.date, filename=filename)
get_upload_to_path = getUploadToPath()
class UploadVpzDocument(LockableMixin, LoadVpzDocumentMixin, models.Model):
"""Uploaded document relative to erecord_vpz application"""
date = models.DateTimeField(auto_now_add=True)
def get_upload_to_path(self, filename):
return self.get_available_filepath(
root=os.path.join(settings.CLOSEDMEDIA_ROOT,
DOWNLOADS_HOME_APP_VPZ),
sub="upload",
date=self.date, filename=filename)
## def get_upload_to_path(self, filename):
## return self.get_available_filepath(
## root=os.path.join(settings.CLOSEDMEDIA_ROOT,
## DOWNLOADS_HOME_APP_VPZ),
## sub="upload", date=self.date, filename=filename)
fs = FileSystemStorage(location=settings.CLOSEDMEDIA_ROOT,
base_url=settings.CLOSEDMEDIA_URL)
......@@ -72,22 +82,31 @@ def uploadvpzdocument_clear(sender, instance, *args, **kwargs):
pre_delete.connect(uploadvpzdocument_clear, sender=UploadVpzDocument)
@deconstructible
class getDownloadToPath(object):
def __call__(self, instance, filename):
return instance.get_available_filepath(
root=os.path.join(settings.CLOSEDMEDIA_ROOT,
DOWNLOADS_HOME_APP_VPZ),
sub="download", date=instance.date, filename=filename)
get_download_to_path = getDownloadToPath()
class DownloadVpzDocument(LockableMixin, LoadVpzDocumentMixin, models.Model):
"""Downloadable document relative to erecord_vpz application"""
date = models.DateTimeField(auto_now_add=True)
def get_upload_to_path(self, filename):
return self.get_available_filepath(
root=os.path.join(settings.CLOSEDMEDIA_ROOT,
DOWNLOADS_HOME_APP_VPZ),
sub="download",
date=self.date, filename=filename)
## def get_upload_to_path(self, filename):
## return self.get_available_filepath(
## root=os.path.join(settings.CLOSEDMEDIA_ROOT,
## DOWNLOADS_HOME_APP_VPZ),
## sub="download", date=self.date, filename=filename)
fs = FileSystemStorage(location=settings.CLOSEDMEDIA_ROOT,
base_url=settings.CLOSEDMEDIA_URL)
docfile = models.FileField(upload_to=get_upload_to_path, storage=fs,
docfile = models.FileField(upload_to=get_download_to_path, storage=fs,
max_length=600)
key = models.CharField(max_length=60, blank=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment