from django.shortcuts import render
from gauth.models import Location
from name_extractor.models import Staff


def leader_board(request, location_id):
    if location_id == '12345':
        staffs = Staff.objects.all().exclude(total_units=0.00).order_by('-total_units')
    else:
        staffs = Staff.objects.filter(location_id=location_id).exclude(total_units=0.00).order_by('-total_units')

    locations = Location.objects.all()
    context = {'er_locations': locations, 'staffs': staffs}

    return render(request, 'leaderboard.html', context=context)