diff options
7 files changed, 112 insertions, 1 deletions
diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index af568ea1..ada2cd33 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -327,6 +327,18 @@ class InfractionTests(AuthenticatedAPITestCase): self.assertEqual(infraction.type, self.ban_hidden.type) self.assertEqual(infraction.hidden, self.ban_hidden.hidden) + def test_partial_update_of_inactive_infraction(self): + url = reverse('api:bot:infraction-detail', args=(self.ban_hidden.id,)) + data = { + 'expires_at': '4143-02-15T21:04:31+00:00', + 'reason': "Do not help out Joe with any electricity-related questions" + } + self.assertFalse(self.ban_inactive.active, "Infraction should start out as inactive") + response = self.client.patch(url, data=data) + self.assertEqual(response.status_code, 200) + infraction = Infraction.objects.get(id=self.ban_inactive.id) + self.assertFalse(infraction.active, "Infraction changed to active via patch") + def test_partial_update_returns_400_for_frozen_field(self): url = reverse('api:bot:infraction-detail', args=(self.ban_hidden.id,)) data = {'user': 6} @@ -692,6 +704,37 @@ class CreationTests(AuthenticatedAPITestCase): reason='A reason.', ) + def test_accepts_two_warnings(self): + """Two warnings can be created for a user.""" + url = reverse('api:bot:infraction-list') + data = { + 'user': self.user.id, + 'actor': self.user.id, + 'type': 'warning', + 'reason': "Thought upgrading DRF is a smart idea", + 'active': False, + } + first_response = self.client.post(url, data=data) + self.assertEqual(first_response.status_code, 201) + data['reason'] = "Do not claim King Arthur eats children" + second_response = self.client.post(url, data=data) + self.assertEqual(second_response.status_code, 201) + + def test_respects_active_false_of_warnings(self): + """Infractions can be created as inactive.""" + url = reverse('api:bot:infraction-list') + data = { + 'user': self.user.id, + 'actor': self.user.id, + 'type': 'warning', + 'reason': "Associate of REDACTED", + 'active': False, + } + response = self.client.post(url, data=data) + self.assertEqual(response.status_code, 201) + infraction = Infraction.objects.get(id=response.json()['id']) + self.assertFalse(infraction.active) + class InfractionDeletionTests(AuthenticatedAPITestCase): @classmethod diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index 066b296f..1d16232c 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -161,7 +161,12 @@ class InfractionViewSet( def partial_update(self, request: HttpRequest, *_args, **_kwargs) -> Response: """Method that handles the nuts and bolts of updating an Infraction.""" instance = self.get_object() - request.data.setdefault("active", True) + # DRF presently errors out if we are not specifying all fields here. + # See this issue: + # https://github.com/encode/django-rest-framework/issues/9358. The + # merged PR that closed the issue does not appear to work either, so + # here's a workaround. + request.data.setdefault("active", instance.active) serializer = self.get_serializer(instance, data=request.data, partial=True) serializer.is_valid(raise_exception=True) serializer.save() diff --git a/pydis_site/apps/timeline/entries/2023-10-15_pydis-code-jam-2023-cj10.md b/pydis_site/apps/timeline/entries/2023-10-15_pydis-code-jam-2023-cj10.md new file mode 100644 index 00000000..34887f69 --- /dev/null +++ b/pydis_site/apps/timeline/entries/2023-10-15_pydis-code-jam-2023-cj10.md @@ -0,0 +1,19 @@ +--- +title: Summer Code Jam 2023 (CJ10) +date: October 15th, 2023 +icon: fa fa-dice +icon_color: pastel-lime +--- + +We host the 10th Code Jam. This year, teams had to use an **image +processing/manipulation library** to create something under the theme of +**"Secret Codes"**. + +In total, 17 teams submitted projects out of which we showcased the top 10 in a +livestream, where the winners were also announced. + +<div class="force-aspect-container"> +<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" +allowfullscreen="" class="force-aspect-content" frameborder="0" +src="https://www.youtube.com/embed/7U7wu7o1Dss"></iframe> +</div> diff --git a/pydis_site/apps/timeline/entries/2024-06-20_partnership-with-coveragepy.md b/pydis_site/apps/timeline/entries/2024-06-20_partnership-with-coveragepy.md new file mode 100644 index 00000000..19582afe --- /dev/null +++ b/pydis_site/apps/timeline/entries/2024-06-20_partnership-with-coveragepy.md @@ -0,0 +1,8 @@ +--- +title: Partnership with Coverage.py +date: June 20th, 2024 +icon: fa fa-handshake + +--- + +The `#coveragepy` channel is created for discussion of Coverage.py, the popular code coverage measurement tool. diff --git a/pydis_site/apps/timeline/entries/2024-09-01_pydis-code-jam-2024-cj11.md b/pydis_site/apps/timeline/entries/2024-09-01_pydis-code-jam-2024-cj11.md new file mode 100644 index 00000000..cb944e71 --- /dev/null +++ b/pydis_site/apps/timeline/entries/2024-09-01_pydis-code-jam-2024-cj11.md @@ -0,0 +1,12 @@ +--- +title: Code Jam 2024 (CJ11) +date: September 1st, 2024 +icon: fa fa-dice +icon_color: pastel-lime +--- + +We host the 11th Code Jam. This year, teams had to create a **Discord +Application** based on the theme of **"Information Overload"**. + +23 teams submitted projects, 10 of which were demoed in a livestream in which +we also announced the winners. diff --git a/pydis_site/apps/timeline/entries/2024-10-07_python-313-release-stream.md b/pydis_site/apps/timeline/entries/2024-10-07_python-313-release-stream.md new file mode 100644 index 00000000..d1fc3eca --- /dev/null +++ b/pydis_site/apps/timeline/entries/2024-10-07_python-313-release-stream.md @@ -0,0 +1,16 @@ +--- +title: Python 3.13 Release Stream +date: Oct 10th, 2022 +icon: pydis +--- + +Another year, another Python release stream! Hosted by KeithTheEE, and CPython +Core Team members Ćukasz Langa, Pablo Galindo Salgado, and Brandt Bucher. +Together, they discuss the new features of the release, and what goes into +contributing to Python. + +<div class="force-aspect-container"> +<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" +allowfullscreen="" class="force-aspect-content" frameborder="0" +src="https://www.youtube.com/embed/7MAPzvv3ZG0"></iframe> +</div> diff --git a/pydis_site/apps/timeline/entries/2025-04-10_400000-members.md b/pydis_site/apps/timeline/entries/2025-04-10_400000-members.md new file mode 100644 index 00000000..205f61c7 --- /dev/null +++ b/pydis_site/apps/timeline/entries/2025-04-10_400000-members.md @@ -0,0 +1,8 @@ +--- +title: We hit 400 000 members! +date: April 10th, 2025 +icon: fa fa-users +icon_color: pastel-dark-blue +--- + +We're growing slower, but we're still growing! Python Discord's now has 400,000 members. |