2018-11-11 12:41:48 +00:00
|
|
|
"""passbook overview views"""
|
|
|
|
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from django.views.generic import TemplateView
|
2019-04-29 18:37:44 +00:00
|
|
|
|
2019-04-29 18:07:18 +00:00
|
|
|
from passbook.core.models import Application
|
2019-10-07 14:33:48 +00:00
|
|
|
from passbook.policies.engine import PolicyEngine
|
2018-12-10 09:50:19 +00:00
|
|
|
|
|
|
|
|
2018-11-11 12:41:48 +00:00
|
|
|
class OverviewView(LoginRequiredMixin, TemplateView):
|
|
|
|
"""Overview for logged in user, incase user opens passbook directly
|
|
|
|
and is not being forwarded"""
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
template_name = "overview/index.html"
|
2018-11-16 10:41:14 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
2019-12-31 11:51:16 +00:00
|
|
|
kwargs["applications"] = []
|
2020-02-18 16:05:30 +00:00
|
|
|
for application in Application.objects.all().order_by("name"):
|
2020-06-07 14:35:08 +00:00
|
|
|
engine = PolicyEngine(application, self.request.user, self.request)
|
2019-04-29 18:07:18 +00:00
|
|
|
engine.build()
|
|
|
|
if engine.passing:
|
2019-12-31 11:51:16 +00:00
|
|
|
kwargs["applications"].append(application)
|
2018-11-16 10:41:14 +00:00
|
|
|
return super().get_context_data(**kwargs)
|