mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-01 08:54:37 +00:00
[Printer] Move user_printing_path from utils to models (avoid circular import)
This commit is contained in:
parent
5d85fd1b74
commit
6b3fa3b15a
2 changed files with 9 additions and 3 deletions
|
@ -18,6 +18,6 @@ class Migration(migrations.Migration):
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='jobwithoptions',
|
model_name='jobwithoptions',
|
||||||
name='file',
|
name='file',
|
||||||
field=models.FileField(storage=django.core.files.storage.FileSystemStorage(location='/var/impressions'), upload_to=printer.utils.user_printing_path, validators=[printer.validators.FileValidator(allowed_types=['application/pdf'], max_size=26214400)]),
|
field=models.FileField(storage=django.core.files.storage.FileSystemStorage(location='/var/impressions'), upload_to=printer.models.user_printing_path, validators=[printer.validators.FileValidator(allowed_types=['application/pdf'], max_size=26214400)]),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,6 +7,9 @@ Author : Maxime Bombar <bombar@crans.org>.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from numpy.random import randint
|
||||||
|
import unidecode
|
||||||
|
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -43,10 +46,13 @@ import math
|
||||||
- ```Job``` is the main model of a printer job. His parent is the ```user``` model.
|
- ```Job``` is the main model of a printer job. His parent is the ```user``` model.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def user_printing_path(instance, filename):
|
def user_printing_path(instance, filename):
|
||||||
|
"""
|
||||||
|
Defines the path where will be uploaded the files
|
||||||
|
"""
|
||||||
# File will be uploaded to MEDIA_ROOT/printings/user_<id>/<filename>
|
# File will be uploaded to MEDIA_ROOT/printings/user_<id>/<filename>
|
||||||
return 'printings/user_{0}/{1}'.format(instance.user.id, filename)
|
return 'printings/user_{0}/{1}'.format(instance.user.id, unidecode.unidecode(filename))
|
||||||
|
|
||||||
|
|
||||||
class JobWithOptions(RevMixin, models.Model):
|
class JobWithOptions(RevMixin, models.Model):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue