コード例 #1
0
def activeGroup(request, pk):
    group = Group.objects.get(name=request.GET.get('group'))
    pk = request.GET.get('pk')
    communication = Communication.objects.get(
        pk=request.GET.get('communication'))
    person = Person.objects.get(pk=request.GET.get('person'))
    user = User.objects.get(pk=request.GET.get('user'))

    if group.name == "Antrenor":
        coach = Coach(person=person, communication=communication, user=user)
        coach.save()
        user.groups.add(group)
        user.save()
        return redirect('sbs:update-coach', pk=coach.pk)
    elif group.name == "Hakem":
        judge = Judge(person=person, communication=communication, user=user)
        judge.save()
        user.groups.add(group)
        user.save()
        return redirect('sbs:hakem-duzenle', pk=judge.pk)
    elif group.name == "Admin":
        user.groups.add(group)
        user.is_superuser = True
        user.is_staff = True
        user.is_active = True
        user.save()
        return redirect('sbs:admin')
    elif group.name == "KlupUye":
        clupuser = SportClubUser(person=person,
                                 communication=communication,
                                 user=user,
                                 role=ClubRole.objects.all()[0])
        clupuser.save()
        user.groups.add(group)
        user.save()
        return redirect('sbs:kulup-uyesi-guncelle', pk=clupuser.pk)
    elif group.name == "Sporcu":
        athlete = Athlete(person=person,
                          communication=communication,
                          user=user)
        athlete.save()
        user.groups.add(group)
        user.save()
        return redirect('sbs:update-athletes', pk=athlete.pk)
    elif group.name == "Yonetim":
        member = DirectoryMember(
            person=person,
            communication=communication,
            user=user,
            role=DirectoryMemberRole.objects.all()[0],
            commission=DirectoryCommission.objects.all()[0])
        member.save()
        user.groups.add(group)
        user.save()
        return redirect('sbs:kurul-uyesi-duzenle', pk=member.pk)
    return {}
コード例 #2
0
def return_add_club_person(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    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)

        mail = request.POST.get('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-ekle.html',
                          {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form,
                           'sportClubUser_form': sportClubUser_form,
                           })

        tc = request.POST.get('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-ekle.html',
                          {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form,
                           'sportClubUser_form': sportClubUser_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-ekle.html',
        #                   {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form,
        #                    'sportClubUser_form': sportClubUser_form,
        #                    })

        if user_form.is_valid() and person_form.is_valid() and communication_form.is_valid() and sportClubUser_form.is_valid():
            user = User()
            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']
            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 = 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()

            subject, from_email, to = 'BADMİNTON - Kulüp Üye Bilgi Sistemi Kullanıcı Giriş Bilgileri', '*****@*****.**', user.email
            text_content = 'Aşağıda ki bilgileri kullanarak sisteme giriş yapabilirsiniz.'
            html_content = '<p> <strong>Site adresi: </strong> <a href="http://sbs.badminton.gov.tr/"></a>sbs.badminton.gov.tr</p>'
            html_content = html_content + '<p><strong>Kullanıcı Adı:  </strong>' + user.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()

            log = str(user.get_full_name()) + " Klupuyesi eklendi"
            log = general_methods.logwrite(request, request.user, log)

            messages.success(request, 'Kulüp Üyesi Başarıyla Kayıt Edilmiştir.')

            return redirect('sbs:kulup-uyesi-guncelle', club_person.pk)

        else:

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

    return render(request, 'kulup/kulup-uyesi-ekle.html',
                  {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form,
                   'sportClubUser_form': sportClubUser_form,
                   })
コード例 #3
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
        })
コード例 #4
0
def import_csv():
    doc_root = settings.BASE_DIR + '/media/wushu_csv.csv'
    with open(doc_root) as csv_file:
        file_reader = csv.reader(csv_file, delimiter=';')
        next(file_reader, None)  # skip the headers
        for row in file_reader:
            club = SportsClub()
            club.name = row[14]
            club.shortName = row[15]
            club.foundingDate = row[16]

            club.save()

            comClub = Communication()
            comClub.city = City.objects.get(name__icontains=row[18].strip())
            comClub.phoneNumber = row[17]
            comClub.address = row[19]
            comClub.country = Country.objects.get(name__icontains="TÜRKİYE")
            comClub.save()

            club.comminication = comClub

            club.save()

            user = User()
            user.first_name = row[1]
            user.last_name = row[2]
            user.username = row[10]

            password = User.objects.make_random_password()
            user.set_password(password)
            user.save()

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

            person = Person()
            person.tc = row[0]
            person.motherName = row[3]
            person.fatherName = row[4]
            person.gender = row[5]
            person.birthDate = row[7]
            person.birthplace = row[6]
            person.bloodType = row[8]
            person.save()

            comClubUser = Communication()
            comClubUser.city = City.objects.get(
                name__icontains=row[12].strip())
            comClubUser.phoneNumber = row[11]
            comClubUser.address = row[13]
            comClubUser.country = Country.objects.get(name="TÜRKİYE")
            comClubUser.save()

            sportClubUser = SportClubUser()
            sportClubUser.person = person
            sportClubUser.user = user
            sportClubUser.communication = comClubUser
            sportClubUser.sportClub = club
            sportClubUser.role = ClubRole.objects.get(
                name__icontains=row[9].strip())

            sportClubUser.save()

            print(row)
コード例 #5
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})
コード例 #6
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})
コード例 #7
0
ファイル: views.py プロジェクト: ismailyegin/etutproje
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
        })
コード例 #8
0
def return_add_club_person(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    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)

        if user_form.is_valid() and person_form.is_valid(
        ) and communication_form.is_valid() and sportClubUser_form.is_valid():
            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')
            password = User.objects.make_random_password()
            user.set_password(password)
            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()

            subject, from_email, to = 'Halter - Kulüp Üye Bilgi Sistemi Kullanıcı Giriş Bilgileri', '*****@*****.**', user.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>' + user.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()

            messages.success(request,
                             'Kulüp Üyesi Başarıyla Kayıt Edilmiş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-ekle.html', {
            'user_form': user_form,
            'person_form': person_form,
            'communication_form': communication_form,
            'sportClubUser_form': sportClubUser_form,
        })