コード例 #1
0
ファイル: RefereeViews.py プロジェクト: HalilBozdag/kobiltek
def return_referees(request):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    referees = Judge.objects.none()
    searchClupForm = SearchClupForm()
    user_form = RefereeSearchForm()
    if request.method == 'POST':
        searchClupForm = SearchClupForm(request.POST)
        user_form = RefereeSearchForm(request.POST)
        branch = request.POST.get('branch')
        grade = request.POST.get('definition')
        visa = request.POST.get('visa')
        firstName = request.POST.get('first_name')
        lastName = request.POST.get('last_name')
        email = request.POST.get('email')
        # print(firstName, lastName, email, branch, grade, visa)
        if not (firstName or lastName or email or branch or grade or visa):
            referees = Judge.objects.all()
        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)
            if branch:
                query &= Q(grades__branch=branch, grades__status='Onaylandı')
            if grade:
                query &= Q(grades__definition__name=grade,
                           grades__status='Onaylandı')
            if visa == 'VISA':
                print('visa ')
                query &= Q(visa__startDate__year=timezone.now().year)
            referees = Judge.objects.filter(query).distinct()
            if visa == 'NONE':
                referees = referees.exclude(
                    visa__startDate__year=timezone.now().year).distinct()

    return render(request, 'hakem/hakemler.html', {
        'referees': referees,
        'user_form': user_form,
        'branch': searchClupForm
    })
コード例 #2
0
def sporcu_kusak_listesi(request):
    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)
    belts = not License.objects.none()
    if request.method == 'POST':
        brans = request.POST.get('branch')
        sportsclup = request.POST.get('sportsClub')
        firstName = request.POST.get('first_name')
        lastName = request.POST.get('last_name')
        email = request.POST.get('email')
        status = request.POST.get('status')
        startDate = request.POST.get('startDate')
        if firstName or lastName or email or sportsclup or brans or status or startDate:
            query = Q()
            if firstName:
                query &= Q(athlete__user__first_name__icontains=firstName)
            if lastName:
                query &= Q(athlete__user__last_name__icontains=lastName)
            if email:
                query &= Q(athlete__user__email__icontains=email)

            if startDate:
                query &= Q(startDate__year=startDate)

            if sportsclup:
                try:
                    query &= Q(
                        athlete__licenses__sportsClub=SportsClub.objects.get(
                            name=sportsclup).pk)
                except:
                    if user.groups.filter(name__in=['Yonetim', 'Admin']):
                        messages.warning(
                            request,
                            'Bu kulube bir başkan atamasi gerçeklesmemiştir. Bütün degerler gösterilecek'
                        )
            if brans:
                query &= Q(branch__icontains=brans)
            if status:
                query &= Q(status=status)
            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)
                belts = Level.objects.filter(query).filter(
                    athlete__licenses__sportsClub__in=clubsPk).filter(
                        levelType=EnumFields.LEVELTYPE.BELT).order_by(
                            '-athlete__belts__creationDate').distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                belts = Level.objects.filter(query).filter(
                    levelType=EnumFields.LEVELTYPE.BELT).order_by(
                        '-athlete__belts__creationDate').distinct()
        else:
            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)
                belts = Level.objects.filter(
                    athlete__licenses__sportsClub__in=clubsPk).order_by(
                        '-athlete__belts__creationDate').distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                belts = Level.objects.filter(
                    levelType=EnumFields.LEVELTYPE.BELT).order_by(
                        '-athlete__belts__creationDate').distinct()
    else:
        if user.groups.filter(name__in=['Yonetim', 'Admin']):
            belts = Level.objects.filter(status=Level.WAITED).filter(
                levelType=EnumFields.LEVELTYPE.BELT).order_by(
                    '-athlete__belts__creationDate').distinct()

    sportclup = SearchClupForm(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)
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.filter(
            id__in=clubsPk)
    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.all()
    return render(request, 'sporcu/sporcu-kusak-listesi.html', {
        'belts': belts,
        'Sportclup': sportclup
    })
コード例 #3
0
def return_athletes(request):
    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)
    user_form = UserSearchForm()
    # # arama açıldıgı zaman burasi sillinecek
    # 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()
    # #     silinecek son

    athletes = Athlete.objects.none()
    if request.method == 'POST':

        user_form = UserSearchForm(request.POST)
        brans = request.POST.get('branch')
        sportsclup = request.POST.get('sportsClub')

        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 or brans or sportsclup):

                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()
            elif firstName or lastName or email or sportsclup or brans:
                query = Q()
                clubsPk = []
                clubs = SportsClub.objects.filter(
                    name=request.POST.get('sportsClub'))
                for club in clubs:
                    clubsPk.append(club.pk)

                if firstName:
                    query &= Q(user__first_name__icontains=firstName)
                if lastName:
                    query &= Q(user__last_name__icontains=lastName)
                if email:
                    query &= Q(user__email__icontains=email)
                if sportsclup:
                    query &= Q(licenses__sportsClub__in=clubsPk)
                if brans:
                    query &= Q(licenses__branch=brans,
                               licenses__status='Onaylandı')

                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).filter(
                            query).distinct()

                elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                    athletes = Athlete.objects.filter(query).distinct()

    sportclup = SearchClupForm(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)
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.filter(
            id__in=clubsPk)
    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.all()
    return render(request, 'sporcu/sporcular.html', {
        'athletes': athletes,
        'user_form': user_form,
        'Sportclup': sportclup
    })
