from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic.base import TemplateView

from aircox.models import Program
from aircox.views import BaseView


class ProfileView(LoginRequiredMixin, BaseView, TemplateView):
    template_name = "accounts/profile.html"

    def get_context_data(self, **kwargs):
        groups = self.request.user.groups.all()
        programs = Program.objects.filter(editors__in=groups)
        kwargs.update({"user": self.request.user, "programs": programs})
        return super().get_context_data(**kwargs)
