Skip to content

Comments

Hub Rule Tag/View#7

Open
MaxIsJoe wants to merge 3 commits intounitystation:masterfrom
MaxIsJoe:update-tags
Open

Hub Rule Tag/View#7
MaxIsJoe wants to merge 3 commits intounitystation:masterfrom
MaxIsJoe:update-tags

Conversation

@MaxIsJoe
Copy link

@MaxIsJoe MaxIsJoe commented Jul 4, 2024

No description provided.

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