コード例 #1
0
def managergoalupdate(request):
    try:
        if request.method == 'POST':
            form = goalupdateForm(request.POST)
            if form.is_valid():
                shift_manager = ShiftManager()
                azach_num = form.cleaned_data['azach_num']
                miluim_num = form.cleaned_data['miluim_num']
                shift_manager.insertgoals(azach_num, miluim_num)
                template = 'base/managerpagegoal.html'
                args = {
                    'form': form,
                    'azach_num': azach_num,
                    'miluim_num': miluim_num
                }
        else:
            form = goalupdateForm(request.POST)
            template = 'base/managergoalupdate.html'
            args = {'form': form}
        return render(request, template, args)
    except:
        situation = 'bad'
        args = {'form': form, 'situation': situation}
        template = 'base/managergoalupdate.html'
        return render(request, template, args)
コード例 #2
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)
コード例 #3
0
def managerunmanned(request):
    username = str(request.user)
    usernamequery = (username,)
    shift_manager = ShiftManager()
    unmanned = shift_manager.unmannedshifts()
    user = shift_manager.getname(usernamequery)
    args = {'unmanned' : unmanned, 'user' : user}
    return render(request, 'base/managerunmanned1.html', args)
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
def deletestaffing(request):
    shift_manager = ShiftManager()
    flight_date = request.GET.get('flight_date')
    flight_type =request.GET.get('flight_type')
    personal_num = request.GET.get('personal_num')
    leader = request.GET.get('leader')
    #send_mail(subject='the subject',
     #           message ='shift canceled',
      #        from_email = '*****@*****.**',
       #       recipient_list = ['*****@*****.**' ],
        #      fail_silently = False,
         #     )
    shift_manager.deletestaffing(flight_date, flight_type, personal_num)
    return redirect('/managerstaffing#staffing')
コード例 #7
0
def managershowalljobs(request):
    shifts = Shift()
    all_jobs = shifts.showalljobs()
    if request.method == 'POST':
        form = AddShiftForm(request.POST)
        if form.is_valid():
            shift_manager = ShiftManager()
            flight_type = form.cleaned_data['flight_type']
            flight_date = form.cleaned_data['flight_date']
            notes = form.cleaned_data['notes']
            shift_manager.insertshift(flight_date, flight_type, notes)
            args = {'form': form}
            return redirect('/managershowalljobs')

    else:
        form = AddShiftForm()
    template = 'base/manageralljobs.html'
    args = {'form': form, 'all_jobs': all_jobs}
    return render(request, template, args)
コード例 #8
0
def airgoals(request):
    shift_manager = ShiftManager()
    number_of_people = shift_manager.staffnumber()
    air_goals = shift_manager.goaltracker()
    totalgoal = shift_manager.totalgoal()
    totaldid = shift_manager.totaldid()
    remain = float(totalgoal) - float(totaldid)
    args = {'air_goals' : air_goals, 'number_of_people': number_of_people, 'totalgoal': totalgoal, 'totaldid': totaldid, 'remain': remain}
    return render(request, 'base/airgoals1.html', args)
コード例 #9
0
def unmannedshifts(request):
    air_crew = AirCrew()
    shift = Shift()
    all_shifts = shift.ShowAllShifts()
    username = str(request.user)
    usernamequery = (str(username),)
    shift_manager = ShiftManager()
    #user = shift_manager.getname(usernamequery)
    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/unmannedshifts1.html', args)
コード例 #10
0
def managermyweek(request):
    shift_manager = ShiftManager()
    week = shift_manager.myweek()
    args = { 'week': week}
    return render(request,'base/managermyweek.html',args)
コード例 #11
0
def managerapproved(request):
    if request.method == "POST":
        form = auth_air_crew(request.POST)
        form2 = delete_auth_air_crew(request.POST)
        if form.is_valid():
            shift_manager = ShiftManager()
            personal_num = form.cleaned_data['personal_number']
            shift_manager.insert_auth(personal_num)
            return redirect('/managerapproved#add')
        if form2.is_valid():
            shift_manager = ShiftManager()
            personal_num_delete =  form2.cleaned_data['Delete_Personal_Number']
            shift_manager.delete_auth(personal_num_delete)
            return redirect('/managerapproved#add')
    else:
        usernamequery = (str(request.user),)
        shift_manager = ShiftManager()
        user = shift_manager.getname(usernamequery)
        all_auth = shift_manager.show_auth()
        form = auth_air_crew()
        form2 = delete_auth_air_crew()
    args = {'form': form, 'form2' :form2, 'user':user , 'all_auth' : all_auth}
    return render(request,'base/managerauth.html',args)
コード例 #12
0
def managercontact(request):
    shift_manager = ShiftManager()
    letters = shift_manager.getletters()
    args = { 'letters': letters}
    return render(request,'base/managercontact1.html',args)
コード例 #13
0
def deletejob(request):
    shift_manager = ShiftManager()
    flight_date = request.GET.get('flight_date')
    flight_type = request.GET.get('flight_type')
    shift_manager.deletejob(flight_date, flight_type)
    return redirect('/managershowalljobs#job')
コード例 #14
0
def deletegoals(request):
    shift_manager = ShiftManager()
    shift_manager.deletegoals()
    return render (request, 'base/deletedgoals.html')
コード例 #15
0
def managerunmanned(request):
    shift_manager = ShiftManager()
    unmanned = shift_manager.unmannedshifts()
    args = {'unmanned': unmanned}
    return render(request, 'base/managerunmanned1.html', args)