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('wushu: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})
Exemple #2
0
def return_belt(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    category_item_form = CategoryItemForm()

    if request.method == 'POST':

        category_item_form = CategoryItemForm(request.POST)

        if category_item_form.is_valid():

            categoryItem = category_item_form.save(commit=False)
            categoryItem.forWhichClazz = "BELT"
            categoryItem.save()
            messages.success(request, 'Kuşak Başarıyla Kayıt Edilmiştir.')
            return redirect('wushu:kusak')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    categoryitem = CategoryItem.objects.filter(forWhichClazz="BELT")
    return render(request, 'sporcu/kusak.html', {
        'category_item_form': category_item_form,
        'categoryitem': categoryitem
    })
Exemple #3
0
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)
Exemple #4
0
def deleteCoachFromClub(request, pk, club_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 = Coach.objects.get(pk=pk)
            club = SportsClub.objects.get(pk=club_pk)

            club.coachs.remove(obj)
            club.save()

            return JsonResponse({
                'status': 'Success',
                'messages': 'delete successfully'
            })
        except ClubRole.DoesNotExist:
            return JsonResponse({
                'status': 'Fail',
                'msg': 'Object does not exist'
            })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemple #5
0
def choose_coach(request, pk):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    login_user = request.user
    user = User.objects.get(pk=login_user.pk)
    sinav = BeltExam.objects.get(pk=pk)
    athletes = Coach.objects.none()
    # .filter(grades__branch=sinav.branch) eklenmeli
    coa = []
    for item in sinav.coachs.all():
        coa.append(item.user.pk)
    athletes = Coach.objects.filter(
        grades__branch=sinav.branch, grades__status='Onaylandı').exclude(
            beltexam__coachs__user_id__in=coa).filter(
                visa__startDate__year=timezone.now().year).exclude(
                    grades=None).exclude(visa=None).exclude(
                        grades__definition__name='1.Kademe').exclude(
                            grades__definition=None).distinct()
    # for fd in coach:
    #     for visa in fd.visa.all():
    #         if(date(sinav.examDate.year,sinav.examDate.month,sinav.examDate.day)-date(visa.creationDate.year,visa.creationDate.month,visa.creationDate.day)).days<365:
    #             athletes|=Coach.objects.filter(pk=fd.pk).distinct()

    if request.method == 'POST':
        athletes1 = request.POST.getlist('selected_options')
        if athletes1:
            for x in athletes1:
                if not sinav.coachs.all().filter(beltexam__coachs__user_id=x):
                    sinav.coachs.add(x)
                    sinav.save()
        return redirect('wushu:kusak-sinavi-incele', pk=pk)
    return render(request, 'kulup/kusak-sınavı-antroner-sec.html',
                  {'athletes': athletes})
Exemple #6
0
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'})
Exemple #7
0
def kademe_onay_hepsi(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    coa = []
    for item in CategoryItem.objects.filter(forWhichClazz='REFEREE_GRADE'):
        coa.append(item.pk)
    Belt = Level.objects.filter(definition_id__in=coa,
                                levelType=EnumFields.LEVELTYPE.GRADE,
                                status="Beklemede")

    for grade in Belt:
        coach = grade.Judgegrades.first()
        try:
            for item in coach.grades.all():
                if item.branch == grade.branch:
                    item.isActive = False
                    item.save()
            grade.status = Level.APPROVED
            grade.isActive = True
            grade.save()
            messages.success(request, 'Beklemede olan Kademeler Onaylanmıştır')
        except:
            messages.warning(request, 'Lütfen yeniden deneyiniz.')

    return redirect('wushu:hakem-kademe-listesi')
Exemple #8
0
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 musabaka_sporcu_sec(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    login_user = request.user
    user = User.objects.get(pk=login_user.pk)
    competition = Competition.objects.get(pk=pk)
    if user.groups.filter(name='KulupUye'):
        sc_user = SportClubUser.objects.get(user=user)
        clubsPk = []
        clubs = SportsClub.objects.filter(clubUser=sc_user)
        for club in clubs:
            clubsPk.append(club.pk)
        athletes = Athlete.objects.filter(licenses__sportsClub__in=clubsPk).distinct()
    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        athletes = Athlete.objects.all()
    if request.method == 'POST':

        athletes1 = request.POST.getlist('selected_options')
        if athletes1:
            for x in athletes1:
                if competition.subBranch == 'SANDA':
                    athlete = Athlete.objects.get(pk=x)
                    sandaAthlete = SandaAthlete()
                    sandaAthlete.athlete = athlete
                    sandaAthlete.competition = competition
                    sandaAthlete.save()

        return redirect('wushu:musabaka-duzenle', pk=pk)
    return render(request, 'kulup/kusak-sinavi-sporcu-sec.html', {'athletes': athletes})
Exemple #10
0
def updateProfile(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')

    user = request.user
    user_form = DisabledUserForm(request.POST or None, instance=user)
    password_form = SetPasswordForm(request.user, request.POST)

    if request.method == 'POST':

        if password_form.is_valid():

            user.set_password(password_form.cleaned_data['new_password1'])
            user.save()
            update_session_auth_hash(request, user)
            messages.success(request, 'Şifre Başarıyla Güncellenmiştir.')

            return redirect('wushu:admin-profil-guncelle')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')

    return render(request, 'admin/admin-profil-guncelle.html', {
        'user_form': user_form,
        'password_form': password_form
    })
Exemple #11
0
def return_users(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    users = User.objects.none()
    user_form = UserSearchForm()
    if request.method == 'POST':
        user_form = UserSearchForm(request.POST)
        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')
            active = request.POST.get('is_active')
            print(active)
            if not (firstName or lastName or email or active):
                users = User.objects.all()
            else:
                query = Q()
                if lastName:
                    query &= Q(last_name__icontains=lastName)
                if firstName:
                    query &= Q(first_name__icontains=firstName)
                if email:
                    query &= Q(email__icontains=email)
                if active == 'True':
                    print(active)
                    query &= Q(is_active=True)
                if active == 'False':
                    query &= Q(is_active=False)

                    print('geldim ')
                users = User.objects.filter(query)
    return render(request, 'kullanici/kullanicilar.html', {'users': users, 'user_form': user_form})
def return_directory_members(request):
    perm =general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    members = DirectoryMember.objects.all()
    user_form = UserSearchForm()
    if request.method == 'POST':
        user_form = UserSearchForm(request.POST)
        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):
                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)
                members = DirectoryMember.objects.filter(query)
    return render(request, 'yonetim/kurul-uyeleri.html', {'members': members, 'user_form': user_form})
def return_commissions(request):
    perm =general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    commission_form = DirectoryCommissionForm()

    if request.method == 'POST':

        commission_form = DirectoryCommissionForm(request.POST)

        if commission_form.is_valid():

            commission = DirectoryCommission(name=commission_form.cleaned_data['name'])
            commission.save()
            messages.success(request, 'Kurul Başarıyla Kayıt Edilmiştir.')
            return redirect('wushu:kurullar')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    commissions = DirectoryCommission.objects.all()
    return render(request, 'yonetim/kurullar.html',
                  {'commission_form': commission_form, 'commissions': commissions})
def return_member_roles(request):
    perm =general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    member_role_form = DirectoryMemberRoleForm();

    if request.method == 'POST':

        member_role_form = DirectoryMemberRoleForm(request.POST)

        if member_role_form.is_valid():

            memberRole = DirectoryMemberRole(name=member_role_form.cleaned_data['name'])
            memberRole.save()
            messages.success(request, 'Kurul Üye Rolü Başarıyla Kayıt Edilmiştir.')
            return redirect('wushu:kurul-uye-rolleri')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    memberRoles = DirectoryMemberRole.objects.all()
    return render(request, 'yonetim/kurul-uye-rolleri.html',
                  {'member_role_form': member_role_form, 'memberRoles': memberRoles})
Exemple #15
0
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 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})
Exemple #17
0
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 musabaka_sporcu_sec(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    login_user = request.user
    user = User.objects.get(pk=login_user.pk)
    competition = Competition.objects.get(pk=pk)
    athletes = Athlete.objects.none()

    if request.method == 'POST':


        athletes1 = request.POST.getlist('selected_options')
        if athletes1:
            for x in athletes1:
                if competition.subBranch == 'SANDA':
                    athlete = Athlete.objects.get(pk=x)
                    sandaAthlete = SandaAthlete()
                    sandaAthlete.athlete = athlete
                    sandaAthlete.competition = competition
                    sandaAthlete.save()

        return redirect('wushu:musabaka-duzenle', pk=pk)
    return render(request, 'kulup/kusak-sinavi-sporcu-sec.html', {'athletes': athletes})
Exemple #19
0
def visaSeminar_duzenle(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')

    seminar = VisaSeminar.objects.get(pk=pk)
    referee = seminar.referee.all()
    competition_form = VisaSeminarForm(request.POST or None, instance=seminar)
    if request.method == 'POST':
        if competition_form.is_valid():
            competition_form.save()
            messages.success(request,
                             'Vize Seminer Başarıyla Güncellenmiştir.')

            return redirect('wushu:hakem-visa-seminar')
        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')

    return render(
        request, 'hakem/hakem-VizeSeminerGüncelle.html', {
            'competition_form': competition_form,
            'competition': seminar,
            'athletes': referee
        })
def musabaka_kategori_sec(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    login_user = request.user
    user = User.objects.get(pk=login_user.pk)
    competition = Competition.objects.get(pk=pk)
    kategoriler = competition.categori.all()
    coa = []
    for item in kategoriler:
        coa.append(item.pk)
    categori = TaoluCategory.objects.exclude(competitioncategori__in=coa)
    if request.method == 'POST':
        kategoriler = request.POST.getlist('selected_options')
        if kategoriler:
            for x in kategoriler:
                if competition.subBranch == 'TAOLU':
                    kategori = TaoluCategory.objects.get(pk=x)
                    competitionCategori = CompetitionCategori()
                    competitionCategori.categori = kategori
                    competitionCategori.save()
                    competition.categori.add(competitionCategori)
                    competition.save()

        return redirect('wushu:musabaka-duzenle', pk=pk)
    return render(request, 'musabaka/musabaka-Kategori-sec.html', {'categori': categori})
Exemple #21
0
def return_club_role(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    club_role_form = ClubRoleForm()

    if request.method == 'POST':

        club_role_form = ClubRoleForm(request.POST)

        if club_role_form.is_valid():

            clubrole = ClubRole(name=club_role_form.cleaned_data['name'])
            clubrole.save()
            messages.success(request,
                             'Kulüp Üye Rolü Başarıyla Kayıt Edilmiştir.')
            return redirect('wushu:kulup-uye-rolu')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    club_role = ClubRole.objects.all()
    return render(request, 'kulup/kulup-uye-rolu.html', {
        'club_role_form': club_role_form,
        'club_role': club_role
    })
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})
Exemple #23
0
def return_belt_exams(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')

    user = request.user

    if user.groups.filter(name='KulupUye'):

        clubuser = SportClubUser.objects.get(user=user)
        clubs = SportsClub.objects.filter(clubUser=clubuser)
        clubsPk = []
        for club in clubs:
            clubsPk.append(club.pk)

        exams = BeltExam.objects.filter(sportClub__in=clubsPk)

    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        exams = BeltExam.objects.all()

    if int(timezone.now().month) % 3 == 0:
        examMonth = True
    else:
        examMonth = False

    print(examMonth)

    return render(request, 'kulup/kusak-sinavlari.html', {
        'exams': exams,
        'examMonth': examMonth
    })
Exemple #24
0
def return_grade(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    category_item_form = CategoryItemForm()

    if request.method == 'POST':

        category_item_form = CategoryItemForm(request.POST)
        name = request.POST.get('name')
        if name is not None:
            categoryItem = CategoryItem(name=name)
            categoryItem.forWhichClazz = "COACH_GRADE"
            categoryItem.isFirst = False
            categoryItem.save()
            return redirect('wushu:kademe')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    categoryitem = CategoryItem.objects.filter(forWhichClazz="COACH_GRADE")
    return render(request, 'antrenor/kademe.html', {
        'category_item_form': category_item_form,
        'categoryitem': categoryitem
    })
Exemple #25
0
def add_belt_exam(request):
    perm = general_methods.control_access(request),
    if not perm:
        logout(request)
        return redirect('accounts:login')
    exam_form = BeltExamForm(request.POST, request.FILES or None)
    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)
        exam_form.fields['sportClub'].queryset = SportsClub.objects.filter(
            id__in=clubsPk)

    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        exam_form.fields['sportClub'].queryset = SportsClub.objects.all()

    if request.method == 'POST':
        exam_form = BeltExamForm(request.POST, request.FILES or None)
        if exam_form.is_valid():
            exam = exam_form.save()
            messages.success(request, 'Sınav başarıyla oluşturuldu')
            return redirect('wushu:kusak-sinavlari')
        else:
            messages.warning(request, 'Alanları Kontrol Ediniz')
    return render(request, 'kulup/kusak-sinavi-ekle.html',
                  {'exam_form': exam_form})
Exemple #26
0
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})
Exemple #27
0
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)
Exemple #28
0
def return_level(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    category_item_form = CategoryItemForm()

    if request.method == 'POST':

        category_item_form = CategoryItemForm(request.POST)

        if category_item_form.is_valid():

            categoryItem = CategoryItem(
                name=category_item_form.cleaned_data['name'])
            categoryItem.forWhichClazz = "REFEREE_GRADE"
            categoryItem.save()

            return redirect('wushu:seviye')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    categoryitem = CategoryItem.objects.filter(forWhichClazz="REFEREE_GRADE")
    return render(request, 'hakem/seviye.html', {
        'category_item_form': category_item_form,
        'categoryitem': categoryitem
    })
Exemple #29
0
def sporcu_lisans_duzenle_mobil(request, count):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    login_user = request.user
    user = User.objects.get(pk=login_user.pk)
    if user.groups.filter(name__in=['Yonetim', 'Admin']):
        ileri = int(count) + 1
        geri = int(count) - 1

        if int(count) >= 0 and int(count) < License.objects.count():
            licenses = License.objects.all().order_by('-pk')[int(count)]
            if int(count) == 0:
                geri = 0
        else:
            licenses = License.objects.all().order_by('-pk')[0]
            messages.success(request, 'Degerler bitti ')
            count = '0'

    return render(request, 'sporcu/sporcu-lisans-mobil-onay.html', {
        'ileri': ileri,
        'geri': geri,
        'say': count,
        'license': licenses
    })
def return_directory_dashboard(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    return render(request, 'anasayfa/federasyon.html')