Ejemplo n.º 1
0
def managerstaffing(request):
    shift_manager = ShiftManager()
    usernamequery = (str(request.user), )
    name = shift_manager.getname(usernamequery)
    shifts = Shift()
    all_shifts = shifts.ShowAllShifts()
    all_staffing = shifts.ShowAllStaffing()
    if request.method == 'POST':
        form = AddShiftForm(request.POST)
        if form.is_valid():
            flight_type = form.cleaned_data['flight_type']
            flight_date = form.cleaned_data['flight_date']
            notes = form.cleaned_data['notes']
            shift_manager.insertshift(flight_type, flight_date, notes)
            template = 'base/staffingshow.html'
            args = {
                'form': form,
                'flight_type': flight_type,
                'flight_date': flight_date
            }
    else:
        form = AddShiftForm()
        template = 'base/managerstaffing1.html'
        args = {
            'name': name,
            'all_shifts': all_shifts,
            'all_staffing': all_staffing,
            'form': form
        }
    return render(request, template, args)
Ejemplo n.º 2
0
def managershifts(request):
    shifts = Shift()
    shift_manager = ShiftManager()
    all_shifts = shifts.ShowAllShifts()
    totalgoal = shift_manager.totalgoal()
    totaldid = shift_manager.totaldid()
    remain = float(totalgoal) - float(totaldid)
    args = {'all_shifts': all_shifts,'totalgoal': totalgoal, 'totaldid': totaldid, 'remain': remain}
    return render(request, 'base/managershifts1.html', args)
Ejemplo n.º 3
0
def Profile(request):
    if request.user.is_staff:
        shift_manager = ShiftManager()
        usernamequery = (str(request.user), )
        name = shift_manager.getname(usernamequery)
        totalgoal = shift_manager.totalgoal()
        totaldid = shift_manager.totaldid()
        remain = float(totalgoal) - float(totaldid)
        args = {
            'name': name,
            'totalgoal': totalgoal,
            'totaldid': totaldid,
            'remain': remain
        }
        return render(request, 'base/managerpage.html', args)
    else:
        username = str(request.user)
        usernamequery = (str(request.user), )
        mydb = mysql.connector.connect(host="localhost",
                                       user="******",
                                       password='******',
                                       database='flight_manager',
                                       auth_plugin='mysql_native_password')
        mycursor = mydb.cursor()
        query = """
         SELECT goal FROM flight_manager.air_crew WHERE personal_number = %s 
        """
        mycursor.execute(query, usernamequery)
        results = mycursor.fetchall()
        mydb.commit()
        for row in results:
            shift = str(row[0])
        new_shift = Shift()
        all_shifts = new_shift.ShowAllShifts()
        if len(shift) == 0:
            shift = '0'
        air_crew = AirCrew()
        future_shifts = air_crew.ShowFutureShifts(username)
        name = air_crew.getname(usernamequery)
        howmanydid = air_crew.howmanydid(username)
        howmanytot = air_crew.howmanytot(usernamequery)
        name = air_crew.getname(usernamequery)
        try:
            left = int(shift) - int(howmanydid[0])
        except:
            left = str('0')
        finally:
            args = {
                'user': name,
                'shifts': shift,
                'all_shifts': all_shifts,
                'howmanydid': howmanydid[0],
                'left': left,
                'shift': shift
            }
            return render(request, 'base/profile.html', args)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def allshifts(request):
    shift = Shift()
    all_shifts = shift.ShowAllShifts()
    args = {'all_shifts' : all_shifts}
    return render(request, 'base/allshifts.html', args)