From e24a748631e2a2e7ad3b60679ea8b837a8faae21 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Mon, 23 Sep 2019 16:32:25 +0200 Subject: [PATCH] Add discipline to Journal; modify Journals navbar menu item --- journals/context_processors.py | 6 ++- .../migrations/0075_journal_discipline.py | 18 ++++++++ journals/models/journal.py | 4 +- journals/templates/journals/base.html | 1 - scipost/constants.py | 4 +- scipost/templates/scipost/navbar.html | 41 ++++++++++++------- 6 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 journals/migrations/0075_journal_discipline.py diff --git a/journals/context_processors.py b/journals/context_processors.py index 3904ea33a..a1569fba3 100644 --- a/journals/context_processors.py +++ b/journals/context_processors.py @@ -1,9 +1,13 @@ __copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" +from scipost.constants import SCIPOST_DISCIPLINES from .models import Journal def journals_processor(request): """Append all Journals to the context of all views.""" - return {'journals': Journal.objects.order_by('name')} + return { + 'disciplines': SCIPOST_DISCIPLINES, + 'journals': Journal.objects.order_by('name') + } diff --git a/journals/migrations/0075_journal_discipline.py b/journals/migrations/0075_journal_discipline.py new file mode 100644 index 000000000..61cfb4071 --- /dev/null +++ b/journals/migrations/0075_journal_discipline.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.8 on 2019-09-23 09:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('journals', '0074_journal_style'), + ] + + operations = [ + migrations.AddField( + model_name='journal', + name='discipline', + field=models.CharField(choices=[('physics', 'Physics'), ('astrophysics', 'Astrophysics'), ('chemistry', 'Chemistry'), ('mathematics', 'Mathematics'), ('computerscience', 'Computer Science')], default='physics', max_length=20), + ), + ] diff --git a/journals/models/journal.py b/journals/models/journal.py index d974ad767..efed46122 100644 --- a/journals/models/journal.py +++ b/journals/models/journal.py @@ -4,11 +4,12 @@ __license__ = "AGPL v3" import datetime -from django.contrib.postgres.fields import JSONField from django.db import models from django.db.models import Avg, F from django.urls import reverse +from scipost.constants import SCIPOST_DISCIPLINES + from ..constants import JOURNAL_STRUCTURE, ISSUES_AND_VOLUMES, ISSUES_ONLY from ..managers import JournalQuerySet from ..validators import doi_journal_validator @@ -20,6 +21,7 @@ class Journal(models.Model): Publications may be categorized into issues or issues and volumes. """ + discipline = models.CharField(max_length=20, choices=SCIPOST_DISCIPLINES, default='physics') name = models.CharField(max_length=256, unique=True) name_abbrev = models.CharField(max_length=128, default='SciPost [abbrev]', help_text='Abbreviated name (for use in citations)') diff --git a/journals/templates/journals/base.html b/journals/templates/journals/base.html index f650eea44..00285c0e4 100644 --- a/journals/templates/journals/base.html +++ b/journals/templates/journals/base.html @@ -34,7 +34,6 @@ <li><a href="{{ journal.get_absolute_url }}">Home</a></li> <li><a class="{% block link_class_physics_info %}{% endblock %}" href="{% url 'journal:info_for_authors' journal.doi_label %}">Info for authors</a></li> <li><a href="{% url 'submissions:submit_manuscript' %}">Submit a manuscript</a></li> - <li><a href="{% url 'scipost:about' %}#editorial_college_physics">Editorial College</a></li> <li><a class="{% block link_class_physics_about %}{% endblock %}" href="{% url 'journal:about' journal.doi_label %}">About</a></li> </ul> </div> diff --git a/scipost/constants.py b/scipost/constants.py index 0c5772dc3..d892bc716 100644 --- a/scipost/constants.py +++ b/scipost/constants.py @@ -5,13 +5,13 @@ __license__ = "AGPL v3" DISCIPLINE_PHYSICS = 'physics' DISCIPLINE_ASTROPHYSICS = 'astrophysics' DISCIPLINE_CHEMISTRY = 'chemistry' -DISCIPLINE_MATH = 'mathematics' +DISCIPLINE_MATHEMATICS = 'mathematics' DISCIPLINE_COMPUTERSCIENCE = 'computerscience' SCIPOST_DISCIPLINES = ( (DISCIPLINE_PHYSICS, 'Physics'), (DISCIPLINE_ASTROPHYSICS, 'Astrophysics'), (DISCIPLINE_CHEMISTRY, 'Chemistry'), - (DISCIPLINE_MATH, 'Mathematics'), + (DISCIPLINE_MATHEMATICS, 'Mathematics'), (DISCIPLINE_COMPUTERSCIENCE, 'Computer Science'), ) diff --git a/scipost/templates/scipost/navbar.html b/scipost/templates/scipost/navbar.html index 6a120da10..35fb66c3c 100644 --- a/scipost/templates/scipost/navbar.html +++ b/scipost/templates/scipost/navbar.html @@ -39,20 +39,33 @@ </div> </div> <div class="dropdown-divider"></div> - <span class="dropdown-item dropdown-headline"><strong>Physics</strong></span> - {% for journal in journals %} - {% if journal.active %} - <div class="dropdown-item"> - <a href="{{ journal.get_absolute_url }}">{{ journal.name }}</a> - <i class="fa fa-angle-right" aria-hidden="true"></i> - </div> - {% elif perms.scipost.can_view_pool %} - <div class="dropdown-item"> - <a href="{% url 'journal:about' journal.doi_label %}">{{ journal.name }}</a> - <i class="fa fa-angle-right" aria-hidden="true"></i> - </div> - {% endif %} - {% endfor %} + {% for discipline in disciplines %} + <div class="row"> + <div class="col-md-4"> + <span class="dropdown-time dropdown-headline"><strong>{{ discipline.1 }}</strong></span> + </div> + <div class="col-md-8"> + {% for journal in journals %} + {% if journal.discipline == discipline.0 %} + {% if journal.active %} + <div class="dropdown-item"> + <a href="{{ journal.get_absolute_url }}">{{ journal.name }}</a> + <i class="fa fa-angle-right" aria-hidden="true"></i> + </div> + {% elif perms.scipost.can_view_pool %} + <div class="dropdown-item"> + <a href="{% url 'journal:about' journal.doi_label %}">{{ journal.name }}</a> + <i class="fa fa-angle-right" aria-hidden="true"></i> + </div> + {% endif %} + {% endif %} + {% endfor %} + </div> + </div> + {% if not forloop.last %} + <div class="dropdown-divider"></div> + {% endif %} + {% endfor %} </div> </li> <li class="nav-item{% if '/submissions/' in request.path %} active{% endif %} dropdown"> -- GitLab