예제 #1
0
def forgot(request):
    if request.method == 'POST':
        mail = request.POST.get('username')
        obj = User.objects.filter(username=mail)
        print('ben geldim ')

        if obj.count() != 0:
            user = User.objects.get(username=mail)
            print(user)
            fdk = Forgot(user=user, status=False)
            fdk.save()

            log = general_methods.logwrite(request, " Yeni giris maili gönderildi")

            html_content = ''
            subject, from_email, to = 'Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
            html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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>Yeni şifre oluşturma linki:</strong> <a href="'+settings.SITE_URL+'/sbs/newpassword?query=' + str(
                fdk.uuid) + '">'+settings.SITE_URL+'/sbs/profil-guncelle/?query=' + str(
                fdk.uuid) + '</p></a>'

            msg = EmailMultiAlternatives(subject, '', from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            messages.success(request, "Giriş bilgileriniz mail adresinize gönderildi. ")
            return redirect("accounts:login")
        else:
            messages.warning(request, "Geçerli bir mail adresi giriniz.")
            return redirect("accounts:forgot")

    return render(request, 'registration/forgot-password.html')
예제 #2
0
def send_information(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    if request.method == 'POST' and request.is_ajax():

        user = User.objects.get(pk=pk)

        if not user.is_active:
            return JsonResponse({'status': 'Fail', 'msg': 'Kullanıcıyı aktifleştirin.'})
        fdk = Forgot(user=user, status=False)
        fdk.save()


        html_content = ''
        subject, from_email, to = 'Taekwondo Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>TÜRKİYE TAEKWONDO 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://172.16.5.25/TaekwondoArsiv/newpassword?query=' + str(
            fdk.uuid) + '">http://172.16.5.25/sbs/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        log = str(user.get_full_name()) + " sifre gonderildi"
        log = general_methods.logwrite(request, request.user, log)

        return JsonResponse({'status': 'Success', 'msg': 'Şifre başarıyla gönderildi'})

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
예제 #3
0
def forgot(request):
    if request.method == 'POST':
        mail = request.POST.get('username')
        obj = User.objects.filter(username=mail)

        if obj.count() != 0:
            user = User.objects.get(username=mail)
            fdk = Forgot(user=user, status=False)
            fdk.save()

            html_content = ''
            subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
            html_content = '<h2>TÜRKİYE WUSHU KUNG FU 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://sbs.twf.gov.tr:81/sbs/newpassword?query=' + str(
                fdk.uuid) + '">http://sbs.twf.gov.tr:81/sbs/wushu/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'

            msg = EmailMultiAlternatives(subject, '', from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            messages.success(request, "Giriş bilgileriniz mail adresinize gönderildi. ")
            return redirect("accounts:login")
        else:
            messages.warning(request, "Geçerli bir mail adresi giriniz.")
            return redirect("accounts:forgot")

    return render(request, 'registration/forgot-password.html')
예제 #4
0
def send_information(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    if request.method == 'POST' and request.is_ajax():

        user = User.objects.get(pk=pk)

        if not user.is_active:
            return JsonResponse({
                'status': 'Fail',
                'msg': 'Kullanıcıyı aktifleştirin.'
            })
        fdk = Forgot(user=user, status=False)
        fdk.save()

        html_content = ''
        subject, from_email, to = 'Etut Proje Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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>Yeni şifre oluşturma linki:</strong> <a href="' + settings.SITE_URL + '/sbs/newpassword?query=' + str(
            fdk.uuid
        ) + '">' + settings.SITE_URL + '/sbs/profil-guncelle/?query=' + str(
            fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        log = general_methods.logwrite(
            request, " Yeni giris maili gönderildi" + str(user))

        # password = User.objects.make_random_password()
        # obj.set_password(password)
        # # form.cleaned_data['password'] = make_password(form.cleaned_data['password'])
        # user = obj.save()
        # html_content = ''
        # subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', obj.email
        # text_content = 'Aşağıda ki bilgileri kullanarak sisteme giriş yapabilirsiniz.'
        # html_content = '<p> <strong>Site adresi:</strong> <a href="http://sbs.twf.gov.tr:81"></a>sbs.twf.gov.tr:81</p>'
        # html_content = html_content + '<p><strong>Kullanıcı Adı:</strong>' + obj.username + '</p>'
        # html_content = html_content + '<p><strong>Şifre:</strong>' + password + '</p>'
        # msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        # msg.attach_alternative(html_content, "text/html")
        # msg.send()

        # print(obj.is_active)
        return JsonResponse({
            'status': 'Success',
            'msg': 'Şifre başarıyla gönderildi'
        })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
예제 #5
0
def send_information(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    if request.method == 'POST' and request.is_ajax():

        user = User.objects.get(pk=pk)

        if not user.is_active:
            return JsonResponse({
                'status': 'Fail',
                'msg': 'Kullanıcıyı aktifleştirin.'
            })
        fdk = Forgot(user=user, status=False)
        fdk.save()

        html_content = ''
        subject, from_email, to = 'Spor  Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>TÜRKİYE GÜREŞ 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://sbs.tgf.gov.tr/newpassword?query=' + str(
            fdk.uuid
        ) + '">http://sbs.tgf.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()

        # password = User.objects.make_random_password()
        # obj.set_password(password)
        # # form.cleaned_data['password'] = make_password(form.cleaned_data['password'])
        # user = obj.save()
        # html_content = ''
        # subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', obj.email
        # text_content = 'Aşağıda ki bilgileri kullanarak sisteme giriş yapabilirsiniz.'
        # html_content = '<p> <strong>Site adresi:</strong> <a href="http://sbs.twf.gov.tr:81"></a>sbs.twf.gov.tr:81</p>'
        # html_content = html_content + '<p><strong>Kullanıcı Adı:</strong>' + obj.username + '</p>'
        # html_content = html_content + '<p><strong>Şifre:</strong>' + password + '</p>'
        # msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        # msg.attach_alternative(html_content, "text/html")
        # msg.send()

        # print(obj.is_active)

        log = str(user.get_full_name()) + " sifre gonderildi"
        log = general_methods.logwrite(request, request.user, log)

        return JsonResponse({
            'status': 'Success',
            'msg': 'Şifre başarıyla gönderildi'
        })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
예제 #6
0
def forgot(request):
    if request.method == 'POST':
        mail = request.POST.get('username')
        obj = User.objects.filter(username=mail)
        if obj.count() != 0:
            user = User.objects.get(username=mail)
            user.is_active = True
            user.save()
            print(user)
            fdk = Forgot(user=user, status=False)
            fdk.save()

            html_content = ''
            subject, from_email, to = 'THF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
            html_content = '<h2>TÜRKİYE HALTER 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.halter.gov.tr:81/newpassword?query=' + str(
                fdk.uuid
            ) + '">http://sbs.halter.gov.tr:81/sbs/profil-guncelle/?query=' + str(
                fdk.uuid) + '</p></a>'

            msg = EmailMultiAlternatives(subject, '', from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            log = str(user.get_full_name()) + "yeni şifre emaili gönderildi"
            log = general_methods.logwrite(request, fdk.user, log)

            messages.success(
                request, "Giriş bilgileriniz mail adresinize gönderildi. ")
            return redirect("accounts:login")
        else:
            messages.warning(request, "Geçerli bir mail adresi giriniz.")
            return redirect("accounts:forgot")

    return render(request, 'registration/forgot-password.html')
예제 #7
0
def UserAllMail(request):
    for user in User.objects.all():
        fdk = Forgot(user=user, status=False)
        fdk.save()

        log = general_methods.logwrite(request, " Yeni giris maili gönderildi")

        html_content = ''
        subject, from_email, to = 'Etut Proje Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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>Yeni şifre oluşturma linki:</strong> <a href="' + settings.SITE_URL + '/sbs/newpassword?query=' + str(
            fdk.uuid
        ) + '">' + settings.SITE_URL + '/sbs/profil-guncelle/?query=' + str(
            fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()
        return redirect("sbs:kullanicilar")
예제 #8
0
def newlogin(request, pk):
    clup = SportsClub.objects.get(pk=pk)
    # clüp
    club_form = ClubForm(instance=clup)
    communication_formclup = CommunicationForm(instance=clup.communication)
    # klüp üyesi
    user_form = UserForm()
    person_form = PersonForm()
    communication_form = CommunicationForm()
    sportClubUser_form = SportClubUserForm()

    if request.method == 'POST':
        user_form = UserForm(request.POST)
        person_form = PersonForm(request.POST, request.FILES)
        communication_form = CommunicationForm(request.POST, request.FILES)
        sportClubUser_form = SportClubUserForm(request.POST)

        club_form = ClubForm(request.POST, request.FILES)
        communication_formclup = CommunicationForm(request.POST, request.FILES)

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

            tc = request.POST.get('tc')

            if Coach.objects.get(person__tc=tc):
                # print("Bu degerde elimde tc si olan bir antrenör var ")
                coach = Coach.objects.get(person__tc=tc)
                user = coach.user

                club_person = SportClubUser(
                    user=coach.user,
                    person=coach.person,
                    communication=coach.communication,
                    role=sportClubUser_form.cleaned_data['role'])
                club_person.save()

                group = Group.objects.get(name='KulupUye')
                coach.user.groups.add(group)
                coach.save()

                communication = communication_formclup.save(commit=False)
                communication.save()
                clup.communication = communication
                clup.coachs.add(coach)
                clup.save()
                messages.success(
                    request,
                    'Antrenör şifreniz ile sisteme giriş yapabilirsiniz')
                log = general_methods.logwrite(
                    request, user,
                    "Antrenör klup üyesi olarak giris yaptı new login ")

            else:

                mail = request.POST.get('email')
                if User.objects.filter(
                        email=mail) or ReferenceCoach.objects.filter(
                            email=mail) or ReferenceReferee.objects.filter(
                                email=mail) or PreRegistration.objects.filter(
                                    email=mail):
                    messages.warning(
                        request,
                        'Mail adresi başka bir kullanici tarafından kullanilmaktadir.'
                    )
                    return render(
                        request, 'registration/newlogin.html', {
                            'user_form': user_form,
                            'person_form': person_form,
                            'communication_form': communication_form,
                            'sportClubUser_form': sportClubUser_form,
                            'club_form': club_form,
                            'communication_formclup': communication_formclup
                        })

                tc = request.POST.get('tc')
                if Person.objects.filter(
                        tc=tc) or ReferenceCoach.objects.filter(
                            tc=tc) or ReferenceReferee.objects.filter(
                                tc=tc) or PreRegistration.objects.filter(
                                    tc=tc):
                    messages.warning(
                        request, 'Tc kimlik numarasi sistemde kayıtlıdır. ')
                    return render(
                        request, 'registration/newlogin.html', {
                            'user_form': user_form,
                            'person_form': person_form,
                            'communication_form': communication_form,
                            'sportClubUser_form': sportClubUser_form,
                            'club_form': club_form,
                            'communication_formclup': communication_formclup
                        })

                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/newlogin.html', {
                            'user_form': user_form,
                            'person_form': person_form,
                            'communication_form': communication_form,
                            'sportClubUser_form': sportClubUser_form,
                            'club_form': club_form,
                            'communication_formclup': communication_formclup
                        })

                clup.name = request.POST.get('name')
                clup.shortName = request.POST.get('shortName')
                clup.foundingDate = request.POST.get('foundingDate')
                clup.logo = request.POST.get('logo')
                clup.clubMail = request.POST.get('clubMail')
                clup.petition = request.POST.get('petition')
                clup.isFormal = request.POST.get('isFormal')
                user = User()
                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']
                group = Group.objects.get(name='KulupUye')
                user.save()
                user.groups.add(group)
                user.save()

                communication = communication_formclup.save(commit=False)
                communication.save()
                clup.communication = communication
                clup.save()

                person = person_form.save(commit=False)
                communication = communication_form.save(commit=False)
                person.save()
                communication.save()

                club_person = SportClubUser(
                    user=user,
                    person=person,
                    communication=communication,
                    role=sportClubUser_form.cleaned_data['role'],
                )

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

                html_content = ''
                subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
                html_content = '<h2>TÜRKİYE HALTER 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.halter.gov.tr:81/newpassword?query=' + str(
                    fdk.uuid
                ) + '">http://sbs.halter.gov.tr:81/sbs/profil-guncelle/?query=' + str(
                    fdk.uuid) + '</p></a>'

                msg = EmailMultiAlternatives(subject, '', from_email, [to])
                msg.attach_alternative(html_content, "text/html")
                msg.send()

                messages.success(
                    request,
                    'Mail adresinize gelen link ile sistemde giriş yapabilirsiniz.'
                )

            clup.clubUser.add(club_person)
            clup.dataAccessControl = False
            clup.isRegister = True

            clup.save()
            log = general_methods.logwrite(request, user,
                                           "Eski sifre ile giris yapildi")

            return redirect("accounts:login")

    return render(
        request, 'registration/newlogin.html', {
            'user_form': user_form,
            'person_form': person_form,
            'communication_form': communication_form,
            'sportClubUser_form': sportClubUser_form,
            'club_form': club_form,
            'communication_formclup': communication_formclup
        })
예제 #9
0
def updatejudge(request, tc, pk):
    judge = Judge.objects.filter(person__tc=tc)[0]
    if not (judge.user.groups.all()):
        user = judge.user
        judge.user.groups.add(Group.objects.get(name="Hakem"))
        judge.save()
    groups = Group.objects.all()

    user = User.objects.get(pk=judge.user.pk)
    person = Person.objects.get(pk=judge.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=judge.communication.pk)
    if person.material:
        metarial = Material.objects.get(pk=judge.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 Competition.objects.filter(judges=judge).distinct():
        competitions = Competition.objects.filter(judges=judge).distinct()
    else:
        competitions = Competition.objects.none()

    iban_form = IbanFormJudge(request.POST or None, instance=judge)

    grade_form = judge.grades.all()
    visa_form = judge.visa.all()

    if request.method == "POST":
        name = request.POST.get('first_name')
        surname = request.POST.get('last_name')
        year = request.POST.get('birthDate')
        year = year.split('/')
        mail = request.POST.get('email')
        if mail != judge.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, 'hakem/hakemDuzenle.html', {
                        'user_form': user_form,
                        'communication_form': communication_form,
                        'person_form': person_form,
                        'judge': judge,
                        'grade_form': grade_form,
                        'visa_form': visa_form,
                        'iban_form': iban_form,
                        'groups': groups,
                        'metarial_form': metarial_form
                    })

        tc = request.POST.get('tc')
        if tc != judge.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, 'hakem/hakemDuzenle.html', {
                        'user_form': user_form,
                        'communication_form': communication_form,
                        'person_form': person_form,
                        'judge': judge,
                        'grade_form': grade_form,
                        'visa_form': visa_form,
                        'iban_form': iban_form,
                        'groups': groups,
                        'metarial_form': metarial_form,
                    })

        # 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/JudgeUpdate.html',
        #                   {'user_form': user_form, 'communication_form': communication_form,
        #                    'person_form': person_form, 'judge': judge, 'grade_form': grade_form,
        #                    '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()

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

            iban_form.save()

            person_form.save()

            communication_form.save()
            metarial_form.save()
            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, 'Alanları Kontrol Ediniz')

    return render(
        request, 'registration/JudgeUpdate.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'person_form': person_form,
            'judge': judge,
            'grade_form': grade_form,
            'visa_form': visa_form,
            'iban_form': iban_form,
            'groups': groups,
            'metarial_form': metarial_form,
            'competitions': competitions
        })
    return render(request, 'registration/JudgeUpdate.html')
예제 #10
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 = 'TAEKWONDO Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
                html_content = '<h2>TÜRKİYE TAEKWONDO 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://172.16.5.25/TaekwondoArsiv/newpassword?query=' + str(
                    fdk.uuid
                ) + '">http://172.16.5.25/sbs/profil-guncelle/?query=' + str(
                    fdk.uuid) + '</p></a>'
                # html_content = html_content + '<p> <strong>Site adresi:</strong> <a href="http://sbs.TAEKWONDO.gov.tr/newpassword?query=' + str(
                #     fdk.uuid) + '">http://sbs.TAEKWONDO.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')
예제 #11
0
def approve_preRegistration(request, pk):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    basvuru = PreRegistration.objects.get(pk=pk)
    if basvuru.status != PreRegistration.APPROVED:
        mail = basvuru.email
        if not (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)):

            user = User()
            user.username = basvuru.email
            user.first_name = unicode_tr(basvuru.first_name).upper()
            user.last_name = unicode_tr(basvuru.last_name).upper()
            user.email = basvuru.email
            user.is_active = True
            user.is_staff = basvuru.is_staff
            group = Group.objects.get(name='KlupUye')
            password = User.objects.make_random_password()
            user.set_password(password)
            user.save()
            user.groups.add(group)
            user.save()

            # person kaydet
            person = Person()
            person.tc = basvuru.tc
            person.birthplace = basvuru.birthplace
            person.motherName = basvuru.motherName
            person.fatherName = basvuru.fatherName
            person.profileImage = basvuru.profileImage
            person.birthDate = basvuru.birthDate
            person.bloodType = basvuru.bloodType
            if basvuru.gender == 'Erkek':
                person.gender = Person.MALE
            else:
                person.gender = Person.FEMALE
            person.save()

            # Communication kaydet
            com = Communication()
            com.postalCode = basvuru.postalCode
            com.phoneNumber = basvuru.phoneNumber
            com.phoneNumber2 = basvuru.phoneNumber2
            com.address = basvuru.address
            com.city = basvuru.city
            com.country = basvuru.country
            com.save()

            Sportclup = SportClubUser()
            Sportclup.user = user
            Sportclup.person = person
            Sportclup.communication = com
            Sportclup.role = basvuru.role
            Sportclup.save()

            comclup = Communication()
            comclup.postalCode = basvuru.clubpostalCode
            comclup.phoneNumber = basvuru.clubphoneNumber
            comclup.phoneNumber2 = basvuru.clubphoneNumber2
            comclup.address = basvuru.clubaddress
            comclup.city = basvuru.clubcity
            comclup.country = basvuru.clubcountry
            comclup.save()

            # SportClup
            clup = SportsClub()
            clup.name = basvuru.name
            clup.shortName = basvuru.shortName
            clup.foundingDate = basvuru.foundingDate
            clup.clubMail = basvuru.clubMail
            clup.logo = basvuru.logo
            clup.isFormal = basvuru.isFormal
            clup.petition = basvuru.petition
            clup.communication = comclup
            clup.save()
            clup.clubUser.add(Sportclup)
            clup.save()
            # burada kadik
            if basvuru.isCoach:

                coach = Coach()
                coach.user = user
                coach.person = person
                coach.communication = com
                coach.iban = basvuru.iban
                coach.save()
                group = Group.objects.get(name='Antrenor')
                user.groups.add(group)
                user.save()
                grade = Level(
                    startDate=basvuru.kademe_startDate,
                    dekont=basvuru.kademe_belge,
                    branch=EnumFields.HALTER.value)
                try:
                    grade.definition = CategoryItem.objects.get(name=basvuru.kademe_definition)
                except:
                    grade.definition = CategoryItem.objects.get(name='1.Kademe')

                grade.levelType = EnumFields.LEVELTYPE.GRADE
                grade.status = Level.APPROVED
                grade.isActive = True
                grade.save()
                coach.grades.add(grade)
                coach.save()

                clup.coachs.add(coach)
                clup.save()

            basvuru.status = PreRegistration.APPROVED
            basvuru.save()

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

            html_content = ''
            subject, from_email, to = '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://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()
            messages.success(request, 'Başari ile kaydedildi')

            log = str(clup) + " Klup basvurusu onaylandi"
            log = general_methods.logwrite(request, request.user, log)

            # try:
            #     # user kaydet
            #     print()
            # except:
            #     messages.warning(request, 'Lütfen sistem yöneticisi ile görüşünüz ')
            #     log = str(basvuru.name) + " Klup basvurusu hata oldu"
            #     log = general_methods.logwrite(request, request.user, log)

        else:
            messages.warning(request, 'Mail adresi sistem de kayıtlıdır.')
    else:
        messages.warning(request, 'Bu basvuru sisteme kaydedilmistir.')

    prepegidtration = PreRegistration.objects.all()
    return render(request, 'kulup/kulupBasvuru.html',
                  {'prepegidtration': prepegidtration})
예제 #12
0
def approve_preRegistration(request, pk):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    basvuru = PreRegistration.objects.get(pk=pk)
    if basvuru.status != PreRegistration.APPROVED:
        if not (User.objects.filter(email=basvuru.email).exists()):
            # user kaydet
            try:
                user = User()
                user.username = basvuru.email
                user.first_name = basvuru.first_name
                user.last_name = basvuru.last_name
                user.email = basvuru.email
                user.is_active = basvuru.is_active
                user.is_staff = basvuru.is_staff
                group = Group.objects.get(name='KulupUye')
                password = User.objects.make_random_password()
                user.set_password(password)
                user.save()
                user.groups.add(group)
                user.save()
            except:
                messages.warning(request, ' Kullanici eklenmedi ')

            try:
                # person kaydet
                person = Person()
                person.tc = basvuru.tc
                person.height = basvuru.height
                person.weight = basvuru.weight
                person.birthplace = basvuru.birthplace
                person.motherName = basvuru.motherName
                person.fatherName = basvuru.fatherName
                person.profileImage = basvuru.profileImage
                person.birthDate = basvuru.birthDate
                person.bloodType = basvuru.bloodType
                person.gender = basvuru.gender
                person.save()

            except:
                messages.warning(request, ' Kullanici eklenmedi ')

            try:
                # Communication kaydet
                com = Communication()
                com.postalCode = basvuru.postalCode
                com.phoneNumber = basvuru.phoneNumber
                com.phoneNumber2 = basvuru.phoneNumber2
                com.address = basvuru.address
                com.city = basvuru.city
                com.country = basvuru.country
                com.save()

                Sportclup = SportClubUser()
                Sportclup.user = user
                Sportclup.person = person
                Sportclup.communication = com
                Sportclup.role = basvuru.role
                Sportclup.save()

                comclup = Communication()
                comclup.postalCode = basvuru.clubpostalCode
                comclup.phoneNumber = basvuru.clubphoneNumber
                comclup.phoneNumber2 = basvuru.clubphoneNumber2
                comclup.address = basvuru.clubaddress
                comclup.city = basvuru.clubcity
                comclup.country = basvuru.clubcountry
                comclup.save()

                # SportClup
                clup = SportsClub()
                clup.name = basvuru.name
                clup.shortName = basvuru.shortName
                clup.foundingDate = basvuru.foundingDate
                clup.clubMail = basvuru.clubMail
                clup.logo = basvuru.logo
                clup.isFormal = basvuru.isFormal
                clup.communication = comclup
                clup.save()
                clup.clubUser.add(Sportclup)
                clup.save()

                basvuru.status = PreRegistration.APPROVED
                basvuru.save()
            except:
                messages.success(request, 'Klüp ve iletisim kaydedilemedi')

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

                html_content = ''
                subject, from_email, to = 'THF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
                html_content = '<h2>TÜRKİYE HALTER 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.halter.gov.tr/newpassword?query=' + str(
                    fdk.uuid
                ) + '">http://sbs.halter.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()

                messages.success(
                    request, "Giriş bilgileriniz mail adresinize gönderildi. ")
            except:
                messages.success(request, "Mail Gönderilemedi")

        else:
            messages.warning(request, 'Mail adresi sistem de kayıtlıdır. ')
    else:
        messages.warning(request, 'Bu basvuru sisteme kaydedilmistir.')

    prepegidtration = PreRegistration.objects.all()
    return render(request, 'kulup/kulupBasvuru.html',
                  {'prepegidtration': prepegidtration})
예제 #13
0
def newlogin(request, pk):
    clup = SportsClub.objects.get(pk=pk)
    # clüp
    club_form = ClubForm(instance=clup)
    communication_formclup = CommunicationForm(instance=clup.communication)
    # klüp üyesi
    user_form = UserForm()
    person_form = PersonForm()
    communication_form = CommunicationForm()
    sportClubUser_form = SportClubUserForm()

    if request.method == 'POST':
        user_form = UserForm(request.POST)
        person_form = PersonForm(request.POST, request.FILES)
        communication_form = CommunicationForm(request.POST, request.FILES)
        sportClubUser_form = SportClubUserForm(request.POST)

        club_form = ClubForm(request.POST, request.FILES)
        communication_formclup = CommunicationForm(request.POST, request.FILES)

        if club_form.is_valid() and user_form.is_valid(
        ) and person_form.is_valid() and communication_form.is_valid(
        ) and sportClubUser_form.is_valid():
            clup.name = request.POST.get('name')
            clup.shortName = request.POST.get('shortName')
            clup.foundingDate = request.POST.get('foundingDate')
            clup.logo = request.POST.get('logo')
            clup.clubMail = request.POST.get('clubMail')
            clup.isFormal = request.POST.get('isFormal')

            communication = communication_formclup.save(commit=False)
            communication.save()
            clup.communication = communication
            clup.save()

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

            user = User()
            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']
            group = Group.objects.get(name='KulupUye')
            user.save()
            user.groups.add(group)
            user.save()

            person = person_form.save(commit=False)
            communication = communication_form.save(commit=False)
            person.save()
            communication.save()

            club_person = SportClubUser(
                user=user,
                person=person,
                communication=communication,
                role=sportClubUser_form.cleaned_data['role'],
            )

            club_person.save()

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

            html_content = ''
            html_content = ''
            subject, from_email, to = 'Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
            html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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://kobiltek.com:81/etutproje/newpassword?query=' + str(
                fdk.uuid
            ) + '">http://kobiltek.com:81/etutproje/sbs/profil-guncelle/?query=' + str(
                fdk.uuid) + '</p></a>'

            msg = EmailMultiAlternatives(subject, '', from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            clup.clubUser.add(club_person)
            clup.dataAccessControl = True
            clup.save()
            messages.success(
                request,
                'Mail adresinize gelen link ile sisteme giriş yapabilirsiniz.')
            return redirect("accounts:login")

        # try:
        #
        #
        # except:
        #     messages.warning(request, 'Lütfen Yeniden Deneyiniz')
        #     return redirect("accounts:login")

    return render(
        request, 'registration/newlogin.html', {
            'user_form': user_form,
            'person_form': person_form,
            'communication_form': communication_form,
            'sportClubUser_form': sportClubUser_form,
            'club_form': club_form,
            'communication_formclup': communication_formclup
        })