diff --git a/printer/migrations/0008_auto_20181012_1242.py b/printer/migrations/0008_auto_20181012_1242.py new file mode 100644 index 00000000..4ac92372 --- /dev/null +++ b/printer/migrations/0008_auto_20181012_1242.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-10-12 10:42 +from __future__ import unicode_literals + +import django.core.files.storage +from django.db import migrations, models +import printer.utils +import printer.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('printer', '0007_auto_20180925_1351'), + ] + + operations = [ + migrations.AlterField( + model_name='jobwithoptions', + 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)]), + ), + ] diff --git a/printer/models.py b/printer/models.py index 8e8f211f..407e5b4a 100644 --- a/printer/models.py +++ b/printer/models.py @@ -7,6 +7,8 @@ Author : Maxime Bombar . from __future__ import unicode_literals +from django.core.files.storage import FileSystemStorage + from django.db import models from django.forms import ValidationError from django.utils.translation import ugettext_lazy as _ @@ -78,7 +80,12 @@ class JobWithOptions(RevMixin, models.Model): ('Finished', 'Finished') ) user = models.ForeignKey('users.User', on_delete=models.PROTECT) - file = models.FileField(upload_to=user_printing_path, validators=[FileValidator(allowed_types=ALLOWED_TYPES, max_size=MAX_PRINTFILE_SIZE)]) + file = models.FileField(storage=FileSystemStorage(location='/var/impressions'), + upload_to=user_printing_path, + validators=[FileValidator( + allowed_types=ALLOWED_TYPES, + max_size=MAX_PRINTFILE_SIZE) + ]) filename = models.CharField(max_length=255,null=True) starttime = models.DateTimeField(auto_now_add=True) endtime = models.DateTimeField(null=True)