from django.contrib.auth.decorators import login_required
from django.template.response import TemplateResponse

from aircox.models import Program


@login_required
def profile(request):
    programs = []
    ugroups = request.user.groups.all()
    for p in Program.objects.all():
        if p.editors in ugroups:
            programs.append(p)
    context = {"user": request.user, "programs": programs}
    return TemplateResponse(request, "accounts/profile.html", context)
