from django.shortcuts import render
from django.utils.decorators import method_decorator

from iamheadless_publisher_site import decorators as iamheadless_publisher_site_decorators
from iamheadless_publisher_site.viewsets.item import ItemViewSet

from .conf import settings


class FlatpageViewSet(ItemViewSet):

    template = settings.TEMPLATE

    @method_decorator(iamheadless_publisher_site_decorators.has_allowed_language(), name='dispatch')
    def get(self, request, language, slug):
        return render(request, self.get_template(), context=self.get_context())
