From 762763cf00651526b798e70995eaf320d4275e97 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 16 Apr 2023 01:00:32 +0200 Subject: Add a README to the staff app Plus minor refactorings --- pydis_site/apps/staff/README.md | 19 +++++++++++++++++++ .../apps/staff/templatetags/deletedmessage_filters.py | 2 +- pydis_site/apps/staff/urls.py | 2 +- pydis_site/apps/staff/views.py | 11 +++++++++++ pydis_site/apps/staff/viewsets/__init__.py | 3 --- pydis_site/apps/staff/viewsets/logs.py | 11 ----------- 6 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 pydis_site/apps/staff/README.md create mode 100644 pydis_site/apps/staff/views.py delete mode 100644 pydis_site/apps/staff/viewsets/__init__.py delete mode 100644 pydis_site/apps/staff/viewsets/logs.py (limited to 'pydis_site') diff --git a/pydis_site/apps/staff/README.md b/pydis_site/apps/staff/README.md new file mode 100644 index 00000000..db263e5e --- /dev/null +++ b/pydis_site/apps/staff/README.md @@ -0,0 +1,19 @@ +# The "staff" app + +This Django application hosts any staff-internal tooling, which, at time of +writing, only is an endpoint to view logs uploaded by the Python bot. + +This app mainly interacts with a single model from the `api` app, and has no +models on its own. The following files and directories are of interest: + +- [`templatetags`](./templatetags) contains custom template tags that help with + formatting the HTML templates of this app (these can be found in the template + root direcetory). + +- [`tests`](./tests) contains standard Django unit tests that validate both the + template tags and functionality of the log viewer itself. + +- [`urls.py`](./urls.py) contains the regular Django URL routing logic. + +- [`views.py`](./views.py) contains standard Django views. In our case, the + main work happens in the template, so this is relatively straightforward. diff --git a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py index 5026068e..9d8f1819 100644 --- a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py +++ b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py @@ -28,5 +28,5 @@ def footer_datetime(timestamp: str) -> datetime: @register.filter def visible_newlines(text: str) -> str: - """Takes an embed timestamp and returns a timezone-aware datetime object.""" + """Visualizes newlines in text by replacing them with a grey-ish `↵`.""" return text.replace("\n", "
") diff --git a/pydis_site/apps/staff/urls.py b/pydis_site/apps/staff/urls.py index ca8d1a0f..0565592b 100644 --- a/pydis_site/apps/staff/urls.py +++ b/pydis_site/apps/staff/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .viewsets import LogView +from .views import LogView app_name = 'staff' urlpatterns = [ diff --git a/pydis_site/apps/staff/views.py b/pydis_site/apps/staff/views.py new file mode 100644 index 00000000..22dede95 --- /dev/null +++ b/pydis_site/apps/staff/views.py @@ -0,0 +1,11 @@ +from django.views.generic.detail import DetailView + +from pydis_site.apps.api.models.bot.message_deletion_context import MessageDeletionContext + + +class LogView(DetailView): + """The default view for the Deleted Messages logs.""" + + model = MessageDeletionContext + context_object_name = "deletion_context" + template_name = "staff/logs.html" diff --git a/pydis_site/apps/staff/viewsets/__init__.py b/pydis_site/apps/staff/viewsets/__init__.py deleted file mode 100644 index 6b10eb83..00000000 --- a/pydis_site/apps/staff/viewsets/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .logs import LogView - -__all__ = ["LogView"] diff --git a/pydis_site/apps/staff/viewsets/logs.py b/pydis_site/apps/staff/viewsets/logs.py deleted file mode 100644 index 22dede95..00000000 --- a/pydis_site/apps/staff/viewsets/logs.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.views.generic.detail import DetailView - -from pydis_site.apps.api.models.bot.message_deletion_context import MessageDeletionContext - - -class LogView(DetailView): - """The default view for the Deleted Messages logs.""" - - model = MessageDeletionContext - context_object_name = "deletion_context" - template_name = "staff/logs.html" -- cgit v1.2.3