Skip to content

Commit

Permalink
Merge pull request #538 from Terralego/new_debug_panel
Browse files Browse the repository at this point in the history
New debug panel
  • Loading branch information
submarcos authored Feb 2, 2024
2 parents ae69101 + a4cd376 commit 9f8aa35
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 18 deletions.
2 changes: 1 addition & 1 deletion conf/nginx.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ server {

client_max_body_size 200M;

location ~ ^/(api|config|static_dj|media|base-layers|env.json) {
location ~ ^/(api|config|static_dj|media|base-layers|debug|__debug__|env.json) {
proxy_pass http://django;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
12 changes: 12 additions & 0 deletions docs/source/others/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Changelog
==========

2024.02.3 (2024-02-02)
---------------------------

**Breaking changes**

- To access new debug panel, you should add 'debug' exception in nginx configuration file.

**Improvements:**

- Split Config dashboard debug entries in another /debug/ panel.


2024.02.2 (2024-02-01)
---------------------------

Expand Down
2 changes: 1 addition & 1 deletion install/conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ server {
gzip_min_length 256;
gzip_comp_level 4;
client_max_body_size 100M;
location ~ ^/(api|config|base-layers|env.json) {
location ~ ^/(api|config|debug|base-layers|env.json) {
proxy_pass http://django;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
2 changes: 1 addition & 1 deletion project/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.02.2
2024.02.3
11 changes: 8 additions & 3 deletions project/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
from django.utils.translation import gettext_lazy as _

from project.accounts.models import FunctionalPermission, PermanentAccessToken, User
from project.admin import config_site

admin.site.index_title = f'{config.INSTANCE_TITLE}: {_("Debug panel")}'
admin.site.site_header = f'{config.INSTANCE_TITLE}: {_("Debug panel")}'
admin.site.index_title = _(f"Welcome to {config.INSTANCE_TITLE} debug interface.")

admin.site.site_header = f"{config.INSTANCE_TITLE}"
admin.site.index_title = _("Configuration panel / Debug")
admin.site.register(User)


Expand All @@ -25,9 +28,11 @@ def has_change_permission(self, request, obj=None):
return False


@admin.register(PermanentAccessToken)
class PermanentAccessTokenAdmin(admin.ModelAdmin):
list_display = ("id", "user", "created_at", "updated_at")
list_filter = ("user", "created_at", "updated_at")
search_fields = ("user__email", "token")
readonly_fields = ("token",)


config_site.register(PermanentAccessToken, PermanentAccessTokenAdmin)
12 changes: 12 additions & 0 deletions project/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from constance import config
from django.contrib.admin import AdminSite
from django.utils.translation import gettext as _


class ConfigSite(AdminSite):
site_header = _(f"{config.INSTANCE_TITLE}: {_('Configuration')}")
site_title = _(f"{config.INSTANCE_TITLE}: {_('Configuration')}")
index_title = _(f"Welcome to {config.INSTANCE_TITLE} configuration interface.")


config_site = ConfigSite(name="config_site")
4 changes: 2 additions & 2 deletions project/fixtures/initial.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@
"fields": {
"name": "Default",
"active": true,
"title": "Configuration TerraVisu",
"title": "",
"title_color": "#DDDDDD",
"title_visible": true,
"logo": "",
"logo_color": "#CCCCCC",
"logo_max_width": 400,
"logo_max_height": 100,
"logo_visible": true,
"logo_visible": false,
"favicon": "",
"env_name": "",
"env_color": "#E74C3C",
Expand Down
12 changes: 10 additions & 2 deletions project/locales/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-01 15:13+0000\n"
"POT-Creation-Date: 2024-02-02 09:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -18,7 +18,8 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "Configuration panel / Debug"
#, python-brace-format
msgid "Welcome to {config.INSTANCE_TITLE} debug interface."
msgstr ""

msgid "Accounts"
Expand Down Expand Up @@ -92,6 +93,13 @@ msgstr ""
msgid "OIDC connect"
msgstr ""

msgid "{config.INSTANCE_TITLE}: {_('Configuration')}"
msgstr ""

#, python-brace-format
msgid "Welcome to {config.INSTANCE_TITLE} configuration interface."
msgstr ""

msgid "Instance customization"
msgstr ""

Expand Down
16 changes: 12 additions & 4 deletions project/locales/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-01 15:13+0000\n"
"POT-Creation-Date: 2024-02-02 09:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -18,11 +18,12 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

msgid "Configuration panel / Debug"
msgstr "Panneau de configuration / Debug"
#, python-brace-format
msgid "Welcome to {config.INSTANCE_TITLE} debug interface."
msgstr "Bienvenue sur l'interface de debug de {config.INSTANCE_TITLE}."

msgid "Accounts"
msgstr ""
msgstr "Comptes"

msgid "Is able to create, delete, update users"
msgstr "Peut créer, supprimer, mettre à jour des utilisateurs"
Expand Down Expand Up @@ -94,6 +95,13 @@ msgstr "Mot de passe oublié ?"
msgid "OIDC connect"
msgstr "Connexion via OIDC"

msgid "{config.INSTANCE_TITLE}: {_('Configuration')}"
msgstr "{config.INSTANCE_TITLE} : {_('Configuration')}"

#, python-brace-format
msgid "Welcome to {config.INSTANCE_TITLE} configuration interface."
msgstr "Bienvenue sur l'interface de configuration de {config.INSTANCE_TITLE}."

msgid "Instance customization"
msgstr "Personnalisation de l'instance"

Expand Down
1 change: 1 addition & 0 deletions project/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
PROJECT_DIR / "project" / "templates",
PROJECT_DIR / "var" / "conf" / "templates",
],
"APP_DIRS": True,
Expand Down
12 changes: 12 additions & 0 deletions project/templates/admin/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "admin/base.html" %}

{% block userlinks %}
{% if user.is_superuser and request.path|slice:":7" != "/debug/" %}
<a href="/debug/">Debug</a> /
{% endif %}
{% if request.path|slice:":8" != "/config/" %}
<a href="/config/">Config</a> /
{% endif %}
<a href="/admin/">Admin</a> /
{{ block.super }}
{% endblock %}
2 changes: 1 addition & 1 deletion project/terra_layer/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def setUp(self):
self.client.force_login(self.user)

def test_list(self):
response = self.client.get("/config/terra_layer/layer/")
response = self.client.get("/debug/terra_layer/layer/")
self.assertEqual(response.status_code, 200)
4 changes: 3 additions & 1 deletion project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rest_framework.routers import SimpleRouter

from project.accounts.api import FunctionalPermissionViewSet, GroupViewSet, UserViewsSet
from project.admin import config_site
from project.terra_layer.views.extras import BaseLayerViewSet

router = SimpleRouter()
Expand All @@ -25,7 +26,8 @@
urlpatterns = [
path("tinymce/", include("tinymce.urls")),
path("config/clearcache/", include("clearcache.urls")),
path("config/", admin.site.urls),
path("config/", config_site.urls),
path("debug/", admin.site.urls),
path("oidc/", include("django_auth_oidc.urls")),
path("accounts/", include("django.contrib.auth.urls")),
path("base-layers/", include("mapbox_baselayer.urls")),
Expand Down
12 changes: 10 additions & 2 deletions project/visu/admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from admin_interface.admin import ThemeAdmin
from admin_interface.models import Theme
from constance.admin import Config, ConstanceAdmin
from django.contrib import admin

from project.admin import config_site
from project.visu.models import ExtraMenuItem, SpriteValue


@admin.register(ExtraMenuItem)
class ExtraMenuItemAdmin(admin.ModelAdmin):
list_display = ("label", "slug", "href", "icon")


admin.site.register(SpriteValue)
config_site.register(SpriteValue)
config_site.register(ExtraMenuItem, ExtraMenuItemAdmin)
admin.site.unregister([Config])
config_site.register([Config], ConstanceAdmin)
admin.site.unregister(Theme)
config_site.register(Theme, ThemeAdmin)

0 comments on commit 9f8aa35

Please sign in to comment.