diff options
author | 2024-01-14 17:01:03 +0800 | |
---|---|---|
committer | 2024-01-14 17:01:03 +0800 | |
commit | 9967809f985f57c36b5fc60d0c6f6e62427a98bb (patch) | |
tree | ba01a53453ac559071d1b0ca3983d6075e2ebae5 /pydis_site | |
parent | Dark: Fix tag colors in resources page (diff) | |
parent | Merge branch 'main' into gdwr-dark-theme (diff) |
Merge branch 'gdwr-dark-theme' of github.com:hedyhli/pydis-site into gdwr-dark-theme
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/api/serializers.py | 18 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/infraction.py | 6 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/nomination.py | 2 | ||||
-rw-r--r-- | pydis_site/apps/content/utils.py | 4 | ||||
-rw-r--r-- | pydis_site/apps/resources/resources/software_design_by_example.yaml | 26 | ||||
-rw-r--r-- | pydis_site/static/css/content/page.css | 13 |
6 files changed, 52 insertions, 17 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py index 87fd6190..cfd975c9 100644 --- a/pydis_site/apps/api/serializers.py +++ b/pydis_site/apps/api/serializers.py @@ -151,12 +151,9 @@ class MessageDeletionContextSerializer(ModelSerializer): """ messages = validated_data.pop('deletedmessage_set') deletion_context = MessageDeletionContext.objects.create(**validated_data) - for message in messages: - DeletedMessage.objects.create( - deletion_context=deletion_context, - **message - ) - + DeletedMessage.objects.bulk_create( + DeletedMessage(deletion_context=deletion_context, **message) for message in messages + ) return deletion_context @@ -508,13 +505,8 @@ class ExpandedInfractionSerializer(InfractionSerializer): """Return the dictionary representation of this infraction.""" ret = super().to_representation(instance) - user = User.objects.get(id=ret['user']) - user_data = UserSerializer(user).data - ret['user'] = user_data - - actor = User.objects.get(id=ret['actor']) - actor_data = UserSerializer(actor).data - ret['actor'] = actor_data + ret['user'] = UserSerializer(instance.user).data + ret['actor'] = UserSerializer(instance.actor).data return ret diff --git a/pydis_site/apps/api/viewsets/bot/infraction.py b/pydis_site/apps/api/viewsets/bot/infraction.py index 09c05a74..8da82822 100644 --- a/pydis_site/apps/api/viewsets/bot/infraction.py +++ b/pydis_site/apps/api/viewsets/bot/infraction.py @@ -230,7 +230,11 @@ class InfractionViewSet( }) additional_filters['type__in'] = [i.strip() for i in filter_types.split(",")] - return self.queryset.filter(**additional_filters) + qs = self.queryset.filter(**additional_filters) + if self.serializer_class is ExpandedInfractionSerializer: + return qs.prefetch_related('actor', 'user') + + return qs @action(url_path='expanded', detail=False) def list_expanded(self, *args, **kwargs) -> Response: diff --git a/pydis_site/apps/api/viewsets/bot/nomination.py b/pydis_site/apps/api/viewsets/bot/nomination.py index 953513e0..d083464c 100644 --- a/pydis_site/apps/api/viewsets/bot/nomination.py +++ b/pydis_site/apps/api/viewsets/bot/nomination.py @@ -170,7 +170,7 @@ class NominationViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge """ serializer_class = NominationSerializer - queryset = Nomination.objects.all() + queryset = Nomination.objects.all().prefetch_related('entries') filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter) filterset_fields = ('user__id', 'active') frozen_on_create = ('ended_at', 'end_reason', 'active', 'inserted_at', 'reviewed') diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index cfd73d67..9c949a93 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -206,9 +206,9 @@ def record_tags(tags: list[Tag]) -> None: # pretend it's previous state is the current state old_tag = new_tag - if old_tag.sha == new_tag.sha and old_tag.last_commit is not None: + if old_tag.sha == new_tag.sha and old_tag.last_commit_id is not None: # We still have an up-to-date commit entry - new_tag.last_commit = old_tag.last_commit + new_tag.last_commit_id = old_tag.last_commit_id new_tag.save() diff --git a/pydis_site/apps/resources/resources/software_design_by_example.yaml b/pydis_site/apps/resources/resources/software_design_by_example.yaml new file mode 100644 index 00000000..8cdfd625 --- /dev/null +++ b/pydis_site/apps/resources/resources/software_design_by_example.yaml @@ -0,0 +1,26 @@ +name: Software Design by Example +description: A tool-based introduction to Software Design with Python. This book teaches + design by explaining examples of small versions of familiar tools to show how + experienced software designers think. It introduces some fundamental ideas in computer + science that many self-taught programmers haven’t encountered. +icon_image: https://third-bit.com/sdxpy/logo.svg +icon_size: 50 +title_url: https://third-bit.com/sdxpy/ +urls: +- icon: branding/goodreads + url: https://www.goodreads.com/book/show/199430059-software-design-by-example + color: black +- icon: branding/github + url: https://github.com/gvwilson/sdxpy + color: black +tags: + topics: + - general + - software design + payment_tiers: + - free + - paid + difficulty: + - intermediate + type: + - book diff --git a/pydis_site/static/css/content/page.css b/pydis_site/static/css/content/page.css index e9023a6b..55fe6223 100644 --- a/pydis_site/static/css/content/page.css +++ b/pydis_site/static/css/content/page.css @@ -10,6 +10,11 @@ #edit-on-github { display: none; } + + .dropdown-menu { + left: unset; + right: 0; + } } i.has-icon-padding { @@ -111,4 +116,12 @@ li img { [data-theme="dark"] hr { background-color: #4c515a; + +.dropdown-menu { + min-width: 15rem; +} + +a.dropdown-item { + white-space: normal; + padding-right: 0; } |