from rest_framework import viewsets
from rest_framework.permissions import AllowAny
from .models import AboutUs
from .serializers import AboutUsSerializer

class AboutUsViewSet(viewsets.ModelViewSet):
    queryset = AboutUs.objects.all()
    serializer_class = AboutUsSerializer
    permission_classes = [AllowAny]
    
    def get_object(self):
        # Always return the first object (or create one if none exists)
        obj, created = AboutUs.objects.get_or_create(
            pk=1,
            defaults={
                'homepage_title': 'Welcome to Delta X',
                'homepage_short_description': 'We are a leading organization providing innovative solutions.',
                'footer_description': 'Delta X is committed to excellence and innovation.',
                'description': 'Detailed description about Delta X.'
            }
        )
        return obj
