Skip to content

Commit

Permalink
Merge branch 'main' into fix/stop_yielding_network_in_certain_normali…
Browse files Browse the repository at this point in the history
…zers
  • Loading branch information
originalsouth authored Aug 29, 2024
2 parents f5e30d9 + b0d62b9 commit 299c3a8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
4 changes: 3 additions & 1 deletion rocky/assets/js/renderNormalizerOutputOOIs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { language, organization_code } from "./utils.js";
const htmlElement = document.getElementsByTagName("html")[0];
const language = htmlElement.getAttribute("lang");
const organization_code = htmlElement.getAttribute("data-organization-code");

const buttons = document.querySelectorAll(
".expando-button.normalizer-list-table-row",
Expand Down
5 changes: 0 additions & 5 deletions rocky/assets/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
const htmlElement = document.getElementsByTagName("html")[0];
const language = htmlElement.getAttribute("lang");
const organization_code = htmlElement.getAttribute("data-organization-code");

export { language, organization_code };
2 changes: 1 addition & 1 deletion rocky/katalogus/templates/partials/plugins_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<a href="{% url 'normalizers_list' organization.code view_type %}">{% translate "Normalizers" %}</a>
</li>
<li {% if active == "all" %}aria-current="page"{% endif %}>
<a href="{% url 'katalogus' organization.code view_type %}">{% translate "All" %}</a>
<a href="{% url 'all_plugins_list' organization.code view_type %}">{% translate "All" %}</a>
</li>
<li {% if active == "about-plugins" %}aria-current="page"{% endif %}>
<a href="{% url 'about_plugins' organization.code %}">{% translate "About plugins" %}</a>
Expand Down
12 changes: 9 additions & 3 deletions rocky/katalogus/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from django.urls import path

from katalogus.views.change_clearance_level import ChangeClearanceLevel
from katalogus.views.katalogus import AboutPluginsView, BoefjeListView, KATalogusView, NormalizerListView
from katalogus.views.katalogus import (
AboutPluginsView,
BoefjeListView,
KATalogusLandingView,
KATalogusView,
NormalizerListView,
)
from katalogus.views.katalogus_settings import ConfirmCloneSettingsView, KATalogusSettingsView
from katalogus.views.plugin_detail import BoefjeDetailView, NormalizerDetailView, PluginCoverImgView
from katalogus.views.plugin_enable_disable import PluginEnableDisableView
from katalogus.views.plugin_settings_add import PluginSettingsAddView
from katalogus.views.plugin_settings_delete import PluginSettingsDeleteView

urlpatterns = [
path("", BoefjeListView.as_view(), name="katalogus"),
path("view/<view_type>/", KATalogusView.as_view(), name="katalogus"),
path("", KATalogusLandingView.as_view(), name="katalogus"),
path(
"settings/",
KATalogusSettingsView.as_view(),
Expand All @@ -36,6 +41,7 @@
NormalizerListView.as_view(),
name="normalizers_list",
),
path("plugins/all/<view_type>/", KATalogusView.as_view(), name="all_plugins_list"),
path(
"plugins/about-plugins/",
AboutPluginsView.as_view(),
Expand Down
16 changes: 16 additions & 0 deletions rocky/katalogus/views/katalogus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Any

from account.mixins import OrganizationView
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import FormView, ListView, TemplateView
Expand All @@ -9,6 +11,20 @@
from katalogus.forms import KATalogusFilter


class KATalogusLandingView(OrganizationView):
"""
Landing page for KAT-alogus.
"""

def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
return redirect(
reverse(
"boefjes_list",
kwargs={"organization_code": self.organization.code, "view_type": self.kwargs.get("view_type", "grid")},
)
)


class BaseKATalogusView(OrganizationView, ListView, FormView):
form_class = KATalogusFilter

Expand Down
2 changes: 1 addition & 1 deletion rocky/rocky/templates/rest_framework/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"csrfToken": "{% if request %}{{ csrf_token }}{% endif %}"
}
</script>
<script src="{% static "rest_framework/js/jquery-3.5.1.min.js" %}" nonce="{{ request.csp_nonce }}"></script>
<script src="{% static "rest_framework/js/jquery-3.7.1.min.js" %}" nonce="{{ request.csp_nonce }}"></script>
<script src="{% static "rest_framework/js/ajax-form.js" %}" nonce="{{ request.csp_nonce }}"></script>
<script src="{% static "rest_framework/js/csrf.js" %}" nonce="{{ request.csp_nonce }}"></script>
<script src="{% static "rest_framework/js/bootstrap.min.js" %}" nonce="{{ request.csp_nonce }}"></script>
Expand Down
2 changes: 1 addition & 1 deletion rocky/rocky/templates/tasks/normalizers.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ <h1>{% translate "Normalizers" %}</h1>
{% block html_at_end_body %}
{{ block.super }}
{% compress js %}
<script type="module" src="{% static "js/renderNormalizerOutputOOIs.js" %}" nonce="{{ request.csp_nonce }}"></script>
<script src="{% static "js/renderNormalizerOutputOOIs.js" %}" nonce="{{ request.csp_nonce }}"></script>
{% endcompress %}
{% endblock html_at_end_body %}
2 changes: 1 addition & 1 deletion rocky/tests/katalogus/test_katalogus.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_katalogus_plugin_listing_no_enable_disable_perm(rf, client_member, mock
mock_requests.Client().get.return_value = mock_response
mock_response.json.return_value = get_plugins_data()

request = rf.get("/en/test/kat-alogus/")
request = rf.get("/en/test/kat-alogus/plugins/all/grid/")
request.resolver_match = resolve(request.path)
response = KATalogusView.as_view()(
setup_request(request, client_member.user), organization_code=client_member.organization.code
Expand Down

0 comments on commit 299c3a8

Please sign in to comment.