-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
124 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import django_tables2 as tables | ||
from . import models | ||
from django_tables2.utils import A | ||
|
||
|
||
class PortalTable(tables.Table): | ||
title = tables.LinkColumn("maps:portal-preview", kwargs={"slug": A("uuid")}) | ||
|
||
class Meta: | ||
model = models.Portal | ||
fields = ( | ||
"title", | ||
"uuid", | ||
"visibility", | ||
"owner", | ||
) | ||
template_name = "django_tables2/bootstrap.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
from ninja import NinjaAPI | ||
from django.urls import path | ||
|
||
from .apis import maps_router | ||
from .views import ConfigJSView, PortalListPage, PortalPreview | ||
|
||
api = NinjaAPI() | ||
api.add_router("/maps/", maps_router) | ||
app_name = "maps" | ||
|
||
urlpatterns = [ | ||
path( | ||
"<uuid:slug>/preview/config.js", | ||
ConfigJSView.as_view(), | ||
name="portal-preview-config", | ||
), | ||
path( | ||
"<uuid:slug>/preview/", | ||
PortalPreview.as_view(), | ||
name="portal-preview", | ||
), | ||
path("", PortalListPage.as_view(), name="portals-list"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.views.generic import DetailView, TemplateView | ||
from django_tables2.views import SingleTableMixin | ||
from django_filters.views import FilterView | ||
|
||
from .models import Portal, Visibility | ||
from metadata_catalogue.maps import filters, tables | ||
|
||
|
||
class ConfigJSView(DetailView): | ||
model = Portal | ||
template_name = "maps/config.js" | ||
content_type = "application/javascript" | ||
slug_field = "uuid" | ||
|
||
|
||
class PortalPreview(TemplateView): | ||
""" | ||
This is a placeholder, the frontend app will proxied | ||
""" | ||
|
||
template_name = "404.html" | ||
|
||
|
||
class PortalListPage(SingleTableMixin, FilterView): | ||
model = Portal | ||
table_class = tables.PortalTable | ||
filterset_class = filters.PortalFilter | ||
template_name = "maps/portal_list.html" | ||
|
||
def get_queryset(self): | ||
qs = super().get_queryset() | ||
|
||
if not self.request.user.is_authenticated: | ||
qs = qs.filter(visibility=Visibility.PUBLIC) | ||
|
||
return qs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const BASE_URL = window.location.origin; | ||
|
||
window.API_URL = `/api/v1/`; | ||
window.PORTAL_KEY = "{{ object.uuid }}"; | ||
window.BASE_PATH = "{% url 'maps:portal-preview' slug=object.uuid %}"; | ||
|
||
window.TRANSFORM_REQUEST = (url, resourceType) => { | ||
if (resourceType === "Style" && url.startsWith(BASE_URL)) { | ||
return { | ||
url: url, | ||
credentials: "include", | ||
}; | ||
} | ||
}; | ||
|
||
window.PLAUSIBLE = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends 'app.html' %} | ||
|
||
{% load render_table from django_tables2 %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block article %} | ||
<div> | ||
<div class="flex my-5 justify-between items-center"> | ||
<h1 class="font-bold text-4xl">Map portals</h1> | ||
</div> | ||
{% if filter %} | ||
<form action="" method="get" class="flex gap-8"> | ||
{% crispy filter.form %} | ||
</form> | ||
{% endif %} | ||
{% render_table table %} | ||
</div> | ||
{% endblock article %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,7 @@ | |
select { | ||
@apply pr-8 !important; | ||
} | ||
|
||
a { | ||
@apply link link-primary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters