import json

from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import Http404
from django.views.generic import TemplateView


class IndexView(LoginRequiredMixin, TemplateView):
    """ View for displaying index page."""
    http_method_names = ['get']
    template_name = 'console/index.html'

    def get_context_data(self, **kwargs) -> dict:
        context = super().get_context_data(**kwargs)
        license_info = {}
        user = self.request.user
        if user.is_authenticated:
            context['user_permissions'] = json.dumps({})
            context['license'] = json.dumps(license_info)
        return context


class LoginTemplateView(TemplateView):
    http_method_names = ['get']
    template_name = 'console/login.html'


class LicenseActivationView(TemplateView):
    """View for activating license."""
    http_method_names = ['get']
    template_name = 'license_info/license_activation.html'


def page_not_found(request):
    raise Http404
