diff --git a/submissions/migrations/0053_auto_20170721_1100.py b/submissions/migrations/0053_auto_20170721_1100.py new file mode 100644 index 0000000000000000000000000000000000000000..ebb3fc0bfb4327f4c5a8ed239a130468efd4eae1 --- /dev/null +++ b/submissions/migrations/0053_auto_20170721_1100.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-21 09:00 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0052_auto_20170721_1057'), + ] + + operations = [ + migrations.AlterField( + model_name='report', + name='author', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reports', to='scipost.Contributor'), + ), + ] diff --git a/submissions/models.py b/submissions/models.py index 7209ea33ba7b1c6bb4902073aedb2ac69ab13cf7..17d86ded80c3f4d034d714cb89df14686830f2ac 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -248,8 +248,7 @@ class Report(models.Model): to explicitly implement the perticular differences in for example the form used. """ status = models.CharField(max_length=16, choices=REPORT_STATUSES, default=STATUS_UNVETTED) - submission = models.ForeignKey('submissions.Submission', related_name='reports', - on_delete=models.CASCADE) + submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE) vetted_by = models.ForeignKey('scipost.Contributor', related_name="report_vetted_by", blank=True, null=True, on_delete=models.CASCADE) @@ -291,6 +290,9 @@ class Report(models.Model): objects = ReportManager() + class Meta: + default_related_name = 'reports' + def __str__(self): return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' + self.submission.title[:50] + ' by ' + self.submission.author_list[:50]) @@ -301,7 +303,7 @@ class Report(models.Model): Check if current Report is a `FollowupReport`. A Report is a `FollowupReport` if the author of the report already has a vetted report in the series of the specific Submission. """ - return (self.author.report_set.accepted() + return (self.author.reports.accepted() .filter(submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr) .exists()) @@ -309,7 +311,7 @@ class Report(models.Model): """ Get latest Report from the same author for the Submission series. """ - return (self.author.report_set.accepted() + return (self.author.reports.accepted() .filter(submission__arxiv_identifier_wo_vn_nr=self.submission.arxiv_identifier_wo_vn_nr) .order_by('submission__arxiv_identifier_wo_vn_nr').last())