Added filters
This commit is contained in:
parent
8337d3dfb2
commit
ff2eb574e1
@ -5,12 +5,23 @@ from .models import AreaOfExpertise, Expert
|
||||
|
||||
def browser(request):
|
||||
filters = AreaOfExpertise.objects.all().order_by('field')
|
||||
filter = filters.filter(field=request.POST.get('filter')).values_list('field')
|
||||
experts = Expert.objects.all()
|
||||
if filter:
|
||||
experts = experts.filter(expertise__in=filter)
|
||||
|
||||
return render(request, 'expertBrowser.html', {'experts': experts, 'filters': filters})
|
||||
experts = Expert.objects.all()
|
||||
|
||||
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})
|
||||
|
||||
|
||||
def viewer(request, id):
|
||||
|
Loading…
Reference in New Issue
Block a user