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, })
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')
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 })
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')