oacpl/expert_witnesses/views.py

30 lines
966 B
Python
Raw Normal View History

2017-09-05 02:24:39 -04:00
from django.shortcuts import render
2017-09-14 13:52:39 -04:00
from .models import AreaOfExpertise, Expert
def browser(request):
filters = AreaOfExpertise.objects.all().order_by('field')
2017-09-16 18:45:28 -04:00
2017-09-14 13:52:39 -04:00
experts = Expert.objects.all()
2017-09-16 18:45:28 -04:00
institutes = set()
for expert in experts:
institutes.add(expert.institute) if expert.institute is not None else None
if request.GET.get('name'):
experts = experts.filter(name__contains=request.GET.get('name'))
if request.GET.get('institute'):
experts = experts.filter(institute=request.GET.get('institute'))
if request.GET.get('experties'):
experts = experts.filter(expertise=AreaOfExpertise.objects.filter(field=request.GET.get('experties'))).distinct()
return render(request, 'expertBrowser.html', {'experts': experts, 'institutes': institutes, 'filters': filters})
2017-09-14 13:52:39 -04:00
def viewer(request, id):
expert = Expert.objects.get(id=id)
return render(request, 'expertViewer.html', {'expert': expert})