def installations(installations): data = { 'total': installations.count(), 'installation_for_software': count_by(installations, lambda inst: inst.software.name), 'installation_for_hardware': count_by(installations, lambda inst: inst.hardware.type), 'installation_for_installer': count_by(installations, lambda inst: inst.installer.collaborator.user.username) } return data
def talks(talks): data = { 'total': talks.count(), 'talks_for_room': count_by(talks, lambda talk: talk.room.name), 'talks_for_type': count_by(talks, lambda talk: talk.talk_proposal.type.name), 'talks_for_level': count_by(talks, lambda talk: talk.talk_proposal.level) } return data
def sede_report(request, sede_url): sede = Sede.objects.get(url__iexact=sede_url) collaborators = Collaborator.objects.filter(sede=sede) installers = Installer.objects.filter(collaborator__sede=sede) talk_proposals = TalkProposal.objects.filter(sede=sede) votes = Vote.objects.all() sede_data = { 'votes_for_talk': count_by(votes, lambda vote: TalkProposal.objects.get( pk=vote.object_id, sede=sede).title, lambda vote: vote.vote), 'staff': get_staff(talk_proposals, installers, collaborators) } return HttpResponse(json.dumps(sede_data), content_type="application/json")
def installers(installers): data = { 'total': installers.count(), 'installers_for_level': count_by(installers, lambda inst: inst.level) } return data