fnp
/
edumed.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
db00cdf
)
don't overrwrite files from different lessons
author
Jan Szejko
<janek37@gmail.com>
Wed, 14 Mar 2018 14:32:08 +0000
(15:32 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Wed, 14 Mar 2018 14:32:08 +0000
(15:32 +0100)
catalogue/models.py
patch
|
blob
|
history
diff --git
a/catalogue/models.py
b/catalogue/models.py
index
c5ed66c
..
4a21790
100644
(file)
--- a/
catalogue/models.py
+++ b/
catalogue/models.py
@@
-302,11
+302,15
@@
class Lesson(models.Model):
return any(requirement in self.dc.get('requires', []) for requirement in ('internet', 'Internet'))
return any(requirement in self.dc.get('requires', []) for requirement in ('internet', 'Internet'))
+def attachment_path(instance, filename):
+ return 'catalogue/attachment/%s/%s' % (instance.lesson.slug, filename)
+
+
class Attachment(models.Model):
slug = models.CharField(max_length=255)
ext = models.CharField(max_length=15)
lesson = models.ForeignKey(Lesson)
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"
, storage=bofh_storage, max_length=255)
+ file = models.FileField(upload_to=
attachment_path
, storage=bofh_storage, max_length=255)
class Meta:
ordering = ['slug', 'ext']
class Meta:
ordering = ['slug', 'ext']