diff options
| author | 2022-05-17 03:39:58 +0300 | |
|---|---|---|
| committer | 2022-05-17 03:39:58 +0300 | |
| commit | aa620e4b8910fcce857f91c213fb275d73e31fd9 (patch) | |
| tree | 320bfd94e7ad338dac507f91b33523fcc1cd70f8 /pydis_site/apps/staff | |
| parent | Add Making Changes step (diff) | |
| parent | Merge pull request #720 from python-discord/id-in-delete-logs (diff) | |
Merge branch 'main' into contrib-streamline
Diffstat (limited to 'pydis_site/apps/staff')
| -rw-r--r-- | pydis_site/apps/staff/templatetags/deletedmessage_filters.py | 10 | ||||
| -rw-r--r-- | pydis_site/apps/staff/tests/test_logs_view.py | 12 |
2 files changed, 18 insertions, 4 deletions
diff --git a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py index 8e14ced6..5026068e 100644 --- a/pydis_site/apps/staff/templatetags/deletedmessage_filters.py +++ b/pydis_site/apps/staff/templatetags/deletedmessage_filters.py @@ -1,4 +1,5 @@ from datetime import datetime +from typing import Union from django import template @@ -6,13 +7,16 @@ register = template.Library() @register.filter -def hex_colour(color: int) -> str: +def hex_colour(colour: Union[str, int]) -> str: """ - Converts an integer representation of a colour to the RGB hex value. + Converts the given representation of a colour to its RGB hex string. As we are using a Discord dark theme analogue, black colours are returned as white instead. """ - colour = f"#{color:0>6X}" + if isinstance(colour, str): + colour = colour if colour.startswith("#") else f"#{colour}" + else: + colour = f"#{colour:0>6X}" return colour if colour != "#000000" else "#FFFFFF" diff --git a/pydis_site/apps/staff/tests/test_logs_view.py b/pydis_site/apps/staff/tests/test_logs_view.py index 45e9ce8f..3e5726cd 100644 --- a/pydis_site/apps/staff/tests/test_logs_view.py +++ b/pydis_site/apps/staff/tests/test_logs_view.py @@ -95,12 +95,22 @@ class TestLogsView(TestCase): "description": "This embed is way too cool to be seen in public channels.", } + cls.embed_three = { + "description": "This embed is way too cool to be seen in public channels.", + "color": "#e74c3c", + } + + cls.embed_four = { + "description": "This embed is way too cool to be seen in public channels.", + "color": "e74c3c", + } + cls.deleted_message_two = DeletedMessage.objects.create( author=cls.author, id=614444836291870750, channel_id=1984, content='Does that mean this thing will halt?', - embeds=[cls.embed_one, cls.embed_two], + embeds=[cls.embed_one, cls.embed_two, cls.embed_three, cls.embed_four], attachments=['https://http.cat/100', 'https://http.cat/402'], deletion_context=cls.deletion_context, ) |