diff --git a/scipost/models.py b/scipost/models.py index 7d05b6a020dff4bfb47208bd63396ff7015d1e75..6df8cec1fce7bd45ef33501b1014999c1fa9411e 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -146,19 +146,14 @@ class Remark(models.Model): date = models.DateTimeField(auto_now_add=True) remark = models.TextField() + class Meta: + default_related_name = 'remarks' + def __str__(self): return (self.contributor.user.first_name + ' ' + self.contributor.user.last_name + ' on ' + self.date.strftime("%Y-%m-%d")) - def as_li(self): - output = '<li><em>{{ by }}</em><p>{{ remark }}</p>' - context = Context({'by': str(self), - 'remark': self.remark}) - template = Template(output) - return template.render(context) - - ############### # Invitations # ############### diff --git a/scipost/templates/partials/scipost/remark_as_li.html b/scipost/templates/partials/scipost/remark_as_li.html new file mode 100644 index 0000000000000000000000000000000000000000..6554304e1a0a9f616a753188233660e4226dfbbf --- /dev/null +++ b/scipost/templates/partials/scipost/remark_as_li.html @@ -0,0 +1 @@ +<li><em>{{remark.contributor.first_name}} {{remark.contributor.last_name}} on {{remark.date|date:'Y-m-j'}}</em><p>{{remark.remark}}</p> diff --git a/submissions/templates/submissions/_submission_card_in_pool.html b/submissions/templates/submissions/_submission_card_in_pool.html index 5425c11952f2f49df48595bd064d8f1dfd45342b..ad484a07864a5b1a45ee339273c28547a87e8cb3 100644 --- a/submissions/templates/submissions/_submission_card_in_pool.html +++ b/submissions/templates/submissions/_submission_card_in_pool.html @@ -6,10 +6,10 @@ {% include 'submissions/_submission_card_fellow_content.html' with submission=submission %} <div class="card-body"> - {% if submission.remark_set.all %} + {% if submission.remarks.all %} <h4>Remarks on this submission:</h4> <ul> - {% for rem in submission.remark_set.all %} + {% for rem in submission.remarks.all %} {% include 'scipost/_remark_li.html' with remark=rem %} {% endfor %} </ul> diff --git a/submissions/templates/submissions/admin/eic_recommendation_detail.html b/submissions/templates/submissions/admin/eic_recommendation_detail.html index ecb457c9be7c8fe905f7c50575b79c5f89c84db6..e453c3dc64de64d4d7a1ae07d45b33b4dc8532eb 100644 --- a/submissions/templates/submissions/admin/eic_recommendation_detail.html +++ b/submissions/templates/submissions/admin/eic_recommendation_detail.html @@ -33,11 +33,11 @@ <div class="card card-outline-secondary"> {% include 'submissions/_recommendation_fellow_content.html' with recommendation=object %} <div class="card-body"> - {% if object.remark_set.all %} + {% if object.remarks.all %} <h3 class="card-title">Remarks by Fellows:</h3> <ul> - {% for remark in object.remark_set.all|sort_by:'date' %} - {{ remark.as_li }} + {% for remark in object.remarks.all|sort_by:'date' %} + {% include 'partials/submissions/remark_as_li.html' with remark=remark %} {% endfor %} </ul> {% endif %} @@ -73,10 +73,10 @@ </li> </ul> - {% if object.remark_set %} + {% if object.remarks %} <h3 class="card-title">Remarks:</h3> <ul> - {% for rem in object.remark_set.all %} + {% for rem in object.remarks.all %} <li>{{ rem }}</li> {% empty %} <li><em>No remarks</em></li> diff --git a/submissions/templates/submissions/pool.html b/submissions/templates/submissions/pool.html index e5dcb543661c9eddb70807537cf3c95cc94671de..ee80629ae9547d42966b84e0561162da0c09bac8 100644 --- a/submissions/templates/submissions/pool.html +++ b/submissions/templates/submissions/pool.html @@ -51,11 +51,11 @@ <div class="card card-outline-secondary"> {% include 'submissions/_recommendation_fellow_content.html' with recommendation=rec %} <div class="card-body"> - {% if rec.remark_set.all %} + {% if rec.remarks.all %} <h3 class="card-title">Remarks by Fellows:</h3> <ul> - {% for remark in rec.remark_set.all|sort_by:'date' %} - {{ remark.as_li }} + {% for remark in rec.remarks.all|sort_by:'date' %} + {% include 'partials/submissions/remark_as_li.html' with remark=remark %} {% endfor %} </ul> {% endif %} @@ -91,10 +91,10 @@ </li> </ul> - {% if rec.remark_set %} + {% if rec.remarks %} <h3 class="card-title">Remarks:</h3> <ul> - {% for rem in rec.remark_set.all %} + {% for rem in rec.remarks.all %} <li>{{ rem }}</li> {% empty %} <li><em>No remarks</em></li> diff --git a/submissions/views.py b/submissions/views.py index c4adc1fbd42d80a9a2fcaeb6f37292e930e37a65..944203d30483dc047d1566618ae0f83bc268af7a 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -344,7 +344,7 @@ def pool(request): All members of the Editorial College have access. """ submissions_in_pool = (Submission.objects.get_pool(request.user) - .prefetch_related('referee_invitations', 'remark_set', 'comments')) + .prefetch_related('referee_invitations', 'remarks', 'comments')) recommendations_undergoing_voting = (EICRecommendation.objects .get_for_user_in_pool(request.user) .filter(submission__status__in=['put_to_EC_voting'])) diff --git a/virtualmeetings/models.py b/virtualmeetings/models.py index 67a42474511244779f1180769a9ffe36819e7803..8a511de9d68dcdd86ece75b38686b0673bbdb42e 100644 --- a/virtualmeetings/models.py +++ b/virtualmeetings/models.py @@ -44,9 +44,6 @@ class Feedback(models.Model): def get_absolute_url(self): return self.VGM.get_absolute_url() + '#feedback' + str(self.id) - def as_li(self): - raise DeprecationWarning - class Nomination(models.Model): """ @@ -84,12 +81,6 @@ class Nomination(models.Model): def get_absolute_url(self): return self.VGM.get_absolute_url() + '#nomination_' + str(self.id) - def as_li(self): - raise DeprecationWarning - - def votes_as_ul(self): - raise DeprecationWarning - def update_votes(self, contributor_id, vote): contributor = get_object_or_404(Contributor, pk=contributor_id) self.in_agreement.remove(contributor) @@ -138,12 +129,6 @@ class Motion(models.Model): def get_absolute_url(self): return self.VGM.get_absolute_url() + '#motion_' + str(self.id) - def as_li(self): - raise DeprecationWarning - - def votes_as_ul(self): - raise DeprecationWarning - def update_votes(self, contributor_id, vote): contributor = get_object_or_404(Contributor, pk=contributor_id) self.in_agreement.remove(contributor) diff --git a/virtualmeetings/templates/virtualmeetings/VGM_detail.html b/virtualmeetings/templates/virtualmeetings/VGM_detail.html index ad312caa0decfad16d6e860d2ba61f1bfa866ef7..399a7881308467630fae1f63944cc873828d5df8 100644 --- a/virtualmeetings/templates/virtualmeetings/VGM_detail.html +++ b/virtualmeetings/templates/virtualmeetings/VGM_detail.html @@ -82,10 +82,10 @@ <input class="btn btn-secondary" type="submit" value="Submit" /> </form> </div> - {% if feedback.remark_set.all %} + {% if feedback.remarks.all %} <h3>Remarks on this feedback:</h3> <ul> - {% for rem in feedback.remark_set.all %} + {% for rem in feedback.remarks.all %} {% include 'scipost/_remark_li.html' with remark=rem %} {% endfor %} </ul> @@ -196,10 +196,10 @@ <input type="submit" class="btn btn-secondary" value="Submit" /> </form> </div> - {% if nomination.remark_set.all %} + {% if nomination.remarks.all %} <h3>Remarks on this nomination:</h3> <ul> - {% for rem in nomination.remark_set.all %} + {% for rem in nomination.remarks.all %} {% include 'scipost/_remark_li.html' with remark=rem %} {% endfor %} </ul> @@ -278,10 +278,10 @@ <input type="submit" class="btn btn-secondary" value="Submit" /> </form> </div> - {% if motion.remark_set.all %} + {% if motion.remarks.all %} <h3>Remarks on this motion:</h3> <ul> - {% for rem in motion.remark_set.all %} + {% for rem in motion.remarks.all %} {% include 'scipost/_remark_li.html' with remark=rem %} {% endfor %} </ul>