diff --git a/journals/constants.py b/journals/constants.py index c98733fee0caad1c76a0ef162e7d9d498e92e375..529c204ef05a223473c915cee4cca47717b6fc6f 100644 --- a/journals/constants.py +++ b/journals/constants.py @@ -85,8 +85,7 @@ CC_LICENSES = ( CC_LICENSES_URI = ( (CCBY4, 'https://creativecommons.org/licenses/by/4.0'), (CCBYSA4, 'https://creativecommons.org/licenses/by-sa/4.0'), - (CCBYNC4, 'https://creativecommons.org/licenses/by-nc/4.0'), - ) + (CCBYNC4, 'https://creativecommons.org/licenses/by-nc/4.0')) ISSUES_AND_VOLUMES = 'IV' diff --git a/scipost/models.py b/scipost/models.py index d5bc608c42a3a3d4eca6b37aab37128958c259d9..b99afdeacac52a98389b56397444d5970a738eb4 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -285,7 +285,7 @@ class PrecookedEmail(models.Model): ###################### class EditorialCollege(models.Model): - '''A SciPost Editorial College for a specific discipline.''' + """A SciPost Editorial College for a specific discipline.""" discipline = models.CharField(max_length=255, unique=True) def __str__(self): diff --git a/scipost/templates/scipost/about.html b/scipost/templates/scipost/about.html index 240f766f7476fcdf8a2006b71fd915ac8ecb9dc2..1840b0a4dbcdc2d922fa48be8e27993178b7c74a 100644 --- a/scipost/templates/scipost/about.html +++ b/scipost/templates/scipost/about.html @@ -125,22 +125,22 @@ <hr> -{% for college, codes in object_list %} - <h2 class="highlight" id="editorial_college_{{ college|lower }}">Editorial College ({{ college }})</h2> +{% for discipline,fellowships in disciplines.items %} +{#{% for college, codes in object_list %}#} + <h2 class="highlight" id="editorial_college_{{ discipline|lower }}">Editorial College ({{ discipline }})</h2> - {% if codes %} <div class="row"> <div class="col-12"> - <a href="#editorial_college_{{ college|lower }}" class="mx-2" data-toggle="toggle-show" data-target="#specializations-{{college|lower}}">Show Fellows by specialization</a> - <a href="#editorial_college_{{ college|lower }}" class="mx-2" style="display: none;" data-toggle="toggle-show" data-target="#specializations-{{college|lower}}">Show full list of Fellows</a> - <div id="specializations-{{college|lower}}" class="card bg-white border-default all-specializations mt-2" style="display: none"> + <a href="#editorial_college_{{ discipline|lower }}" class="mx-2" data-toggle="toggle-show" data-target="#specializations-{{discipline|lower}}">Show Fellows by specialization</a> + <a href="#editorial_college_{{ discipline|lower }}" class="mx-2" style="display: none;" data-toggle="toggle-show" data-target="#specializations-{{discipline|lower}}">Show full list of Fellows</a> + <div id="specializations-{{ discipline|lower }}" class="card bg-white border-default all-specializations mt-2" style="display: none"> <div class="card-body"> <p class="text-muted mt-2">Hover to highlight or click to select</p> <div class="row"> <div class="col-md-6"> - {% with total_count=codes|length %} - {% for code in codes %} + {% with total_count=fellowships.1|length %} + {% for code in fellowships.1 %} <div class="specialization" data-specialization="{{code.0|lower}}">{{code.0}} - {{code.1}}</div> {% if forloop.counter|is_modulo_one_half:total_count %} </div> @@ -154,12 +154,11 @@ </div> </div> </div> - {% endif %} - <div class="row search-contributors" data-contributors="{{ college|lower }}"> + <div class="row search-contributors" data-contributors="{{ discipline|lower }}"> <div class="col-12"> <div class="card-columns"> - {% for fellowship in college.current_fellows %} + {% for fellowship in fellowships.0 %} <div class="card bg-white contributor mb-1"> {% include 'scipost/_contributor_short.html' with contributor=fellowship.contributor %} </div> diff --git a/scipost/views.py b/scipost/views.py index 915df08f3fa3e0bfdc34fbef5b55fdda1e969eb5..9e4ee6cb791cb4bb3db7b6c3e3e199cfbd375f63 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -30,7 +30,8 @@ from guardian.decorators import permission_required from haystack.generic_views import SearchView from .constants import ( - SCIPOST_SUBJECT_AREAS, subject_areas_raw_dict, SciPost_from_addresses_dict, NORMAL_CONTRIBUTOR) + SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS, subject_areas_raw_dict, + SciPost_from_addresses_dict, NORMAL_CONTRIBUTOR) from .decorators import has_contributor, is_contributor_user from .models import ( Contributor, UnavailabilityPeriod, AuthorshipClaim, EditorialCollege, @@ -43,6 +44,7 @@ from .utils import Utils, EMAIL_FOOTER, SCIPOST_SUMMARY_FOOTER, SCIPOST_SUMMARY_ from affiliations.forms import AffiliationsFormset from colleges.permissions import fellowship_or_admin_required +from colleges.models import Fellowship from commentaries.models import Commentary from comments.models import Comment from invitations.constants import STATUS_REGISTERED @@ -1060,34 +1062,26 @@ def Fellow_activity_overview(request): class AboutView(ListView): + """Basic information page with stream of current regular Fellows.""" + model = EditorialCollege template_name = 'scipost/about.html' - queryset = EditorialCollege.objects.prefetch_related( - Prefetch('fellowships', - queryset=EditorialCollegeFellowship.objects.active().select_related( - 'contributor__user').order_by('contributor__user__last_name'), - to_attr='current_fellows')) + queryset = Fellowship.objects.none() def get_context_data(self, *args, **kwargs): + """Save Fellowships per discipline to the context.""" context = super().get_context_data(*args, **kwargs) - object_list = [] - for college in context['object_list']: - try: - spec_list = subject_areas_raw_dict[str(college)] - except KeyError: - spec_list = None - object_list.append(( - college, - spec_list, - )) - context['object_list'] = object_list + context['disciplines'] = {} + for discipline in SCIPOST_DISCIPLINES: + qs = Fellowship.objects.active().regular().filter( + contributor__discipline=discipline[0]) + if qs: + context['disciplines'][discipline[1]] = (qs, subject_areas_raw_dict[discipline[1]]) return context -def csrf_failure(request, reason=""): - """ - Custom CSRF Failure. Informing admins via email as well. - """ +def csrf_failure(request, reason=''): + """CSRF Failure page with an admin mailing action.""" # Filter out privacy data post_data = {} for key in request.POST.keys():