from django.shortcuts import render from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from areas.models import Areas from users.priomodel import Prio from tasks.models import Tasks import webcolors @login_required def mainorga(request): leader = list(User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).filter(profile__func='lead')) if len(leader) > 0: leader = leader[0] else: leader = None indoor = list(User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).filter(profile__func='indoor')) external = list(User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).filter(profile__func='external')) trainee = list(User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).filter(profile__func='trainee')) context = { 'active_link' : 'orga', 'leader' : leader, 'indoor' : indoor, 'external' : external, 'trainee' : trainee } return render(request, 'orga/orga_main.html', context) @login_required def singleorga(request, pk): user = User.objects.get(pk=pk) ''' VON GROß NACH KLEIN - SINNLOS prios = Prio.objects.filter(user__pk=pk).order_by('-prio')[::-1] ''' prios = Prio.objects.filter(user__pk=pk).order_by('-prio') areas = list(Areas.objects.filter(agency__pk=request.user.profile.agency.pk)) i = 0 for area in areas: areas[i].hex = areas[i].color areas[i].color = list(webcolors.hex_to_rgb(areas[i].color)) i += 1 user_first_name = user.first_name user_last_name = user.last_name user_id = user.pk context = { 'active_link' : 'orga', 'areas' : areas, 'user_first_name' : user_first_name, 'user_last_name' : user_last_name, 'user_id' : user_id, 'prios' : prios, 'mail' : user.email, 'userfunc' : user.profile.get_func_display, 'imageurl' : user.profile.image.url, 'compfunc' : user.profile.compfunc, 'phoneland' : user.profile.phoneland, 'phonemobile' : user.profile.phonemobile } return render(request, 'orga/orga_single.html', context)