Skip to content

Conversation

MaxIsJoe
Copy link

@MaxIsJoe MaxIsJoe commented Jul 4, 2024

No description provided.

@@ -25,3 +25,11 @@ def get(self, request, slug):
post = self.get_object()
serializer = self.serializer_class(post)
return Response(serializer.data)

class RulesPostsView(GenericAPIView):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class LatestRulePostView(GenericAPIView):
    serializer_class = PostSerializer

    def get(self, request):
        post = Post.objects.filter(type='rule', state='published').order_by('-date_created').first()
        if post:
            serializer = self.serializer_class(post)
            return Response(serializer.data)
        else:
            return Response({'detail': 'No published rule post found.'}, status=status.HTTP_404_NOT_FOUND)

try if this works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants