Пример #1
0
def coachUpdate(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    coach = Coach.objects.get(pk=pk)

    grade_form = coach.grades.all()
    visa_form = coach.visa.all()
    user = User.objects.get(pk=coach.user.pk)
    person = Person.objects.get(pk=coach.person.pk)
    communication = Communication.objects.get(pk=coach.communication.pk)
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None,
                             request.FILES or None,
                             instance=person)
    communication_form = CommunicationForm(request.POST or None,
                                           instance=communication)
    if request.method == 'POST':
        user = User.objects.get(pk=coach.user.pk)
        user_form = UserForm(request.POST or None, instance=user)
        # person_form = PersonForm(request.POST,request.FILES, instance=person)
        communication_form = CommunicationForm(request.POST or None,
                                               instance=communication)
        if user_form.is_valid() and person_form.is_valid(
        ) and communication_form.is_valid():

            user.username = user_form.cleaned_data['email']
            user.first_name = user_form.cleaned_data['first_name'].upper()
            user.last_name = user_form.cleaned_data['last_name'].upper()
            user.email = user_form.cleaned_data['email']

            user = user_form.save(commit=False)
            user.username = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()

            messages.success(request, 'Antrenör Başarıyla Güncellendi')
            return redirect('sbs:antrenorler')
        else:
            messages.warning(request, 'Alanları Kontrol Ediniz')

    return render(
        request, 'antrenor/antrenorDuzenle.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'person_form': person_form,
            'grades_form': grade_form,
            'coach': coach.pk,
            'personCoach': person,
            'visa_form': visa_form
        })
Пример #2
0
def updateClubPersons(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    athlete = SportClubUser.objects.get(pk=pk)
    user = User.objects.get(pk=athlete.user.pk)
    person = Person.objects.get(pk=athlete.person.pk)
    communication = Communication.objects.get(pk=athlete.communication.pk)
    # sportClub = athlete.sportClub
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None, instance=person)
    communication_form = CommunicationForm(request.POST or None,
                                           instance=communication)
    sportClubUser_form = SportClubUserForm(request.POST or None,
                                           instance=athlete)
    clubs = SportsClub.objects.filter(clubUser__user=user)

    if request.method == 'POST':

        if user_form.is_valid() and communication_form.is_valid(
        ) and person_form.is_valid() and sportClubUser_form.is_valid():

            user = user_form.save(commit=False)
            user.username = user_form.cleaned_data['email']
            user.first_name = user_form.cleaned_data['first_name']
            user.last_name = user_form.cleaned_data['last_name']
            user.email = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()
            sportClubUser_form.save()

            messages.success(request, 'Kulüp Üyesi Başarıyla Güncellenmiştir.')

            return redirect('sbs:kulup-uyeleri')

        else:

            for x in user_form.errors.as_data():
                messages.warning(request, user_form.errors[x][0])

    return render(
        request, 'kulup/kulup-uyesi-duzenle.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'person_form': person_form,
            'sportClubUser_form': sportClubUser_form,
            'clubs': clubs
        })
Пример #3
0
def updateathletes(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    athlete = Athlete.objects.get(pk=pk)
    belts_form = athlete.belts.all()
    licenses_form = athlete.licenses.all()
    user = User.objects.get(pk=athlete.user.pk)
    person = Person.objects.get(pk=athlete.person.pk)
    communication = Communication.objects.get(pk=athlete.communication.pk)
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None, instance=person)
    communication_form = CommunicationForm(request.POST or None,
                                           instance=communication)
    say = 0
    say = athlete.licenses.all().filter(status='Onaylandı').count()

    if request.method == 'POST':

        if user_form.is_valid() and communication_form.is_valid(
        ) and person_form.is_valid():
            user = user_form.save(commit=False)
            print('user='******'email']
            user.first_name = user_form.cleaned_data['first_name'].upper()
            user.last_name = user_form.cleaned_data['last_name'].upper()
            user.email = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()

            messages.success(request, 'Sporcu Başarıyla Güncellenmiştir.')
            return redirect('sbs:update-athletes', pk=pk)

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')

    return render(
        request, 'sporcu/sporcuDuzenle.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'person_form': person_form,
            'belts_form': belts_form,
            'licenses_form': licenses_form,
            'athlete': athlete,
            'say': say
        })
Пример #4
0
def updateClubPersons(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    athlete = SportClubUser.objects.get(pk=pk)

    if not athlete.user.groups.all():
        user = athlete.user
        athlete.user.groups.add(Group.objects.get(name="KlupUye"))
        athlete.save()
    groups = Group.objects.all()

    user = User.objects.get(pk=athlete.user.pk)
    person = Person.objects.get(pk=athlete.person.pk)
    communication = Communication.objects.get(pk=athlete.communication.pk)
    # sportClub = athlete.sportClub
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None, request.FILES or None, instance=person)
    communication_form = CommunicationForm(request.POST or None, instance=communication)
    sportClubUser_form = SportClubUserForm(request.POST or None, instance=athlete)
    clubs = SportsClub.objects.filter(clubUser__user=user)

    communication = Communication.objects.get(pk=athlete.communication.pk)

    if person.material:
        metarial = Material.objects.get(pk=athlete.person.material.pk)
    else:
        metarial = Material()
        metarial.save()
        person.material = metarial
        person.save()

    communication_form = CommunicationForm(request.POST or None, instance=communication)
    metarial_form = MaterialForm(request.POST or None, instance=metarial)

    if request.method == 'POST':
        mail = request.POST.get('email')
        if mail != athlete.user.email:

            if User.objects.filter(email=mail) or ReferenceCoach.objects.exclude(status=ReferenceCoach.DENIED).filter(
                    email=mail) or ReferenceReferee.objects.exclude(status=ReferenceReferee.DENIED).filter(
                email=mail) or PreRegistration.objects.exclude(status=PreRegistration.DENIED).filter(
                email=mail):
                messages.warning(request, 'Mail adresi başka bir kullanici tarafından kullanilmaktadir.')
                return render(request, 'kulup/kulup-uyesi-duzenle.html',
                              {'user_form': user_form, 'communication_form': communication_form, 'groups': groups,
                               'clupUser': athlete,
                               'person_form': person_form, 'sportClubUser_form': sportClubUser_form, 'clubs': clubs,
                               'metarial_form': metarial_form,
                               })

        tc = request.POST.get('tc')
        if tc != athlete.person.tc:
            if Person.objects.filter(tc=tc) or ReferenceCoach.objects.exclude(status=ReferenceCoach.DENIED).filter(
                    tc=tc) or ReferenceReferee.objects.exclude(status=ReferenceReferee.DENIED).filter(
                tc=tc) or PreRegistration.objects.exclude(status=PreRegistration.DENIED).filter(tc=tc):
                messages.warning(request, 'Tc kimlik numarasi sisteme kayıtlıdır. ')
                return render(request, 'kulup/kulup-uyesi-duzenle.html',
                              {'user_form': user_form, 'communication_form': communication_form, 'groups': groups,
                               'clupUser': athlete,
                               'person_form': person_form, 'sportClubUser_form': sportClubUser_form, 'clubs': clubs,
                               'metarial_form': metarial_form,
                               })

        name = request.POST.get('first_name')
        surname = request.POST.get('last_name')
        year = request.POST.get('birthDate')
        year = year.split('/')

        # client = Client('https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL')
        # if not (client.service.TCKimlikNoDogrula(tc, name, surname, year[2])):
        #     messages.warning(request, 'Tc kimlik numarasi ile isim  soyisim dogum yılı  bilgileri uyuşmamaktadır. ')
        #     return render(request, 'kulup/kulup-uyesi-duzenle.html',
        #                   {'user_form': user_form, 'communication_form': communication_form, 'groups': groups,
        #                    'clupUser': athlete,
        #                    'person_form': person_form, 'sportClubUser_form': sportClubUser_form, 'clubs': clubs,
        #                    'metarial_form': metarial_form,
        #                    })

        if user_form.is_valid() and communication_form.is_valid() and person_form.is_valid() and sportClubUser_form.is_valid():

            user = user_form.save(commit=False)
            user.username = user_form.cleaned_data['email']
            user.first_name = unicode_tr(user_form.cleaned_data['first_name']).upper()
            user.last_name = unicode_tr(user_form.cleaned_data['last_name']).upper()
            user.email = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()
            sportClubUser_form.save()

            log = str(user.get_full_name()) + " klup uyesi guncellendi"
            log = general_methods.logwrite(request, request.user, log)

            messages.success(request, 'Kulüp Üyesi Başarıyla Güncellenmiştir.')

            # return redirect('sbs:kulup-uyeleri')

        else:

            for x in user_form.errors.as_data():
                messages.warning(request, user_form.errors[x][0])

    return render(request, 'kulup/kulup-uyesi-duzenle.html',
                  {'user_form': user_form, 'communication_form': communication_form, 'groups': groups,
                   'clupUser': athlete,
                   'person_form': person_form, 'sportClubUser_form': sportClubUser_form, 'clubs': clubs,
                   'metarial_form': metarial_form,
                   })
Пример #5
0
def update_demploye(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    member = Employe.objects.get(pk=pk)
    if not member.user.groups.all():
        member.user.groups.add(Group.objects.get(name="Personel"))
        member.save()
    groups = Group.objects.all()
    user = User.objects.get(pk=member.user.pk)
    person = Person.objects.get(pk=member.person.pk)
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None,
                             request.FILES or None,
                             instance=person)
    communication = Communication.objects.get(pk=member.communication.pk)
    unit_form = EmployeUnitForm(request.POST or None, instance=member)
    if person.material:
        metarial = Material.objects.get(pk=member.person.material.pk)
    else:
        metarial = Material()
        metarial.save()
        person.material = metarial
        person.save()
    communication_form = CommunicationForm(request.POST or None,
                                           instance=communication)
    metarial_form = MaterialForm(request.POST or None, instance=metarial)
    if request.method == 'POST':

        # controller tc email

        mail = request.POST.get('email')
        if user.email != mail:
            if User.objects.filter(
                    email=mail) or ReferenceCoach.objects.exclude(
                        status=ReferenceCoach.DENIED
                    ).filter(email=mail) or ReferenceReferee.objects.exclude(
                        status=ReferenceReferee.DENIED).filter(
                            email=mail) or PreRegistration.objects.exclude(
                                status=PreRegistration.DENIED).filter(
                                    email=mail):
                messages.warning(
                    request,
                    'Mail adresi başka bir kullanici tarafından kullanilmaktadir.'
                )
                return render(
                    request, 'personel/personelDuzenle.html', {
                        'user_form': user_form,
                        'communication_form': communication_form,
                        'member': member,
                        'person_form': person_form,
                        'groups': groups,
                        'metarial_form': metarial_form,
                        'unit_form': unit_form
                    })
        tc = request.POST.get('tc')

        if person.tc != tc:
            if Person.objects.filter(tc=tc) or ReferenceCoach.objects.exclude(
                    status=ReferenceCoach.DENIED).filter(
                        tc=tc) or ReferenceReferee.objects.exclude(
                            status=ReferenceReferee.DENIED).filter(
                                tc=tc) or PreRegistration.objects.exclude(
                                    status=PreRegistration.DENIED).filter(
                                        tc=tc):
                messages.warning(request,
                                 'Tc kimlik numarasi sistemde kayıtlıdır. ')
                return render(
                    request, 'personel/personelDuzenle.html', {
                        'user_form': user_form,
                        'communication_form': communication_form,
                        'member': member,
                        'person_form': person_form,
                        'groups': groups,
                        'metarial_form': metarial_form,
                        'unit_form': unit_form
                    })

        name = request.POST.get('first_name')
        surname = request.POST.get('last_name')
        year = request.POST.get('birthDate')
        year = year.split('/')

        # client = Client('https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL')
        # if not (client.service.TCKimlikNoDogrula(tc, name, surname, year[2])):
        #     messages.warning(request, 'Tc kimlik numarasi ile isim  soyisim dogum yılı  bilgileri uyuşmamaktadır. ')
        #     return render(request, 'yonetim/kurul-uyesi-duzenle.html',
        #                   {'user_form': user_form, 'communication_form': communication_form, 'member': member,
        #                    'person_form': person_form, 'member_form': member_form, 'groups': groups,
        #                    'metarial_form': metarial_form,
        #                    })

        if user_form.is_valid() and person_form.is_valid(
        ) and communication_form.is_valid() and metarial_form.is_valid():
            user_form.save()
            person_form.save()
            communication_form.save()
            metarial_form.save()
            log = str(user.get_full_name()) + " Personel guncellendi"
            log = general_methods.logwrite(request, request.user, log)
            messages.success(request, 'Personel Başarıyla Güncellendi')
            # return redirect('sbs:kurul-uyeleri')
        else:
            messages.warning(request, 'Alanları Kontrol Ediniz')
    return render(
        request, 'personel/personelDuzenle.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'member': member,
            'person_form': person_form,
            'groups': groups,
            'metarial_form': metarial_form,
            'unit_form': unit_form
        })
Пример #6
0
def updatecoach(request, tc, pk):
    coach = Coach.objects.filter(person__tc=tc)[0]
    if coach.pk == Coach.objects.filter(person__tc=tc)[0].pk:
        if not coach.user.groups.all():
            user = coach.user
            coach.user.groups.add(Group.objects.get(name="Antrenor"))
            coach.save()
        groups = Group.objects.all()
        grade_form = coach.grades.all()
        visa_form = coach.visa.all()
        user = User.objects.get(pk=coach.user.pk)
        person = Person.objects.get(pk=coach.person.pk)
        communication = Communication.objects.get(pk=coach.communication.pk)
        user_form = UserForm(request.POST or None, instance=coach.user)
        person_form = PersonForm(request.POST or None,
                                 request.FILES or None,
                                 instance=coach.person)
        iban_form = IbanCoachForm(request.POST or None, instance=coach)
        communication = Communication.objects.get(pk=coach.communication.pk)
        communication_form = CommunicationForm(request.POST or None,
                                               instance=coach.communication)
        if person.material:
            metarial = Material.objects.get(pk=coach.person.material.pk)
        else:
            metarial = Material()
            metarial.save()
            person.material = metarial
            person.save()
        metarial_form = MaterialForm(request.POST or None,
                                     instance=coach.person.material)

        if request.method == 'POST':
            mail = request.POST.get('email')
            if mail != coach.user.email:

                if User.objects.filter(
                        email=mail
                ) or ReferenceCoach.objects.exclude(
                        status=ReferenceCoach.DENIED
                ).filter(email=mail) or ReferenceReferee.objects.exclude(
                        status=ReferenceReferee.DENIED).filter(
                            email=mail) or PreRegistration.objects.exclude(
                                status=PreRegistration.DENIED).filter(
                                    email=mail):
                    messages.warning(
                        request,
                        'Mail adresi başka bir kullanici tarafından kullanilmaktadir.'
                    )
                    return render(
                        request, 'registration/CoachUpdate.html', {
                            'user_form': user_form,
                            'communication_form': communication_form,
                            'person_form': person_form,
                            'grades_form': grade_form,
                            'coach': coach.pk,
                            'personCoach': person,
                            'visa_form': visa_form,
                            'iban_form': iban_form,
                            'groups': groups,
                            'metarial_form': metarial_form,
                        })

            tc = request.POST.get('tc')
            if tc != coach.person.tc:
                if Person.objects.filter(
                        tc=tc) or ReferenceCoach.objects.exclude(
                            status=ReferenceCoach.DENIED
                        ).filter(tc=tc) or ReferenceReferee.objects.exclude(
                            status=ReferenceReferee.DENIED).filter(
                                tc=tc) or PreRegistration.objects.exclude(
                                    status=PreRegistration.DENIED).filter(
                                        tc=tc):
                    messages.warning(
                        request, 'Tc kimlik numarasi sisteme kayıtlıdır. ')
                    return render(
                        request, 'registration/CoachUpdate.html', {
                            'user_form': user_form,
                            'communication_form': communication_form,
                            'person_form': person_form,
                            'grades_form': grade_form,
                            'coach': coach.pk,
                            'personCoach': person,
                            'visa_form': visa_form,
                            'iban_form': iban_form,
                            'groups': groups,
                            'metarial_form': metarial_form,
                        })

            name = request.POST.get('first_name')
            surname = request.POST.get('last_name')
            year = request.POST.get('birthDate')
            year = year.split('/')

            # client = Client('https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL')
            # if not (client.service.TCKimlikNoDogrula(tc, name, surname, year[2])):
            #     messages.warning(request,
            #                      'Tc kimlik numarasi ile isim  soyisim dogum yılı  bilgileri uyuşmamaktadır. ')
            #     return render(request, 'registration/CoachUpdate.html',
            #                   {'user_form': user_form, 'communication_form': communication_form,
            #                    'person_form': person_form, 'grades_form': grade_form, 'coach': coach.pk,
            #                    'personCoach': person, 'visa_form': visa_form, 'iban_form': iban_form,
            #                    'groups': groups,
            #                    'metarial_form': metarial_form,
            #                    })
            if user_form.is_valid() and person_form.is_valid(
            ) and communication_form.is_valid() and iban_form.is_valid(
            ) and metarial_form.is_valid():
                user.username = user_form.cleaned_data['email']
                user.first_name = user_form.cleaned_data['first_name']
                user.last_name = user_form.cleaned_data['last_name']
                user.email = user_form.cleaned_data['email']
                user.save()

                user = user_form.save(commit=False)
                user.username = user_form.cleaned_data['email']
                user.save()

                iban_form.save()
                person_form.save()
                communication_form.save()

                log = str(user.get_full_name()) + " Antrenor güncelledi"
                log = general_methods.logwrite(request, request.user, log)

                fdk = Forgot(user=user, status=False)
                fdk.save()

                html_content = ''
                subject, from_email, to = 'Badminton Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
                html_content = '<h2>TÜRKİYE BADMİNTON FEDERASYONU BİLGİ SİSTEMİ</h2>'
                html_content = html_content + '<p><strong>Kullanıcı Adınız :' + str(
                    fdk.user.username) + '</strong></p>'
                # html_content = html_content + '<p> <strong>Site adresi:</strong> <a href="http://127.0.0.1:8000/newpassword?query=' + str(
                #     fdk.uuid) + '">http://127.0.0.1:8000/sbs/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'
                html_content = html_content + '<p> <strong>Site adresi:</strong> <a href="http://sbs.badminton.gov.tr/newpassword?query=' + str(
                    fdk.uuid
                ) + '">http://sbs.badminton.gov.tr/sbs/profil-guncelle/?query=' + str(
                    fdk.uuid) + '</p></a>'

                msg = EmailMultiAlternatives(subject, '', from_email, [to])
                msg.attach_alternative(html_content, "text/html")
                msg.send()
                user.is_active = True
                user.save()
                messages.success(
                    request, 'Giris Bilgileriniz Mail Adresinize Gönderildi')
                return redirect('accounts:login')
            else:
                messages.warning(request, 'Alanlari Kontrol Ediniz')

        return render(
            request, 'registration/CoachUpdate.html', {
                'user_form': user_form,
                'communication_form': communication_form,
                'person_form': person_form,
                'grades_form': grade_form,
                'coach': coach,
                'personCoach': person,
                'visa_form': visa_form,
                'iban_form': iban_form,
                'groups': groups,
            })
    else:
        return redirect('accounts:last-login')

    return render(request, 'registration/CoachUpdate.html')
