diff --git a/submissions/forms.py b/submissions/forms.py index 7aa45b91c4a90757b431f9743a3f1e89715d7c64..aaf160d1c67bfe11912de317ff840e3a52d5fc7f 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -324,7 +324,7 @@ class RequestSubmissionForm(SubmissionChecks, forms.ModelForm): def clean_author_list(self): """Check if author list matches the Contributor submitting. - + The submitting user must be an author of the submission. Also possibly may be extended to check permissions and give ultimate submission power to certain user groups. @@ -576,7 +576,7 @@ class ReportForm(forms.ModelForm): model = Report fields = ['qualification', 'strengths', 'weaknesses', 'report', 'requested_changes', 'validity', 'significance', 'originality', 'clarity', 'formatting', 'grammar', - 'recommendation', 'remarks_for_editors', 'anonymous'] + 'recommendation', 'remarks_for_editors', 'anonymous', 'file_attachment'] def __init__(self, *args, **kwargs): if kwargs.get('instance'): diff --git a/submissions/migrations/0011_report_file_attachment.py b/submissions/migrations/0011_report_file_attachment.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d463f7dfa685bd3dcf5703468ce3c7656657b9 --- /dev/null +++ b/submissions/migrations/0011_report_file_attachment.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-04-27 07:31 +from __future__ import unicode_literals + +import comments.behaviors +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0010_auto_20180314_1607'), + ] + + operations = [ + migrations.AddField( + model_name='report', + name='file_attachment', + field=models.FileField(blank=True, upload_to='uploads/reports/%Y/%m/%d/', validators=[comments.behaviors.validate_file_extension, comments.behaviors.validate_max_file_size]), + ), + ] diff --git a/submissions/models.py b/submissions/models.py index 9c3bbcf7b50c7927ca7cf7f65379de024bcd27d0..cf0e13a28d73cd5ccf1eff0a2661ca6cc879c1dc 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -28,6 +28,7 @@ from .managers import ( from .utils import ( ShortSubmissionCycle, DirectRecommendationSubmissionCycle, GeneralSubmissionCycle) +from comments.behaviors import validate_file_extension, validate_max_file_size from comments.models import Comment from scipost.behaviors import TimeStampedModel from scipost.constants import TITLE_CHOICES @@ -515,6 +516,11 @@ class Report(SubmissionRelatedObjectMixin, models.Model): anonymous = models.BooleanField(default=True, verbose_name='Publish anonymously') pdf_report = models.FileField(upload_to='UPLOADS/REPORTS/%Y/%m/', max_length=200, blank=True) + # Attachment + file_attachment = models.FileField( + upload_to='uploads/reports/%Y/%m/%d/', blank=True, + validators=[validate_file_extension, validate_max_file_size]) + objects = ReportQuerySet.as_manager() class Meta: