From 3f2310676e6ffc13807649f158b7759ba7563408 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Tue, 30 Oct 2018 09:38:46 +0100 Subject: [PATCH] Fixing --- ontology/models.py | 7 +++---- ontology/templates/ontology/_topic_card.html | 16 ++++++---------- ontology/templates/ontology/ontology.html | 10 +++++----- ontology/views.py | 3 +-- submissions/managers.py | 4 ++++ submissions/views.py | 4 ++-- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/ontology/models.py b/ontology/models.py index 662e14048..c429495c8 100644 --- a/ontology/models.py +++ b/ontology/models.py @@ -3,6 +3,7 @@ __license__ = "AGPL v3" from django.db import models +from django.urls import reverse from .constants import TOPIC_RELATIONS_ASYM, TOPIC_RELATIONS_SYM @@ -27,7 +28,7 @@ class Topic(models.Model): """ name = models.CharField(max_length=256, unique=True) slug = models.SlugField(unique=True, allow_unicode=True) - tags = models.ManyToManyField(Tag, blank=True) + tags = models.ManyToManyField('ontology.Tag', blank=True) class Meta: ordering = ['name'] @@ -61,8 +62,6 @@ class RelationSym(models.Model): relation = models.CharField(max_length=32, choices=TOPIC_RELATIONS_SYM) def __str__(self): - text = '' - for topic in self.topics.all(): - text += '%s, ' % topic + text = ', '.join(self.topics.values_list('name', flat=True)) text += self.get_relation_display() return text diff --git a/ontology/templates/ontology/_topic_card.html b/ontology/templates/ontology/_topic_card.html index ff13e9153..0caa74a21 100644 --- a/ontology/templates/ontology/_topic_card.html +++ b/ontology/templates/ontology/_topic_card.html @@ -103,16 +103,12 @@ </div> <div class="card-body"> <ul> - {% for sub in topic.submission_set.public_newest %} - {% if not sub.publication and not sub.publication.is_published %} - <li> - <a href="{{ sub.get_absolute_url }}">{{ sub.title }}</a> - <br>by {{ sub.author_list }} - <br>(submitted {{ sub.submission_date|date:"Y-m-d" }} to {{ sub.get_submitted_to_journal_display }}) - </li> - {% else %} - <li>No Submission found</li> - {% endif %} + {% for sub in topic.submission_set.unpublished.public_newest %} + <li> + <a href="{{ sub.get_absolute_url }}">{{ sub.title }}</a> + <br>by {{ sub.author_list }} + <br>(submitted {{ sub.submission_date|date:"Y-m-d" }} to {{ sub.get_submitted_to_journal_display }}) + </li> {% empty %} <li>No Submission found</li> {% endfor %} diff --git a/ontology/templates/ontology/ontology.html b/ontology/templates/ontology/ontology.html index 7f88184d8..4f78199e0 100644 --- a/ontology/templates/ontology/ontology.html +++ b/ontology/templates/ontology/ontology.html @@ -27,11 +27,11 @@ Topics and their relations are defined by Editorial-level personnel. The ontology is used at many levels within SciPost, including but not limited to: <ul> - <li>identifying the best potential Editors-in-charge for incoming submissions</li> - <li>identifying thematic areas for which the editorial workforce should be increased</li> - <li>providing Editors-in-charge with referee suggestions</li> - <li>giving readers a way to identify interesting published content</li> - <li>assisting our internal metadata- and content-driven engines.</li> + <li>identifying the best potential Editors-in-charge for incoming submissions</li> + <li>identifying thematic areas for which the editorial workforce should be increased</li> + <li>providing Editors-in-charge with referee suggestions</li> + <li>giving readers a way to identify interesting published content</li> + <li>assisting our internal metadata- and content-driven engines.</li> </ul> </p> <p> diff --git a/ontology/views.py b/ontology/views.py index 06eaae5e2..b5fbbb88c 100644 --- a/ontology/views.py +++ b/ontology/views.py @@ -5,7 +5,6 @@ __license__ = "AGPL v3" from django.contrib import messages from django.core.urlresolvers import reverse, reverse_lazy from django.db.models import Q -from django.http import HttpResponse, HttpResponseServerError from django.shortcuts import get_object_or_404, redirect, render from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, UpdateView @@ -13,7 +12,7 @@ from django.views.generic.list import ListView from guardian.decorators import permission_required -from .models import Tag, Topic, RelationAsym, RelationSym +from .models import Tag, Topic, RelationAsym from .forms import SelectTagForm, SelectLinkedTopicForm, AddRelationAsymForm from scipost.forms import SearchTextForm diff --git a/submissions/managers.py b/submissions/managers.py index b723bdb6d..edb989349 100644 --- a/submissions/managers.py +++ b/submissions/managers.py @@ -177,6 +177,10 @@ class SubmissionQuerySet(models.QuerySet): """Return published Submissions.""" return self.filter(status=constants.STATUS_PUBLISHED) + def unpublished(self): + """Return unpublished Submissions.""" + return self.exclude(status=constants.STATUS_PUBLISHED) + def assignment_failed(self): """Return Submissions which have failed assignment.""" return self.filter(status=constants.STATUS_ASSIGNMENT_FAILED) diff --git a/submissions/views.py b/submissions/views.py index 86026817e..e80c5017d 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -537,7 +537,7 @@ def submission_add_topic(request, identifier_w_vn_nr): except: pass messages.success(request, 'Successfully linked Topic to this Submission') - return submission_detail(request, identifier_w_vn_nr) + return redirect(submission.get_absolute_url()) @permission_required('scipost.can_manage_ontology', raise_exception=True) @@ -558,7 +558,7 @@ def submission_remove_topic(request, identifier_w_vn_nr, slug): except: pass messages.success(request, 'Successfully removed Topic') - return submission_detail(request, identifier_w_vn_nr) + return redirect(submission.get_absolute_url()) @login_required -- GitLab