def newshift(request):
    try:
        personal_num = str(request.user)
        air_crew = AirCrew()
        if air_crew.CheckPilot(personal_num):
            crew_role = 'pilot'
        else:
            crew_role = 'navigator'
        flight_date = request.GET.get('flight_date')
        flight_type = request.GET.get('flight_type')
        leader = str(request.GET.get('leader'))
        newshift = Shift()
        newshift.InsertToStaffing(flight_date, flight_type, personal_num, crew_role, leader)
        if leader == '0':
            leader = ' Number 2'
        elif leader == '1':
            leader == 'Movil'
        if leader == '3':
            leader = ' '

        context = {
            'flight_date': flight_date, 'flight_type': flight_type, 'leader': leader
        }
        return render (request, 'base/newshift1.html', context)
    except:
        return redirect ('/profile')
def unmannedshifts(request):
    air_crew = AirCrew()
    shift = Shift()
    all_shifts = shift.ShowAllShifts()
    username = str(request.user)
    if air_crew.CheckLeader(username) == True:
        if air_crew.CheckPilot(username) == True:
            available = air_crew.ShowAvailableShiftsLeaders('pilot')
        elif air_crew.CheckPilot(username) == False:
            available = air_crew.ShowAvailableShiftsLeaders('navigator')

    elif not air_crew.CheckLeader(username) == True:
        if air_crew.CheckPilot(username):
            available = air_crew.ShowAvailableShifts('pilot')
        elif air_crew.CheckPilot(username) == False:
            available = air_crew.ShowAvailableShifts('navigator')
    args = {'available': available}
    return render(request, 'base/unmannedshifts.html', args)