diff options
author | 2019-08-15 11:28:25 +0200 | |
---|---|---|
committer | 2019-08-23 15:40:51 +0200 | |
commit | dc2a771c994c5a7dad3b8453270ca2bfb74a414b (patch) | |
tree | 9ed21a520802af37ab1d8b6c30870a7ec20e9b1c | |
parent | Merge pull request #236 from python-discord/django-roles-api-add-position (diff) |
Adding initial staff app to Django
-rw-r--r-- | pydis_site/apps/staff/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/staff/apps.py | 7 | ||||
-rw-r--r-- | pydis_site/apps/staff/migrations/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/staff/models/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/staff/tests/__init__.py | 0 | ||||
-rw-r--r-- | pydis_site/apps/staff/urls.py | 12 | ||||
-rw-r--r-- | pydis_site/apps/staff/viewsets/__init__.py | 3 | ||||
-rw-r--r-- | pydis_site/apps/staff/viewsets/logs.py | 14 | ||||
-rw-r--r-- | pydis_site/hosts.py | 1 | ||||
-rw-r--r-- | pydis_site/settings.py | 1 | ||||
-rw-r--r-- | pydis_site/templates/staff/logs.html | 15 | ||||
-rw-r--r-- | pydis_site/urls.py | 1 |
12 files changed, 54 insertions, 0 deletions
diff --git a/pydis_site/apps/staff/__init__.py b/pydis_site/apps/staff/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_site/apps/staff/__init__.py diff --git a/pydis_site/apps/staff/apps.py b/pydis_site/apps/staff/apps.py new file mode 100644 index 00000000..fb8bda03 --- /dev/null +++ b/pydis_site/apps/staff/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig + + +class StaffConfig(AppConfig): + """Django AppConfig for the staff app.""" + + name = 'staff'
\ No newline at end of file diff --git a/pydis_site/apps/staff/migrations/__init__.py b/pydis_site/apps/staff/migrations/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_site/apps/staff/migrations/__init__.py diff --git a/pydis_site/apps/staff/models/__init__.py b/pydis_site/apps/staff/models/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_site/apps/staff/models/__init__.py diff --git a/pydis_site/apps/staff/tests/__init__.py b/pydis_site/apps/staff/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/pydis_site/apps/staff/tests/__init__.py diff --git a/pydis_site/apps/staff/urls.py b/pydis_site/apps/staff/urls.py new file mode 100644 index 00000000..95b3caf3 --- /dev/null +++ b/pydis_site/apps/staff/urls.py @@ -0,0 +1,12 @@ +from django.conf import settings +from django.conf.urls.static import static +from django.contrib import admin +from django.urls import include, path + +from .viewsets import LogView + +app_name = 'staff' +urlpatterns = [ + path('bot/logs/<int:pk>/', LogView.as_view(), name="logs"), + path('admin/', admin.site.urls), +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/pydis_site/apps/staff/viewsets/__init__.py b/pydis_site/apps/staff/viewsets/__init__.py new file mode 100644 index 00000000..ccb57d43 --- /dev/null +++ b/pydis_site/apps/staff/viewsets/__init__.py @@ -0,0 +1,3 @@ +from .logs import LogView + +__all__ = ["LogView"]
\ No newline at end of file diff --git a/pydis_site/apps/staff/viewsets/logs.py b/pydis_site/apps/staff/viewsets/logs.py new file mode 100644 index 00000000..38f8bf1d --- /dev/null +++ b/pydis_site/apps/staff/viewsets/logs.py @@ -0,0 +1,14 @@ +from django.core.handlers.wsgi import WSGIRequest +from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render +from django.views import View + +from pydis_site.apps.api.models.bot.message_deletion_context import MessageDeletionContext + + +class LogView(View): + template_name = "staff/logs.html" + + def get(self, request: WSGIRequest, pk: int) -> HttpResponse: + message_context = get_object_or_404(MessageDeletionContext, pk=pk) + return render(request, self.template_name, {"message_context": message_context}) diff --git a/pydis_site/hosts.py b/pydis_site/hosts.py index 0fa4793d..898e8cdc 100644 --- a/pydis_site/hosts.py +++ b/pydis_site/hosts.py @@ -5,5 +5,6 @@ host_patterns = patterns( '', host(r'admin', 'pydis_site.apps.admin.urls', name="admin"), host(r'api', 'pydis_site.apps.api.urls', name='api'), + host(r'staff', 'pydis_site.apps.staff.urls', name='staff'), host(r'.*', 'pydis_site.apps.home.urls', name=settings.DEFAULT_HOST) ) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 4a4eb94b..d3b371b6 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -63,6 +63,7 @@ else: INSTALLED_APPS = [ 'pydis_site.apps.api', 'pydis_site.apps.home', + 'pydis_site.apps.staff', 'django.contrib.admin', 'django.contrib.auth', diff --git a/pydis_site/templates/staff/logs.html b/pydis_site/templates/staff/logs.html new file mode 100644 index 00000000..5d7724c0 --- /dev/null +++ b/pydis_site/templates/staff/logs.html @@ -0,0 +1,15 @@ +{% extends 'base/base.html' %} +{% load static %} + +{% block title %}Home{% endblock %} + +{% block content %} + <h1>Message Context</h1> + <p> + Actor: {{ message_context.actor }} <br> + Date: {{ message_context.creation }} <br> + </p> + {% for message in message_context.deletedmessage_set.all %} + <p>{{ message.content | safe }}</p> + {% endfor %} +{% endblock %}
\ No newline at end of file diff --git a/pydis_site/urls.py b/pydis_site/urls.py index c68375da..47cf0ba1 100644 --- a/pydis_site/urls.py +++ b/pydis_site/urls.py @@ -3,4 +3,5 @@ from django.urls import include, path urlpatterns = ( path('', include('pydis_site.apps.home.urls', namespace='home')), + path('staff/', include('pydis_site.apps.staff.urls', namespace='staff')), ) |