def kademe_onay(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') grade = Level.objects.get(pk=grade_pk) referee = Judge.objects.get(pk=referee_pk) try: for item in referee.grades.all(): if item.branch == grade.branch: item.isActive = False item.save() grade.status = Level.APPROVED grade.isActive = True grade.save() mesaj = str( referee.user.get_full_name()) + ' Kademe onaylandı ' + str( grade.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kademe Onaylanmıştır') except: messages.warning(request, 'Lütfen yeniden deneyiniz.') return redirect('wushu:hakem-duzenle', pk=referee_pk)
def sporcu_kusak_onayla(request, belt_pk, athlete_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') try: belt = Level.objects.get(pk=belt_pk) athlete = Athlete.objects.get(pk=athlete_pk) for item in athlete.belts.all(): if item.branch == belt.branch: item.isActive = False item.save() belt.status = Level.APPROVED belt.isActive = True belt.save() mesaj = str( athlete.user.get_full_name()) + ' kuşak onaylandi ' + str( belt.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kuşak Onaylanmıştır') except: messages.warning(request, 'Yeniden deneyiniz.') return redirect('wushu:update-athletes', pk=athlete_pk)
def musabaka_duzenle(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') musabaka = Competition.objects.get(pk=pk) categori = musabaka.categori.none() athletes = SandaAthlete.objects.none() if musabaka.subBranch == EnumFields.SANDA: athletes = SandaAthlete.objects.filter(competition=musabaka.pk) if musabaka.subBranch == 'TAOLU': categori = musabaka.categori.all() competition_form = CompetitionForm(request.POST or None, instance=musabaka) if request.method == 'POST': if competition_form.is_valid(): competition = competition_form.save(commit=False) competition.save() mesaj = str(competition.name) + ' müsabaka güncellendi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Müsabaka Başarıyla Güncellenmiştir.') return redirect('wushu:musabaka-duzenle', pk=pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'musabaka/musabaka-duzenle.html', {'competition_form': competition_form, 'competition': musabaka, 'athletes': athletes, 'categori': categori})
def musabaka_ekle(request): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') competition_form = CompetitionForm() if request.method == 'POST': competition_form = CompetitionForm(request.POST) if competition_form.is_valid(): competition = competition_form.save(commit=False) competition.save() mesaj = str(competition.name) + ' müsabaka ekledi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Müsabaka Başarıyla Kaydedilmiştir.') return redirect('wushu:musabakalar') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'musabaka/musabaka-ekle.html', {'competition_form': competition_form})
def active_user(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') if request.method == 'POST' and request.is_ajax(): obj = User.objects.get(pk=pk) if obj.is_active: obj.is_active = False obj.save() else: obj.is_active = True obj.save() print(obj.is_active) mesaj = str(obj.get_full_name()) + ' kullanici durumu degiştirildi. ' + str(obj.is_active) log = general_methods.logwrite(request, request.user, mesaj) return JsonResponse({'status': 'Success', 'messages': 'save successfully'}) else: return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
def sporcu_kusak_sil(request, pk, athlete_pk): if request.method == 'POST' and request.is_ajax(): try: obj = Level.objects.get(pk=pk) athlete = Athlete.objects.get(pk=athlete_pk) mesaj = str( athlete.user.get_full_name()) + ' Kuşak silindi ' + str( obj.pk) log = general_methods.logwrite(request, request.user, mesaj) athlete.belts.remove(obj) obj.delete() return JsonResponse({ 'status': 'Success', 'messages': 'save successfully' }) except Level.DoesNotExist: return JsonResponse({ 'status': 'Fail', 'msg': 'Object does not exist' }) else: return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
def sporcu_lisans_sil(request, pk, athlete_pk): perm = general_methods.control_access_klup(request) if not perm: logout(request) return redirect('accounts:login') if request.method == 'POST' and request.is_ajax(): try: obj = License.objects.get(pk=pk) athlete = Athlete.objects.get(pk=athlete_pk) mesaj = str( athlete.user.get_full_name()) + ' Lisans silindi ' + str( obj.pk) log = general_methods.logwrite(request, request.user, mesaj) athlete.licenses.remove(obj) obj.delete() return JsonResponse({ 'status': 'Success', 'messages': 'save successfully' }) except Level.DoesNotExist: return JsonResponse({ 'status': 'Fail', 'msg': 'Object does not exist' }) else: return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
def sporcu_lisans_onayla(request, license_pk, athlete_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') try: athlete = Athlete.objects.get(pk=athlete_pk) license = License.objects.get(pk=license_pk) for item in athlete.licenses.all(): if item.branch == license.branch: item.isActive = False item.save() license.status = License.APPROVED license.isActive = True license.save() mesaj = str( athlete.user.get_full_name()) + ' Lisans onaylandi ' + str( license.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Lisans Onaylanmıştır') except: messages.warning(request, 'Yeniden deneyiniz.') return redirect('wushu:update-athletes', pk=athlete_pk)
def vize_update(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') grade = Level.objects.get(pk=grade_pk) referee = Judge.objects.get(pk=referee_pk) grade_form = VisaForm(request.POST or None, request.FILES or None, instance=grade) if request.method == 'POST': if grade_form.is_valid(): grade.save() if grade.status != Level.APPROVED: grade.status = Level.WAITED grade.save() mesaj = str(referee.user.get_full_name() ) + ' Hakem vize güncellendi ' + str(grade.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Vize Başarılı bir şekilde güncellenmiştir.') return redirect('wushu:hakem-duzenle', pk=referee_pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'hakem/hakem-vize-güncelle.html', {'grade_form': grade_form})
def vize_update(request, grade_pk, coach_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') grade = Level.objects.get(pk=grade_pk) coach = Coach.objects.get(pk=coach_pk) grade_form = VisaForm(request.POST or None, request.FILES or None, instance=grade) if request.method == 'POST': if grade_form.is_valid(): grade.save() mesaj = str(coach.user.get_full_name( )) + ' Antrenör vize güncellenmiştir. ' + str(grade.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Vize Başarılı bir şekilde güncellenmiştir.') return redirect('wushu:update-coach', pk=coach_pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'antrenor/Vize-update.html', {'grade_form': grade_form})
def vize_delete(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') if request.method == 'POST' and request.is_ajax(): try: obj = Level.objects.get(pk=grade_pk) referee = Judge.objects.get(pk=referee_pk) mesaj = str(referee.user.get_full_name() ) + ' Hakem vize silindi ' + str(obj.pk) log = general_methods.logwrite(request, request.user, mesaj) referee.visa.remove(obj) obj.delete() return JsonResponse({ 'status': 'Success', 'messages': 'save successfully' }) except Level.DoesNotExist: return JsonResponse({ 'status': 'Fail', 'msg': 'Object does not exist' }) else: return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
def clubUpdate(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') club = SportsClub.objects.get(pk=pk) com_id = club.communication.pk communication = Communication.objects.get(id=com_id) club_form = ClubForm(request.POST or None, instance=club) communication_form = CommunicationForm(request.POST or None, instance=communication) clubPersons = club.clubUser.all() clubCoachs = club.coachs.all() if request.method == 'POST': if club_form.is_valid(): club_form.save() communication_form.save() mesaj = str(club.name) + ' klüp güncellendi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Başarıyla Güncellendi') return redirect('wushu:kulupler') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'kulup/kulupDuzenle.html', {'club_form': club_form, 'communication_form': communication_form, 'clubPersons': clubPersons, 'club': club, 'clubCoachs': clubCoachs})
def musabaka_duzenle(request, pk): perm = general_methods.control_access_klup(request) if not perm: logout(request) return redirect('accounts:login') musabaka = Competition.objects.get(pk=pk) categori = musabaka.categori.none() athletes = SandaAthlete.objects.none() user = request.user if request.user.groups.filter(name='KulupUye'): competition_form = DisabledCompetitionForm(request.POST or None, instance=musabaka) if musabaka.subBranch == EnumFields.SANDA.value: sc_user = SportClubUser.objects.get(user=user) clubsPk = [] clubs = SportsClub.objects.filter(clubUser=sc_user) for club in clubs: clubsPk.append(club.pk) athletes = SandaAthlete.objects.filter(athlete__licenses__sportsClub__in=clubsPk, competition=musabaka.pk).distinct() if musabaka.subBranch == EnumFields.TAOLU.value: categori = musabaka.categori.all() elif request.user.groups.filter(name__in=['Yonetim', 'Admin']): competition_form = CompetitionForm(request.POST or None, instance=musabaka) if musabaka.subBranch == EnumFields.SANDA.value: athletes = SandaAthlete.objects.filter(competition=musabaka) if musabaka.subBranch == EnumFields.TAOLU.value: categori = musabaka.categori.all() if request.method == 'POST': if competition_form.is_valid(): competition = competition_form.save(commit=False) competition.save() mesaj = str(competition.name) + ' müsabaka güncellendi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Müsabaka Başarıyla Güncellenmiştir.') return redirect('wushu:musabaka-duzenle', pk=pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'musabaka/musabaka-duzenle.html', {'competition_form': competition_form, 'competition': musabaka, 'athletes': athletes, 'categori': categori})
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'] user.last_name = user_form.cleaned_data['last_name'] 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() mesaj = str(user.get_full_name()) + ' Antrenör güncellendi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Antrenör Başarıyla Güncellendi') return redirect('wushu: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 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, request.FILES 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) 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() messages.success(request, 'Sporcu Başarıyla Güncellenmiştir.') mesaj = str(user.get_full_name()) + ' Sporcu güncellendi' log = general_methods.logwrite(request, request.user, mesaj) return redirect('wushu: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 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() mesaj = str( user.get_full_name()) + ' Klup üyesi güncellenmiştir. ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kulüp Üyesi Başarıyla Güncellenmiştir.') return redirect('wushu: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 kademe_reddet(request, grade_pk, coach_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') grade = Level.objects.get(pk=grade_pk) grade.status = Level.DENIED grade.save() mesaj = ' Antrenör kademe reddedildi ' + str(grade.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kademe Reddedilmistir.') return redirect('wushu:update-coach', pk=coach_pk)
def send_information(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') if request.method == 'POST' and request.is_ajax(): user = User.objects.get(pk=pk) if not user.is_active: return JsonResponse({'status': 'Fail', 'msg': 'Kullanıcıyı aktifleştirin.'}) fdk = Forgot(user=user, status=False) fdk.save() html_content = '' subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email html_content = '<h2>TÜRKİYE WUSHU KUNG FU FEDERASYONU BİLGİ SİSTEMİ</h2>' html_content = html_content + '<p><strong>Kullanıcı Adınız :' + str(fdk.user.username) + '</strong></p>' html_content = html_content + '<p> <strong>Site adresi:</strong> <a href="http://sbs.twf.gov.tr:81/sbs/newpassword?query=' + str( fdk.uuid) + '">http://sbs.twf.gov.tr:81/sbs/wushu/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>' msg = EmailMultiAlternatives(subject, '', from_email, [to]) msg.attach_alternative(html_content, "text/html") msg.send() mesaj = str(user.get_full_name()) + ' Aktivasyon mailli gönderildi ' log = general_methods.logwrite(request, request.user, mesaj) # password = User.objects.make_random_password() # obj.set_password(password) # # form.cleaned_data['password'] = make_password(form.cleaned_data['password']) # user = obj.save() # html_content = '' # subject, from_email, to = 'TWF Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', obj.email # text_content = 'Aşağıda ki bilgileri kullanarak sisteme giriş yapabilirsiniz.' # html_content = '<p> <strong>Site adresi:</strong> <a href="http://sbs.twf.gov.tr:81"></a>sbs.twf.gov.tr:81</p>' # html_content = html_content + '<p><strong>Kullanıcı Adı:</strong>' + obj.username + '</p>' # html_content = html_content + '<p><strong>Şifre:</strong>' + password + '</p>' # msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) # msg.attach_alternative(html_content, "text/html") # msg.send() # print(obj.is_active) return JsonResponse({'status': 'Success', 'msg': 'Şifre başarıyla gönderildi'}) else: return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
def choose_sport_club_user(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') sportClubUsers = SportClubUser.objects.all() user_form = UserSearchForm() if request.method == 'POST': user_form = UserSearchForm(request.POST) athletes1 = request.POST.getlist('selected_options') if user_form.is_valid(): firstName = user_form.cleaned_data.get('first_name') lastName = user_form.cleaned_data.get('last_name') email = user_form.cleaned_data.get('email') if not (firstName or lastName or email): print("asasa") # messages.warning(request, 'Lütfen Arama Kriteri Giriniz.') else: query = Q() if lastName: query &= Q(user__last_name__icontains=lastName) if firstName: query &= Q(user__first_name__icontains=firstName) if email: query &= Q(user__email__icontains=email) sportClubUsers = SportClubUser.objects.filter(query) if athletes1: students = [int(x) for x in athletes1] instances = SportClubUser.objects.filter(id__in=students) club = SportsClub.objects.get(pk=pk) for club_user in instances: club.clubUser.add(club_user) mesaj = str(club_user.user.get_full_name() ) + ' klup üyesi eklendi ' + str(club.name) log = general_methods.logwrite(request, request.user, mesaj) club.save() messages.success(request, 'Kulüp Üyesi Başarıyla Eklenmiştir.') return redirect('wushu:update-club', pk=pk) return render(request, 'kulup/kulupuyesisec.html', { 'coaches': sportClubUsers, 'user_form': user_form })
def sporcu_kusak_reddet(request, belt_pk, athlete_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') belt = Level.objects.get(pk=belt_pk) belt.status = Level.DENIED belt.save() mesaj = ' kuşak reddedildi ' + str(belt.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kuşak Reddedilmiştir') return redirect('wushu:update-athletes', pk=athlete_pk)
def visa_onay(request, grade_pk, coach_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') visa = Level.objects.get(pk=grade_pk) visa.status = Level.APPROVED visa.save() mesaj = ' Antrenör vize onaylandi ' + str(visa.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Vize onaylanmıştır') return redirect('wushu:update-coach', pk=coach_pk)
def visa_reddet(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') visa = Level.objects.get(pk=grade_pk) visa.status = Level.DENIED visa.save() mesaj = ' Hakem vize reddedildi ' + str(visa.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.warning(request, 'Vize Reddedilmiştir.') return redirect('wushu:hakem-duzenle', pk=referee_pk)
def visa_onay(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') visa = Level.objects.get(pk=grade_pk) visa.status = Level.APPROVED visa.save() mesaj = ' Hakem vize onayladı ' + str(visa.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Vize onaylanmıştır.') return redirect('wushu:hakem-duzenle', pk=referee_pk)
def vize_reddet(request, grade_pk, coach_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') visa = Level.objects.get(pk=grade_pk) visa.status = Level.DENIED visa.save() mesaj = ' Antrenör vize reddedildi ' + str(visa.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.warning(request, 'Vize Reddedilmistir.') return redirect('wushu:update-coach', pk=coach_pk)
def kademe_reddet(request, grade_pk, referee_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') belt = Level.objects.get(pk=grade_pk) belt.status = Level.DENIED belt.save() mesaj = ' kademe reddedildi ' + str(belt.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kademe reddedilmiştir.') return redirect('wushu:hakem-duzenle', pk=referee_pk)
def rejected_preRegistration(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') print('geldim ben pk= ', pk) messages.success(request, 'Öneri reddedildi ') veri = PreRegistration.objects.get(pk=pk) veri.status = PreRegistration.DENIED veri.save() mesaj = str(veri.name) + ' Klup basvurusu reddedildi ' log = general_methods.logwrite(request, request.user, mesaj) prepegidtration = PreRegistration.objects.all() return render(request, 'kulup/kulupBasvuru.html', {'prepegidtration': prepegidtration})
def sporcu_lisans_reddet(request, license_pk, athlete_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') if request.POST: license = License.objects.get(pk=license_pk) license.reddetwhy = request.POST.get('reddetwhy') license.status = License.DENIED license.save() mesaj = ' Lisans Reddedilmiştir' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Lisans Reddedilmiştir') return redirect('wushu:update-athletes', pk=athlete_pk)
def return_add_club(request): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') club_form = ClubForm() communication_form = CommunicationForm() if request.method == 'POST': club_form = ClubForm(request.POST, request.FILES) communication_form = CommunicationForm(request.POST, request.FILES) if club_form.is_valid(): clubsave = SportsClub(name=club_form.cleaned_data['name'], shortName=club_form.cleaned_data['shortName'], foundingDate=club_form.cleaned_data['foundingDate'], logo=club_form.cleaned_data['logo'], clubMail=club_form.cleaned_data['clubMail'], isFormal=club_form.cleaned_data['isFormal'], ) communication = communication_form.save(commit=False) communication.save() clubsave.communication = communication clubsave.save() mesaj = str(club_form.cleaned_data['name']) + ' Klubü ekledi ' log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Kulüp Başarıyla Kayıt Edilmiştir.') return redirect('wushu:kulupler') else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'kulup/kulup-ekle.html', {'club_form': club_form, 'communication_form': communication_form})
def vısa_ekle(request, pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') referee = Judge.objects.get(pk=pk) visa_form = VisaForm() category_item_form = CategoryItemForm() if request.method == 'POST': visa_form = VisaForm(request.POST, request.FILES) category_item_form = CategoryItemForm(request.POST, request.FILES) try: visa = Level(dekont=request.POST.get('dekont'), branch=request.POST.get('branch')) visa.startDate = date(int(request.POST.get('startDate')), 1, 1) visa.definition = CategoryItem.objects.get( forWhichClazz='VISA_REFEREE') visa.levelType = EnumFields.LEVELTYPE.VISA visa.status = Level.APPROVED for item in referee.visa.all(): if item.branch == visa.branch: item.isActive = False item.save() visa.isActive = True visa.save() referee.visa.add(visa) referee.save() mesaj = str( referee.user.get_full_name()) + ' Hakem vize eklendi ' + str( visa.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Vize Başarıyla Eklenmiştir.') return redirect('wushu:hakem-duzenle', pk=pk) except: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'hakem/vize-ekle.html', { 'grade_form': visa_form, 'category_item_form': category_item_form })
def sporcu_lisans_duzenle(request, license_pk, athlete_pk): perm = general_methods.control_access(request) if not perm: logout(request) return redirect('accounts:login') license = License.objects.get(pk=license_pk) license_form = LicenseForm(request.POST or None, request.FILES or None, instance=license, initial={'sportsClub': license.sportsClub}) user = request.user 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() if request.method == 'POST': if license_form.is_valid(): license_form.save() if license.status != 'Onaylandı': license.status = License.WAITED license.save() mesaj = ' Lisans güncellendi ' + str(license.pk) log = general_methods.logwrite(request, request.user, mesaj) messages.success(request, 'Lisans Başarıyla Güncellenmiştir.') return redirect('wushu:update-athletes', pk=athlete_pk) else: messages.warning(request, 'Alanları Kontrol Ediniz') return render(request, 'sporcu/sporcu-lisans-duzenle.html', { 'license_form': license_form, 'license': license })