diff options
author | 2019-08-22 15:44:06 +0200 | |
---|---|---|
committer | 2019-08-23 15:40:52 +0200 | |
commit | 8da376b0ebff72db9f72b7026b6f2fef4dff4f13 (patch) | |
tree | c0ac005706e4976d810ef8dbac8187a43f63bcca /pydis_site/apps/staff/viewsets | |
parent | Adding message display to frontend (diff) |
Making the deleted-messages-frontend functional with changes, including:
- Adding support for embeds to both the template and the css;
- Adding Discord fonts to create a Discord-realistic rendering;
- Adding Discord color int to html hex filter for use in templates;
- Removing unnecessary int -> hex property from role model (see previous point);
- Adding support to compute timestamp from snowflake int in the message model;
- Forcing the order of deleted messages list view to snowflake `id` to guarantee chronological order.
Diffstat (limited to 'pydis_site/apps/staff/viewsets')
-rw-r--r-- | pydis_site/apps/staff/viewsets/__init__.py | 2 | ||||
-rw-r--r-- | pydis_site/apps/staff/viewsets/logs.py | 20 |
2 files changed, 20 insertions, 2 deletions
diff --git a/pydis_site/apps/staff/viewsets/__init__.py b/pydis_site/apps/staff/viewsets/__init__.py index ccb57d43..6b10eb83 100644 --- a/pydis_site/apps/staff/viewsets/__init__.py +++ b/pydis_site/apps/staff/viewsets/__init__.py @@ -1,3 +1,3 @@ from .logs import LogView -__all__ = ["LogView"]
\ No newline at end of file +__all__ = ["LogView"] diff --git a/pydis_site/apps/staff/viewsets/logs.py b/pydis_site/apps/staff/viewsets/logs.py index d59847a3..0898d606 100644 --- a/pydis_site/apps/staff/viewsets/logs.py +++ b/pydis_site/apps/staff/viewsets/logs.py @@ -1,3 +1,5 @@ +import logging + from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse from django.shortcuts import get_object_or_404, render @@ -5,11 +7,27 @@ from django.views import View from pydis_site.apps.api.models.bot.message_deletion_context import MessageDeletionContext +log = logging.getLogger(__name__) + class LogView(View): + """The default view for the Deleted Messages logs.""" + template_name = "staff/logs.html" def get(self, request: WSGIRequest, pk: int) -> HttpResponse: + """Get method that answers a request with an html response by rendering a template.""" message_context = get_object_or_404(MessageDeletionContext, pk=pk) + + actor = message_context.actor + creation = message_context.creation messages = message_context.deletedmessage_set.all() - return render(request, self.template_name, {"message_context": message_context, "messages": messages}) + + template_fields = { + 'actor': actor, + 'actor_colour': message_context.actor.top_role.colour, + 'creation': creation, + 'messages': messages + } + + return render(request, self.template_name, template_fields) |