def updateReferee(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') judge = Judge.objects.get(pk=pk) user = User.objects.get(pk=judge.user.pk) person = Person.objects.get(pk=judge.person.pk) communication = Communication.objects.get(pk=judge.communication.pk) user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) grade_form = judge.grades.all() visa_form = judge.visa.all() if request.method == 'POST': if user_form.is_valid() and person_form.is_valid() and communication_form.is_valid(): user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'].upper() user.last_name = user_form.cleaned_data['last_name'].upper() user.email = user_form.cleaned_data['email'] user.save() person_form.save() communication_form.save() messages.success(request, 'Hakem Başarıyla Güncellendi') return redirect('sbs:hakemler') else: messages.warning(request, 'Alanları Kontrol Ediniz') 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})
def update_user(request, pk): user = User.objects.get(pk=pk) user_form = UserForm(request.POST or None, instance=user) if request.method == 'POST': if user_form.is_valid(): 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() update_session_auth_hash(request, user) messages.success(request, 'Kullanıcı Başarıyla Güncellendi') return redirect('sbs:kullanicilar') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'kullanici/kullanici-duzenle.html', {'user_form': user_form})
def return_add_referee(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() if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST) if user_form.is_valid() and person_form.is_valid() and communication_form.is_valid(): user = User() user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'].upper() user.last_name = user_form.cleaned_data['last_name'].upper() user.email = user_form.cleaned_data['email'] group = Group.objects.get(name='Hakem') password = User.objects.make_random_password() user.set_password(password) user.is_active = False user.save() user.groups.add(group) user.save() person = person_form.save(commit=False) communication = communication_form.save(commit=False) person.save() communication.save() judge = Judge(user=user, person=person, communication=communication) judge.save() # subject, from_email, to = 'Halter - Hakem Bilgi Sistemi Kullanıcı Giriş Bilgileri', '[email protected]:81', 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<</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, 'Hakem Başarıyla Kayıt Edilmiştir.') return redirect('sbs:hakemler') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render(request, 'hakem/hakem-ekle.html', {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form})
def coachUpdate(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') coach = Coach.objects.get(pk=pk) grade_form = coach.grades.all() visa_form = coach.visa.all() user = User.objects.get(pk=coach.user.pk) person = Person.objects.get(pk=coach.person.pk) communication = Communication.objects.get(pk=coach.communication.pk) user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, request.FILES or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) if request.method == 'POST': user = User.objects.get(pk=coach.user.pk) user_form = UserForm(request.POST or None, instance=user) # person_form = PersonForm(request.POST,request.FILES, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) if user_form.is_valid() and person_form.is_valid( ) and communication_form.is_valid(): user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'].upper() user.last_name = user_form.cleaned_data['last_name'].upper() user.email = user_form.cleaned_data['email'] user = user_form.save(commit=False) user.username = user_form.cleaned_data['email'] user.save() person_form.save() communication_form.save() messages.success(request, 'Antrenör Başarıyla Güncellendi') return redirect('sbs:antrenorler') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render( request, 'antrenor/antrenorDuzenle.html', { 'user_form': user_form, 'communication_form': communication_form, 'person_form': person_form, 'grades_form': grade_form, 'coach': coach.pk, 'personCoach': person, 'visa_form': visa_form })
def updateClubPersons(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') athlete = SportClubUser.objects.get(pk=pk) user = User.objects.get(pk=athlete.user.pk) person = Person.objects.get(pk=athlete.person.pk) communication = Communication.objects.get(pk=athlete.communication.pk) # sportClub = athlete.sportClub user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) sportClubUser_form = SportClubUserForm(request.POST or None, instance=athlete) clubs = SportsClub.objects.filter(clubUser__user=user) if request.method == 'POST': if user_form.is_valid() and communication_form.is_valid( ) and person_form.is_valid() and sportClubUser_form.is_valid(): user = user_form.save(commit=False) user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'] user.last_name = user_form.cleaned_data['last_name'] user.email = user_form.cleaned_data['email'] user.save() person_form.save() communication_form.save() sportClubUser_form.save() messages.success(request, 'Kulüp Üyesi Başarıyla Güncellenmiştir.') return redirect('sbs:kulup-uyeleri') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render( request, 'kulup/kulup-uyesi-duzenle.html', { 'user_form': user_form, 'communication_form': communication_form, 'person_form': person_form, 'sportClubUser_form': sportClubUser_form, 'clubs': clubs })
def updateathletes(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') athlete = Athlete.objects.get(pk=pk) belts_form = athlete.belts.all() licenses_form = athlete.licenses.all() user = User.objects.get(pk=athlete.user.pk) person = Person.objects.get(pk=athlete.person.pk) communication = Communication.objects.get(pk=athlete.communication.pk) user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) say = 0 say = athlete.licenses.all().filter(status='Onaylandı').count() if request.method == 'POST': if user_form.is_valid() and communication_form.is_valid( ) and person_form.is_valid(): user = user_form.save(commit=False) print('user='******'email'] user.first_name = user_form.cleaned_data['first_name'].upper() user.last_name = user_form.cleaned_data['last_name'].upper() user.email = user_form.cleaned_data['email'] user.save() person_form.save() communication_form.save() messages.success(request, 'Sporcu Başarıyla Güncellenmiştir.') return redirect('sbs:update-athletes', pk=pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render( request, 'sporcu/sporcuDuzenle.html', { 'user_form': user_form, 'communication_form': communication_form, 'person_form': person_form, 'belts_form': belts_form, 'licenses_form': licenses_form, 'athlete': athlete, 'say': say })
def update_directory_member(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') member = DirectoryMember.objects.get(pk=pk) user = User.objects.get(pk=member.user.pk) person = Person.objects.get(pk=member.person.pk) communication = Communication.objects.get(pk=member.communication.pk) user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) member_form = DirectoryForm(request.POST or None, instance=member) if request.method == 'POST': if user_form.is_valid() and person_form.is_valid( ) and communication_form.is_valid() and member_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() person_form.save() communication_form.save() member_form.save() messages.success(request, 'Yönetim Kurulu Üyesi Başarıyla Güncellendi') return redirect('sbs:kurul-uyeleri') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render( request, 'yonetim/kurul-uyesi-duzenle.html', { 'user_form': user_form, 'communication_form': communication_form, 'person_form': person_form, 'member_form': member_form })
def add_directory_member(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() member_form = DirectoryForm() if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST) member_form = DirectoryForm(request.POST) if user_form.is_valid() and person_form.is_valid( ) and communication_form.is_valid() and member_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='Yonetim') 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() directoryMember = DirectoryMember(user=user, person=person, communication=communication) directoryMember.role = member_form.cleaned_data['role'] directoryMember.save() # mail gönderimi yapılacak # subject, from_email, to = 'Adalet - Yönetim/ Bilgi Sistemi Kullanıcı Giriş Bilgileri', '*****@*****.**', user.email # text_content = 'Aşağıda ki bilgileri kullanarak sisteme giriş yapabilirsiniz.' # 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, 'Yönetim Kurulu Üyesi Başarıyla Kayıt Edilmiştir.') return redirect('sbs:kurul-uyeleri') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render( request, 'yonetim/kurul-uyesi-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'member_form': member_form })
def add_employe(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() unit_form = EmployeUnitForm() if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST) unit_form = EmployeUnitForm(request.POST) # controller tc email 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, 'personel/personelEkle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'unit_form': unit_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 sistemde kayıtlıdır. ') return render( request, 'personel/personelEkle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_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-ekle.html', # # {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, # # 'member_form': member_form}) if user_form.is_valid() and person_form.is_valid( ) and communication_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='Personel') 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() employe = Employe(user=user, person=person, communication=communication) print(request.POST.get('birim')) employe.birim = Abirim.objects.get( pk=int(request.POST.get('birim'))) employe.save() log = str(user.get_full_name()) + " Personel kaydedildi" log = general_methods.logwrite(request, request.user, log) messages.success(request, 'Personel Başarıyla Kayıt Edilmiştir.') return redirect('sbs:birim-personel-duzenle', employe.pk) else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render( request, 'personel/personelEkle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'unit_form': unit_form })
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 })
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 edit_employee(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') employee = Employee.objects.get(pk=pk) user = User.objects.get(pk=employee.user.pk) person = Person.objects.get(pk=employee.person.pk) communication = Communication.objects.get(pk=employee.communication.pk) user_form = UserForm(request.POST or None, instance=user) person_form = PersonForm(request.POST or None, request.FILES or None, instance=person) communication_form = CommunicationForm(request.POST or None, instance=communication) employee_form = EmployeeForm(request.POST or None, instance=employee) employee_form.fields['workDefinition'].queryset = CategoryItem.objects.filter( forWhichClazz="EMPLOYEE_WORKDEFINITION") projects=EPProject.objects.filter(employees__employee__user=user ).distinct() projects|=EPProject.objects.filter(sorumlu__user=user).distinct() cezainfaz = int(projects.filter(projeCinsi=EPProject.CIK).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adaletbinasi =int(projects.filter(projeCinsi=EPProject.AB).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adlitip = int(projects.filter(projeCinsi=EPProject.AT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeadliye = int(projects.filter(projeCinsi=EPProject.BAM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeidari = int(projects.filter(projeCinsi=EPProject.BIM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) denetimserbeslik = int(projects.filter(projeCinsi=EPProject.DS).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) personelegitim = int(projects.filter(projeCinsi=EPProject.PEM).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bakanlikbinasi = int(projects.filter(projeCinsi=EPProject.BB).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) diger = int(projects.filter(projeCinsi=EPProject.DIGER).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) lojman = int(projects.filter(projeCinsi=EPProject.LOJMAN).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) cezainfaz_tam = int(projects.filter(projeCinsi=EPProject.CIK,projectStatus=EPProject.PT).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adaletbinasi_tam =int(projects.filter(projeCinsi=EPProject.AB,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adlitip_tam = int(projects.filter(projeCinsi=EPProject.AT,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeadliye_tam = int(projects.filter(projeCinsi=EPProject.BAM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeidari_tam = int(projects.filter(projeCinsi=EPProject.BIM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) denetimserbeslik_tam = int( projects.filter(projeCinsi=EPProject.DS, projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))[ 'insaatAlani__sum'] or 0) personelegitim_tam = int(projects.filter(projeCinsi=EPProject.PEM,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bakanlikbinasi_tam = int(projects.filter(projeCinsi=EPProject.BB,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) diger_tam = int(projects.filter(projeCinsi=EPProject.DIGER,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) lojman_tam = int(projects.filter(projeCinsi=EPProject.LOJMAN,projectStatus=EPProject.PT).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) cezainfaz_dev = int(projects.filter(projeCinsi=EPProject.CIK,projectStatus=EPProject.PDE).distinct().aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adaletbinasi_dev =int(projects.filter(projeCinsi=EPProject.AB,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) adlitip_dev = int(projects.filter(projeCinsi=EPProject.AT,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeadliye_dev = int(projects.filter(projeCinsi=EPProject.BAM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bolgeidari_dev = int(projects.filter(projeCinsi=EPProject.BIM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) denetimserbeslik_dev = int( projects.filter(projeCinsi=EPProject.DS, projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))[ 'insaatAlani__sum'] or 0) personelegitim_dev = int(projects.filter(projeCinsi=EPProject.PEM,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) bakanlikbinasi_dev = int(projects.filter(projeCinsi=EPProject.BB,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) diger_dev = int(projects.filter(projeCinsi=EPProject.DIGER,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) lojman_dev = int(projects.filter(projeCinsi=EPProject.LOJMAN,projectStatus=EPProject.PDE).aggregate(Sum('insaatAlani'))['insaatAlani__sum'] or 0) # bildirimden gelinmisse ve sistem deki kisinin ise true yap daha görülmesin get = request.GET.get('notification') if get: notification = Notification.objects.get(pk=int(get)) if notification.users == request.user: notification.is_show = True notification.save() if request.method == 'POST': if user_form.is_valid() and communication_form.is_valid() and person_form.is_valid() and employee_form.is_valid(): user = user_form.save(commit=False) user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'] user.last_name = user_form.cleaned_data['last_name'] user.email = user_form.cleaned_data['email'] user.save() person_form.save() communication_form.save() employee_form.save() log = str(user.get_full_name()) + " personel güncellendi" log = general_methods.logwrite(request, log) messages.success(request, 'Personel Başarıyla Güncellenmiştir.') # return redirect('sbs:personeller') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render(request, 'personel/personel-duzenle.html', {'user_form': user_form, 'communication_form': communication_form, 'person_form': person_form, 'employee_form': employee_form,'projects':projects,'personel':user, 'cezainfaz': cezainfaz, 'adaletbinasi': adaletbinasi, 'adlitip': adlitip, 'bolgeadliye': bolgeadliye, 'bolgeidari': bolgeidari, 'denetimserbeslik': denetimserbeslik, 'personelegitim': personelegitim, 'bakanlikbinasi': bakanlikbinasi, 'diger': diger, 'lojman': lojman, 'cezainfaz_dev': cezainfaz_dev, 'adaletbinasi_dev': adaletbinasi_dev, 'adlitip_dev': adlitip_dev, 'bolgeadliye_dev': bolgeadliye_dev, 'bolgeidari_dev': bolgeidari_dev, 'denetimserbeslik_dev': denetimserbeslik_dev, 'personelegitim_dev': personelegitim_dev, 'bakanlikbinasi_dev': bakanlikbinasi_dev, 'diger_dev': diger_dev, 'lojman_dev': lojman_dev, 'cezainfaz_tam': cezainfaz_tam, 'adaletbinasi_tam': adaletbinasi_tam, 'adlitip_tam': adlitip_tam, 'bolgeadliye_tam': bolgeadliye_tam, 'bolgeidari_tam': bolgeidari_tam, 'denetimserbeslik_tam': denetimserbeslik_tam, 'personelegitim_tam': personelegitim_tam, 'bakanlikbinasi_tam': bakanlikbinasi_tam, 'diger_tam': diger_tam, 'lojman_tam': lojman_tam, })
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 return_add_athlete(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() # lisans ekleme baslangıç # klüp üyesi sadece kendi klüplerini görebiliyor user = request.user license_form = LicenseForm(request.POST, request.FILES or None) if user.groups.filter(name='KulupUye'): sc_user = SportClubUser.objects.get(user=user) clubs = SportsClub.objects.filter(clubUser=sc_user) clubsPk = [] for club in clubs: clubsPk.append(club.pk) license_form.fields['sportsClub'].queryset = SportsClub.objects.filter( id__in=clubsPk) elif user.groups.filter(name__in=['Yonetim', 'Admin']): license_form.fields['sportsClub'].queryset = SportsClub.objects.all() # lisan ekleme son alani bu alanlar sadece form bileselerinin sisteme gidebilmesi icin post ile gelen veride gene ayni şekilde karşılama ve kaydetme islemi yapilacak if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST) license_form = LicenseForm(request.POST, request.FILES or None) if user_form.is_valid() and person_form.is_valid( ) and license_form.is_valid() and communication_form.is_valid(): user = User() user.username = user_form.cleaned_data['email'] user.first_name = user_form.cleaned_data['first_name'].upper() user.last_name = user_form.cleaned_data['last_name'].upper() user.email = user_form.cleaned_data['email'] group = Group.objects.get(name='Sporcu') password = User.objects.make_random_password() user.set_password(password) user.is_active = False user.save() user.groups.add(group) user.save() person = person_form.save(commit=False) communication = communication_form.save(commit=False) person.save() communication.save() athlete = Athlete( user=user, person=person, communication=communication, ) # lisans kaydedildi kakydetmeden id degeri alamayacagi icin önce kaydedip sonra ekleme islemi yaptık license = license_form.save() athlete.save() athlete.licenses.add(license) # subject, from_email, to = 'WUSHU - Sporcu 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="https://www.twf.gov.tr/"></a>https://www.twf.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() messages.success(request, 'Sporcu Başarıyla Kayıt Edilmiştir.') return redirect('sbs:sporcular') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render( request, 'sporcu/sporcu-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'license_form': license_form, 'communication_form': communication_form })
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, })
def add_employee(request): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') user_form = UserForm() person_form = PersonForm() communication=Communication() country=Country.objects.get(name='Türkiye') communication.country=country communication_form = CommunicationForm(instance=communication) employee_form = EmployeeForm() employee_form.fields['workDefinition'].queryset = CategoryItem.objects.filter(forWhichClazz="EMPLOYEE_WORKDEFINITION") if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST , request.FILES or None) communication_form = CommunicationForm(request.POST, request.FILES) sportClubUser_form = EmployeeForm(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='Teknik') 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() personel = Employee( user=user, person=person, communication=communication, workDefinition=sportClubUser_form.cleaned_data['workDefinition'], ) personel.save() messages.success(request, 'Personel Başarıyla Kayıt Edilmiştir.') return redirect('sbs:personeller-teknik') else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render(request, 'personel/personel-ekle.html', {'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'employee_form': employee_form, })
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 })
def add_directory_member(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() member_form = DirectoryForm() if request.method == 'POST': user_form = UserForm(request.POST) person_form = PersonForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST) member_form = DirectoryForm(request.POST) # controller tc email 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, 'yonetim/kurul-uyesi-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'member_form': member_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 sistemde kayıtlıdır. ') return render( request, 'yonetim/kurul-uyesi-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'member_form': member_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-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'member_form': member_form }) if user_form.is_valid() and person_form.is_valid( ) and communication_form.is_valid() and member_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='Yonetim') 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() directoryMember = DirectoryMember(user=user, person=person, communication=communication) directoryMember.role = member_form.cleaned_data['role'] directoryMember.commission = member_form.cleaned_data['commission'] directoryMember.save() # subject, from_email, to = 'Halter - Yönetim/Federasyon 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() log = str(user.get_full_name()) + " Kurul Uyesi kaydedildi" log = general_methods.logwrite(request, request.user, log) messages.success(request, 'Kurul Üyesi Başarıyla Kayıt Edilmiştir.') return redirect('sbs:kurul-uyesi-duzenle', directoryMember.pk) else: for x in user_form.errors.as_data(): messages.warning(request, user_form.errors[x][0]) return render( request, 'yonetim/kurul-uyesi-ekle.html', { 'user_form': user_form, 'person_form': person_form, 'communication_form': communication_form, 'member_form': member_form })
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 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')