from django.contrib.auth import logout
from django.shortcuts import redirect, render
from django.views.generic.base import TemplateView, View
from django.http.response import HttpResponse
# START_FEATURE crispy_forms
from django.views.generic.edit import FormView

from crispy_forms.tests.forms import SampleForm
# END_FEATURE crispy_forms


class IndexView(TemplateView):
    template_name = "common/index.html"


class HealthCheckView(View):
    def get(self, request):
        return HttpResponse("ok")


class LogoutView(View):
    def post(self, request):
        logout(request)
        return redirect("index")


# START_FEATURE django_react
class DjangoReactView(TemplateView):
    # TODO: delete me; this is just a reference example
    template_name = 'common/sample_django_react.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['hello_msg'] = 'Component'
        context['sample_props'] = {'msg': 'sample props'}
        return context
# END_FEATURE django_react


# START_FEATURE crispy_forms
class SampleFormView(FormView):
    # TODO: delete me; this is just a reference example
    form_class = SampleForm
# END_FEATURE crispy_forms

def error_404(request, exception):
    return render(request, "errors/404.html", status=404)

def error_500(request):
    return render(request, "errors/500.html", status=500)

from django.contrib.auth import logout
from django.shortcuts import redirect, render
from django.views.generic.base import TemplateView, View
from django.http.response import HttpResponse
# START_FEATURE crispy_forms
from django.views.generic.edit import FormView

from crispy_forms.tests.forms import SampleForm
# END_FEATURE crispy_forms


class IndexView(TemplateView):
    template_name = "common/index.html"


class HealthCheckView(View):
    def get(self, request):
        return HttpResponse("ok")


class LogoutView(View):
    def post(self, request):
        logout(request)
        return redirect("index")


# START_FEATURE django_react
class DjangoReactView(TemplateView):
    # TODO: delete me; this is just a reference example
    template_name = 'common/sample_django_react.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['hello_msg'] = 'Component'
        context['sample_props'] = {'msg': 'sample props'}
        return context
# END_FEATURE django_react


# START_FEATURE crispy_forms
class SampleFormView(FormView):
    # TODO: delete me; this is just a reference example
    form_class = SampleForm
# END_FEATURE crispy_forms

def error_404(request, exception):
    return render(request, "errors/404.html", status=404)

def error_500(request):
    return render(request, "errors/500.html", status=500)

# START_FEATURE crispy_forms # END_FEATURE crispy_forms # START_FEATURE django_react # TODO: delete me; this is just a reference example # END_FEATURE django_react # START_FEATURE crispy_forms # TODO: delete me; this is just a reference example # END_FEATURE crispy_forms