aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/staff
diff options
context:
space:
mode:
authorGravatar Joseph <[email protected]>2020-02-02 22:03:00 +0000
committerGravatar GitHub <[email protected]>2020-02-02 22:03:00 +0000
commitfa7c2aa1cef7e18face5d531fcc51a5f39bf2e3e (patch)
treee7a6417bfe02c2d6f15789f098de422fd6f70dde /pydis_site/apps/staff
parentMake newlines visible in deleted messages (diff)
parentCreate CODEOWNERS (diff)
Merge branch 'master' into deleted-messages-visible-line-endings
Diffstat (limited to 'pydis_site/apps/staff')
-rw-r--r--pydis_site/apps/staff/migrations/0002_add_is_staff_to_role_mappings.py18
-rw-r--r--pydis_site/apps/staff/models/role_mapping.py5
-rw-r--r--pydis_site/apps/staff/tests/test_logs_view.py17
3 files changed, 40 insertions, 0 deletions
diff --git a/pydis_site/apps/staff/migrations/0002_add_is_staff_to_role_mappings.py b/pydis_site/apps/staff/migrations/0002_add_is_staff_to_role_mappings.py
new file mode 100644
index 00000000..0404d270
--- /dev/null
+++ b/pydis_site/apps/staff/migrations/0002_add_is_staff_to_role_mappings.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.6 on 2019-10-20 14:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('staff', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='rolemapping',
+ name='is_staff',
+ field=models.BooleanField(default=False, help_text='Whether this role mapping relates to a Django staff group'),
+ ),
+ ]
diff --git a/pydis_site/apps/staff/models/role_mapping.py b/pydis_site/apps/staff/models/role_mapping.py
index 10c09cf1..8a1fac2e 100644
--- a/pydis_site/apps/staff/models/role_mapping.py
+++ b/pydis_site/apps/staff/models/role_mapping.py
@@ -21,6 +21,11 @@ class RoleMapping(models.Model):
unique=True, # Unique in order to simplify group assignment logic
)
+ is_staff = models.BooleanField(
+ help_text="Whether this role mapping relates to a Django staff group",
+ default=False
+ )
+
def __str__(self):
"""Returns the mapping, for display purposes."""
return f"@{self.role.name} -> {self.group.name}"
diff --git a/pydis_site/apps/staff/tests/test_logs_view.py b/pydis_site/apps/staff/tests/test_logs_view.py
index 32cb6bbf..1415c558 100644
--- a/pydis_site/apps/staff/tests/test_logs_view.py
+++ b/pydis_site/apps/staff/tests/test_logs_view.py
@@ -37,6 +37,7 @@ class TestLogsView(TestCase):
channel_id=1984,
content='<em>I think my tape has run out...</em>',
embeds=[],
+ attachments=[],
deletion_context=cls.deletion_context,
)
@@ -101,6 +102,7 @@ class TestLogsView(TestCase):
channel_id=1984,
content='Does that mean this thing will halt?',
embeds=[cls.embed_one, cls.embed_two],
+ attachments=['https://http.cat/100', 'https://http.cat/402'],
deletion_context=cls.deletion_context,
)
@@ -149,6 +151,21 @@ class TestLogsView(TestCase):
self.assertInHTML(embed_colour_needle.format(colour=embed_one_colour), html_response)
self.assertInHTML(embed_colour_needle.format(colour=embed_two_colour), html_response)
+ def test_if_both_attachments_are_included_html_response(self):
+ url = reverse('logs', host="staff", args=(self.deletion_context.id,))
+ response = self.client.get(url)
+
+ html_response = response.content.decode()
+ attachment_needle = '<img alt="Attachment" class="discord-attachment" src="{url}">'
+ self.assertInHTML(
+ attachment_needle.format(url=self.deleted_message_two.attachments[0]),
+ html_response
+ )
+ self.assertInHTML(
+ attachment_needle.format(url=self.deleted_message_two.attachments[1]),
+ html_response
+ )
+
def test_if_html_in_content_is_properly_escaped(self):
url = reverse('logs', host="staff", args=(self.deletion_context.id,))
response = self.client.get(url)