Ejemplo n.º 1
0
def deneme(request):
    perm = general_methods.control_access_klup(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    return render(request, 'sporcu/deneme.html')
Ejemplo n.º 2
0
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'})
Ejemplo n.º 3
0
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})
Ejemplo n.º 4
0
def return_competitions(request):
    perm = general_methods.control_access_klup(request)

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

    competitions = Competition.objects.all()

    return render(request, 'musabaka/musabakalar.html', {'competitions': competitions})
Ejemplo n.º 5
0
def choose_athlete_remove(request, pk, exam_pk):
    perm = general_methods.control_access_klup(request)

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

    sinav = BeltExam.objects.get(pk=exam_pk)
    sinav.athletes.remove(Athlete.objects.get(pk=pk))

    return redirect('wushu:kusak-sinavi-incele', pk=exam_pk)
Ejemplo n.º 6
0
def musabaka_sporcu_sil(request, 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:
            athlete = SandaAthlete.objects.get(pk=pk)
            athlete.delete()
            return JsonResponse({'status': 'Success', 'messages': 'save successfully'})
        except SandaAthlete.DoesNotExist:
            return JsonResponse({'status': 'Fail', 'msg': 'Object does not exist'})

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Ejemplo n.º 7
0
def taolu_sporcu_sil(request, pk, competition):
    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:
            comp = CompetitionCategori.objects.get(pk=competition)
            comp.athlete.remove(Athlete.objects.get(pk=pk))
            comp.save()
            return JsonResponse({'status': 'Success', 'messages': 'save successfully'})
        except:
            return JsonResponse({'status': 'Fail', 'msg': 'Object does not exist'})

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Ejemplo n.º 8
0
def choose_athlete(request, pk, competition):
    perm = general_methods.control_access_klup(request)

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

    if request.method == 'POST':

        athletes1 = request.POST.getlist('selected_options')
        if athletes1:
            for x in athletes1:
                kategori.athlete.add(x)
                kategori.save()
        return redirect('wushu:musabaka-duzenle', pk=competition)
    return render(request, 'musabaka/musabaka-Sporcu-sec.html',
                  {'athletes': athletes, 'kategori': kategori, 'competition': competition})
Ejemplo n.º 9
0
def musabaka_sanda(request, pk):
    perm = general_methods.control_access_klup(request)

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

    musabaka = Competition.objects.get(pk=pk)

    if request.method == 'POST':

        athletes1 = request.POST.getlist('selected_options')
        if athletes1:
            for x in athletes1:
                if musabaka.subBranch == 'SANDA':
                    athlete = Athlete.objects.get(pk=x)
                    sandaAthlete = SandaAthlete()
                    sandaAthlete.athlete = athlete
                    sandaAthlete.competition = musabaka
                    sandaAthlete.save()
        return redirect('wushu:musabaka-duzenle', pk=musabaka.pk)

    return render(request, 'musabaka/musabaka-SandaSporcusec.html',
                  {'competition': musabaka, })