Пример #7
0
def edit_employee(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    employee = Employee.objects.get(pk=pk)
    user = User.objects.get(pk=employee.user.pk)
    person = Person.objects.get(pk=employee.person.pk)

    communication = Communication.objects.get(pk=employee.communication.pk)
    user_form = UserForm(request.POST or None, instance=user)
    person_form = PersonForm(request.POST or None, request.FILES or None, instance=person)
    communication_form = CommunicationForm(request.POST or None, instance=communication)

    employee_form = EmployeeForm(request.POST or None, instance=employee)
    employee_form.fields['workDefinition'].queryset = CategoryItem.objects.filter(
        forWhichClazz="EMPLOYEE_WORKDEFINITION")
    projects=EPProject.objects.filter(employees__employee__user=user ).distinct()
    projects|=EPProject.objects.filter(sorumlu__user=user).distinct()

    cezainfaz = int(projects.filter(projeCinsi=EPProject.CIK).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adaletbinasi =int(projects.filter(projeCinsi=EPProject.AB).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adlitip = int(projects.filter(projeCinsi=EPProject.AT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeadliye = int(projects.filter(projeCinsi=EPProject.BAM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeidari = int(projects.filter(projeCinsi=EPProject.BIM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    denetimserbeslik = int(projects.filter(projeCinsi=EPProject.DS).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    personelegitim = int(projects.filter(projeCinsi=EPProject.PEM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bakanlikbinasi = int(projects.filter(projeCinsi=EPProject.BB).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    diger = int(projects.filter(projeCinsi=EPProject.DIGER).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    lojman = int(projects.filter(projeCinsi=EPProject.LOJMAN).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)


    cezainfaz_tam = int(projects.filter(projeCinsi=EPProject.CIK,projectStatus=EPProject.PT).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adaletbinasi_tam  =int(projects.filter(projeCinsi=EPProject.AB,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adlitip_tam  = int(projects.filter(projeCinsi=EPProject.AT,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeadliye_tam  = int(projects.filter(projeCinsi=EPProject.BAM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeidari_tam  = int(projects.filter(projeCinsi=EPProject.BIM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    denetimserbeslik_tam = int(
        projects.filter(projeCinsi=EPProject.DS, projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))[
            'insaatAlani__sum'] or 0)
    personelegitim_tam  = int(projects.filter(projeCinsi=EPProject.PEM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bakanlikbinasi_tam  = int(projects.filter(projeCinsi=EPProject.BB,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    diger_tam  = int(projects.filter(projeCinsi=EPProject.DIGER,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    lojman_tam  = int(projects.filter(projeCinsi=EPProject.LOJMAN,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)


    cezainfaz_dev = int(projects.filter(projeCinsi=EPProject.CIK,projectStatus=EPProject.PDE).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adaletbinasi_dev  =int(projects.filter(projeCinsi=EPProject.AB,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    adlitip_dev  = int(projects.filter(projeCinsi=EPProject.AT,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeadliye_dev = int(projects.filter(projeCinsi=EPProject.BAM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bolgeidari_dev  = int(projects.filter(projeCinsi=EPProject.BIM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    denetimserbeslik_dev = int(
        projects.filter(projeCinsi=EPProject.DS, projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))[
            'insaatAlani__sum'] or 0)
    personelegitim_dev  = int(projects.filter(projeCinsi=EPProject.PEM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    bakanlikbinasi_dev  = int(projects.filter(projeCinsi=EPProject.BB,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    diger_dev  = int(projects.filter(projeCinsi=EPProject.DIGER,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)
    lojman_dev  = int(projects.filter(projeCinsi=EPProject.LOJMAN,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0)

    # bildirimden  gelinmisse ve sistem deki  kisinin ise true yap daha görülmesin
    get = request.GET.get('notification')
    if get:
        notification = Notification.objects.get(pk=int(get))
        if notification.users == request.user:
            notification.is_show = True
            notification.save()



    if request.method == 'POST':

        if user_form.is_valid() and communication_form.is_valid() and person_form.is_valid() and employee_form.is_valid():

            user = user_form.save(commit=False)
            user.username = user_form.cleaned_data['email']
            user.first_name = user_form.cleaned_data['first_name']
            user.last_name = user_form.cleaned_data['last_name']
            user.email = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()
            employee_form.save()

            log = str(user.get_full_name()) + " personel güncellendi"
            log = general_methods.logwrite(request, log)

            messages.success(request, 'Personel Başarıyla Güncellenmiştir.')

            # return redirect('sbs:personeller')

        else:

            for x in user_form.errors.as_data():
                messages.warning(request, user_form.errors[x][0])

    return render(request, 'personel/personel-duzenle.html',
                  {'user_form': user_form, 'communication_form': communication_form,
                   'person_form': person_form, 'employee_form': employee_form,'projects':projects,'personel':user,
                   'cezainfaz': cezainfaz,
                   'adaletbinasi': adaletbinasi,
                   'adlitip': adlitip,
                   'bolgeadliye': bolgeadliye,
                   'bolgeidari': bolgeidari,
                   'denetimserbeslik': denetimserbeslik,
                   'personelegitim': personelegitim,
                   'bakanlikbinasi': bakanlikbinasi,
                   'diger': diger,
                   'lojman': lojman,

                   'cezainfaz_dev': cezainfaz_dev,
                   'adaletbinasi_dev': adaletbinasi_dev,
                   'adlitip_dev': adlitip_dev,
                   'bolgeadliye_dev': bolgeadliye_dev,
                   'bolgeidari_dev': bolgeidari_dev,
                   'denetimserbeslik_dev': denetimserbeslik_dev,
                   'personelegitim_dev': personelegitim_dev,
                   'bakanlikbinasi_dev': bakanlikbinasi_dev,
                   'diger_dev': diger_dev,
                   'lojman_dev': lojman_dev,

                   'cezainfaz_tam': cezainfaz_tam,
                   'adaletbinasi_tam': adaletbinasi_tam,
                   'adlitip_tam': adlitip_tam,
                   'bolgeadliye_tam': bolgeadliye_tam,
                   'bolgeidari_tam': bolgeidari_tam,
                   'denetimserbeslik_tam': denetimserbeslik_tam,
                   'personelegitim_tam': personelegitim_tam,
                   'bakanlikbinasi_tam': bakanlikbinasi_tam,
                   'diger_tam': diger_tam,
                   'lojman_tam': lojman_tam,
                   })