Fix #187: add timestamp to final path on upload for avoid file renaming.
parent
c54b14711c
commit
71afb1cf79
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import collections
|
import collections
|
||||||
|
import time
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -262,11 +263,14 @@ class Project(ProjectDefaults, models.Model):
|
||||||
|
|
||||||
|
|
||||||
def get_attachment_file_path(instance, filename):
|
def get_attachment_file_path(instance, filename):
|
||||||
return "attachment-files/{project}/{model}/{filename}".format(
|
template = "attachment-files/{project}/{model}/{stamp}/{filename}"
|
||||||
project=instance.project.slug,
|
current_timestamp = int(time.mktime(timezone.now().timetuple()))
|
||||||
model=instance.content_type.model,
|
|
||||||
filename=filename
|
upload_to_path = template.format(stamp=current_timestamp,
|
||||||
)
|
project=instance.project.slug,
|
||||||
|
model=instance.content_type.model,
|
||||||
|
filename=filename)
|
||||||
|
return upload_to_path
|
||||||
|
|
||||||
|
|
||||||
class Attachment(models.Model):
|
class Attachment(models.Model):
|
||||||
|
|
Loading…
Reference in New Issue