Exemplo n.º 1
0
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})
Exemplo n.º 2
0
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
        })
Exemplo n.º 3
0
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
        })
Exemplo n.º 4
0
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
        })
Exemplo n.º 5
0
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']
            user.last_name = user_form.cleaned_data['last_name']
            user.email = user_form.cleaned_data['email']
            user.save()
            person_form.save()
            communication_form.save()

            mesaj = str(user.get_full_name()) + ' Hakem güncellendi  '
            log = general_methods.logwrite(request, request.user, mesaj)

            messages.success(request, 'Hakem Başarıyla Güncellendi')
            return redirect('wushu: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
        })
Exemplo n.º 6
0
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 person_form.is_valid() and license_form.is_valid(
        ) and communication_form.is_valid():
            user = User()
            user.first_name = request.POST.get('first_name')
            user.last_name = request.POST.get('last_name')
            email = request.POST.get('email')
            if email:
                try:
                    if User.objects.filter(email=email).exists():
                        user.email = str(uuid.uuid4()) + '@kobiltek.com'
                        user.username = user.email
                    else:
                        user.username = email
                        user.email = email
                except:
                    user.email = str(uuid.uuid4()) + '@kobiltek.com'
                    user.username = user.email
            else:
                user.email = str(uuid.uuid4()) + '@kobiltek.com'
                user.username = user.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()

            mesaj = str(user.get_full_name()) + ' Sporcusunu kaydetti'
            log = general_methods.logwrite(request, request.user, mesaj)

            messages.success(request, 'Sporcu Başarıyla Kayıt Edilmiştir.')

            return redirect('wushu: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
        })
Exemplo n.º 7
0
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)

        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='KulupUye')
            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 = 'WUSHU - 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.twf.gov.tr/"></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()

            mesaj = str(user.get_full_name()) + ' klup üyesi  eklendi   '
            log = general_methods.logwrite(request, request.user, mesaj)

            messages.success(request,
                             'Kulüp Üyesi Başarıyla Kayıt Edilmiş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-ekle.html', {
            'user_form': user_form,
            'person_form': person_form,
            'communication_form': communication_form,
            'sportClubUser_form': sportClubUser_form,
        })
Exemplo n.º 8
0
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']
            user.last_name = user_form.cleaned_data['last_name']
            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 = 'WUSHU - 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()

            mesaj = str(judge.user.get_full_name()) + ' Hakem eklendi. '
            log = general_methods.logwrite(request, request.user, mesaj)
            messages.success(request, 'Hakem Başarıyla Kayıt Edilmiştir.')
            return redirect('wushu: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
        })
Exemplo n.º 9
0
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.commission = member_form.cleaned_data['commission']

            directoryMember.save()

            subject, from_email, to = 'WUSHU - 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/"></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, 'Yönetim Kurulu Üyesi Başarıyla Kayıt Edilmiştir.')

            return redirect('wushu: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})