Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
record
recordweb
Commits
34d36ec0
Commit
34d36ec0
authored
Jul 24, 2018
by
Nathalie Rousse
Browse files
vle-x/trunk,erecord_slm/models.py : Modifying get_upload_to_path to make migrations possible.
parent
0a8127c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
vle-x/trunk/erecord/erecord/apps/erecord_slm/models.py
View file @
34d36ec0
...
...
@@ -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_
up
load_to_path
,
storage
=
fs
,
docfile
=
models
.
FileField
(
upload_to
=
get_
down
load_to_path
,
storage
=
fs
,
max_length
=
600
)
key
=
models
.
CharField
(
max_length
=
60
,
blank
=
True
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment