diff --git a/scipost_django/scipost/management/commands/add_groups_and_permissions.py b/scipost_django/scipost/management/commands/add_groups_and_permissions.py index 4311644b536c0f06e6d129d409416833e21e6851..5259a7690c0e836d97dfeb39d97e134c1d03d331 100644 --- a/scipost_django/scipost/management/commands/add_groups_and_permissions.py +++ b/scipost_django/scipost/management/commands/add_groups_and_permissions.py @@ -26,6 +26,7 @@ class Command(BaseCommand): name='Registered Contributors') Developers, created = Group.objects.get_or_create(name='Developers') Testers, created = Group.objects.get_or_create(name='Testers') + Previewers, created = Group.objects.get_or_create(name='Previewers') NewsAdmin, created = Group.objects.get_or_create(name='News Administrators') Ambassadors, created = Group.objects.get_or_create(name='Ambassadors') JuniorAmbassadors, created = Group.objects.get_or_create(name='Junior Ambassadors') @@ -311,6 +312,11 @@ class Command(BaseCommand): name='Can manage ontology', content_type=content_type) + # Previewing new features + can_preview_new_features, created = Permission.objects.get_or_create( + codename='can_preview_new_features', + name='Can preview new features', + content_type=content_type) # Assign permissions to groups SciPostAdmin.permissions.set([ @@ -428,6 +434,10 @@ class Command(BaseCommand): can_view_docs_scipost, ]) + Previewers.permissions.set([ + can_preview_new_features, + ]) + Ambassadors.permissions.set([ can_create_registration_invitations, can_manage_registration_invitations, diff --git a/scipost_django/scipost/templates/scipost/index_alt.html b/scipost_django/scipost/templates/scipost/index3.html similarity index 94% rename from scipost_django/scipost/templates/scipost/index_alt.html rename to scipost_django/scipost/templates/scipost/index3.html index 2ccc70bf0c6445f455d5152ef1e04eacfd4f67c6..8a2120a203b48e2dd1c7e8179fa21cdea89c55cc 100644 --- a/scipost_django/scipost/templates/scipost/index_alt.html +++ b/scipost_django/scipost/templates/scipost/index3.html @@ -1,9 +1,9 @@ {% extends 'scipost/base.html' %} {% block headsup %} -<link rel="preconnect" href="https://fonts.googleapis.com"> -<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> -<link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans:wght@300;400;500;600&display=swap" rel="stylesheet"> + <link rel="preconnect" href="https://fonts.googleapis.com"> + <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> + <link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans:wght@300;400;500;600&display=swap" rel="stylesheet"> {% endblock headsup %} {% load render_bundle from webpack_loader %} @@ -14,6 +14,10 @@ {% block meta_description %}{{ block.super }} homepage{% endblock meta_description %} {% block pagetitle %}Homepage{% endblock pagetitle %} +{% block navbar %} + {% include 'scipost/navbar2.html' %} +{% endblock %} + {% block content %} <div class="row"> <div class="col-12"> diff --git a/scipost_django/scipost/templates/scipost/navbar2.html b/scipost_django/scipost/templates/scipost/navbar2.html index 924d734d858c191398824738ab872cd75246ab00..1e5bbbd076385a1082d88b242ae483f00cfb5c1f 100644 --- a/scipost_django/scipost/templates/scipost/navbar2.html +++ b/scipost_django/scipost/templates/scipost/navbar2.html @@ -17,6 +17,26 @@ <div class="collapse navbar-collapse mt-lg-0 mt-3" id="main-navbar"> <ul class="navbar-nav me-auto"> + {% if perms.scipost.can_preview_new_features %} + <li class="nav-item dropdown border border-warning"> + <a class="nav-link dropdown-toggle" href="#" id="HomepagesDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-trigger="hover"> + <span class="d-none d-lg-inline-block text-warning" aria-hidden="true" style="min-width: 16px;">{% include 'bi/house-fill.html' %}</span> + <span class="d-lg-none d-inline-block text-warning">Homepages</span> + </a> + <div class="dropdown-menu" aria-labelledby="HomepagesDropdown"> + <div class="dropdown-item"> + <a href="{% url 'scipost:index' %}">Current homepage</a> + </div> + <div class="dropdown-item"> + <a href="{% url 'scipost:index2' %}">2: home + portal</a> + </div> + <div class="dropdown-item"> + <a href="{% url 'scipost:index3' %}">3: homepage, restyled</a> + </div> + </div> + </li> + {% endif %} + <li class="nav-item{% if request.path == '/home2' %} active{% endif %}"> <a href="{% url 'scipost:index2' %}" class="nav-link" aria-label="SciPost Home"> <span class="d-none d-lg-inline-block" aria-hidden="true" style="min-width: 16px;">{% include 'bi/house-fill.html' %}</span> diff --git a/scipost_django/scipost/urls.py b/scipost_django/scipost/urls.py index e8765a3ec2b5e3f508fbd23135043fe5af799cf2..6f1ad700bb669dbba300a57d0741832923c33c43 100644 --- a/scipost_django/scipost/urls.py +++ b/scipost_django/scipost/urls.py @@ -80,8 +80,8 @@ urlpatterns = [ name='index2' ), path( - 'home_alt', - views.index_alt, name='index-alt' + 'home3', + views.index3, name='index3' ), # Portal diff --git a/scipost_django/scipost/views.py b/scipost_django/scipost/views.py index 15878d7748f59ccb85b742486980e84101f6fefc..8778397a75406c32c0c4bbe349f3f64294b2d801 100644 --- a/scipost_django/scipost/views.py +++ b/scipost_django/scipost/views.py @@ -177,7 +177,7 @@ def index(request): return render(request, 'scipost/index.html', context) -@login_required +@permission_required('scipost.can_preview_new_features', return_403=True) def index2(request): """Homepage view of SciPost.""" if NewsItem.objects.homepage().exists(): @@ -190,7 +190,7 @@ def index2(request): return render(request, 'scipost/index2.html', context) -@login_required +@permission_required('scipost.can_preview_new_features', return_403=True) def portal(request): """ Academic portal entryway. @@ -377,8 +377,8 @@ def _hx_sponsors(request): return render(request, 'scipost/_hx_sponsors.html', context) -@login_required -def index_alt(request): +@permission_required('scipost.can_preview_new_features', return_403=True) +def index3(request): """Homepage view of SciPost.""" context = { 'news_items': NewsItem.objects.homepage().order_by('-date')[:4], @@ -386,7 +386,7 @@ def index_alt(request): '-paper_nr')[:10], 'current_sponsors': Organization.objects.current_sponsors().order_by('?')[:2] } - return render(request, 'scipost/index_alt.html', context) + return render(request, 'scipost/index3.html', context) def protected_serve(request, path, show_indexes=False):