コード例 #4
0
def sporcu_lisans_listesi(request):
    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)
    user_form = UserForm(request.POST, request.FILES or None)

    # ilk açılıs alani
    # 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)
    #     licenses = License.objects.filter(athlete__licenses__sportsClub__in=clubsPk).distinct()
    #     sc_user = SportClubUser.objects.get(user=user)
    #     clubs = SportsClub.objects.filter(clubUser=sc_user)
    #     clubsPk = []
    #     for club in clubs:
    #         clubsPk.append(club.pk)
    #     sportclup.fields['sportsClub'].queryset = SportsClub.objects.filter(id__in=clubsPk)
    # elif user.groups.filter(name__in=['Yonetim', 'Admin']):
    #     licenses = License.objects.all().distinct()
    #     sportclup.fields['sportsClub'].queryset = SportsClub.objects.all()

    # ilk açılıs son
    licenses = not License.objects.none()
    if request.method == 'POST':
        brans = request.POST.get('branch')
        sportsclup = request.POST.get('sportsClub')
        firstName = request.POST.get('first_name')
        lastName = request.POST.get('last_name')
        email = request.POST.get('email')
        status = request.POST.get('status')

        if firstName or lastName or email or sportsclup or brans or status:
            query = Q()
            if firstName:
                query &= Q(athlete__user__first_name__icontains=firstName)
            if lastName:
                query &= Q(athlete__user__last_name__icontains=lastName)
            if email:
                query &= Q(athlete__user__email__icontains=email)
            if sportsclup:
                query &= Q(sportsClub__name__icontains=sportsclup)
            if brans:
                query &= Q(branch__icontains=brans)
            if status:
                query &= Q(status=status)

            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)
                licenses = License.objects.filter(
                    sportsClub_id__in=clubsPk).filter(query).distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                licenses = License.objects.filter(query).distinct()
        else:
            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)
                licenses = License.objects.filter(
                    sportsClub_id__in=clubsPk).distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                licenses = License.objects.all().distinct()
    else:
        if user.groups.filter(name__in=['Yonetim', 'Admin']):
            licenses = License.objects.filter(status=License.WAITED)

    sportclup = SearchClupForm(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)
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.filter(
            id__in=clubsPk)
    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.all()
    return render(request, 'sporcu/sporcu-lisans-listesi.html', {
        'licenses': licenses,
        'user_form': user_form,
        'Sportclup': sportclup
    })
コード例 #5
0
def return_club_person(request):
    perm = general_methods.control_access(request)

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

    user_form = UserSearchForm()
    user = request.user
    club_user_array = SportClubUser.objects.none()
    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)

        club_user_array = SportClubUser.objects.filter(
            sportsclub__in=clubsPk).distinct()

    if request.method == 'POST':
        user_form = UserSearchForm(request.POST)
        sportsclup = request.POST.get('sportsClub')

        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 or sportsclup):
                club_user_array = []
                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)

                    club_user_array = SportClubUser.objects.filter(
                        sportsclub__in=clubsPk).distinct()

                elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                    club_user_array = SportClubUser.objects.all()
            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)
                if sportsclup:
                    query &= Q(sportsclub__name__icontains=sportsclup)

                club_user_array = []
                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)

                    club_user_array = SportClubUser.objects.filter(
                        sportsclub__in=clubsPk).filter(query).distinct()

                elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                    club_user_array = SportClubUser.objects.filter(
                        query).distinct()

    sportclup = SearchClupForm(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)
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.filter(
            id__in=clubsPk)
    elif user.groups.filter(name__in=['Yonetim', 'Admin']):
        sportclup.fields['sportsClub'].queryset = SportsClub.objects.all()

    return render(
        request, 'kulup/kulup-uyeleri.html', {
            'athletes': club_user_array,
            'user_form': user_form,
            'Sportclup': sportclup
        })
コード例 #6
0
ファイル: CoachViews.py プロジェクト: HalilBozdag/kobiltek
def return_coachs(request):
    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)
    coachs = Coach.objects.none()
    user_form = CoachSearchForm()
    searchClupForm = SearchClupForm()

    if request.method == 'POST':
        user_form = CoachSearchForm(request.POST)
        searchClupForm = SearchClupForm(request.POST)
        branch = request.POST.get('branch')
        grade = request.POST.get('definition')
        visa = request.POST.get('visa')
        firstName = request.POST.get('first_name')
        lastName = request.POST.get('last_name')
        email = request.POST.get('email')

        if not (firstName or lastName or email or branch or grade or visa):
            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)
                coachs = Coach.objects.filter(
                    sportsclub__in=clubsPk).distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                coachs = Coach.objects.all()
        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)
            if branch:
                query &= Q(grades__branch=branch, grades__status='Onaylandı')
            if grade:
                query &= Q(grades__definition__name=grade,
                           grades__status='Onaylandı')
            if visa == 'VISA':
                query &= Q(visa__startDate__year=timezone.now().year,
                           visa__status='Onaylandı')

            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)
                coachs = Coach.objects.filter(query).filter(
                    sportsclub__in=clubsPk).distinct()
            elif user.groups.filter(name__in=['Yonetim', 'Admin']):
                coachs = Coach.objects.filter(query)
            if visa == 'NONE':
                coachs = coachs.exclude(
                    visa__startDate__year=timezone.now().year,
                    visa__status='Onaylandı')
    return render(request, 'antrenor/antrenorler.html', {
        'coachs': coachs,
        'user_form': user_form,
        'branch': searchClupForm
    })