Exemplo n.º 1
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.')
            aktif = general_methods.controlGroup(request)
            if aktif == "Admin":
                log = str(user.get_full_name()) + " admin sifre guncellendi"
                log = general_methods.logwrite(request, request.user, log)
                return redirect('sbs:admin-profil-guncelle')
            elif aktif == "Arsiv":
                log = str(
                    user.get_full_name()) + " arsiv yönetici sifre guncellendi"
                log = general_methods.logwrite(request, request.user, log)
                return redirect('sbs:evrak-anasayfa')
        else:

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

    return render(request, 'admin/admin-profil-guncelle.html', {
        'user_form': user_form,
        'password_form': password_form
    })
Exemplo n.º 2
0
def choose_athlete(request, pk, competition):
    perm = general_methods.control_access_klup(request)
    login_user = request.user

    if not perm:
        logout(request)
        return redirect('accounts:login')
    if request.method == 'POST' and request.is_ajax():

        try:
            if request.POST.get('weight'):

                user = User.objects.get(pk=login_user.pk)
                competition = Competition.objects.get(pk=competition)
                athlete = Athlete.objects.get(pk=pk)
                compAthlete = CompetitionsAthlete()
                if CompetitionsAthlete.objects.filter(competition=competition).filter(athlete=athlete).count() <= 1:
                    if CompetitionsAthlete.objects.filter(competition=competition).filter(athlete=athlete):
                        competitionAthlete=CompetitionsAthlete.objects.get(athlete=athlete , competition=competition)
                        katagori=competitionAthlete.category.pk
                        if str(katagori) != request.POST.get('weight'):
                            if request.POST.get('sporcu'):
                                compAthlete.athleteTwo = Athlete.objects.get(pk=request.POST.get('sporcu'))
                            compAthlete.athlete = athlete
                            compAthlete.competition = competition
                            compAthlete.category = Category.objects.get(pk=request.POST.get('weight'))
                            compAthlete.save()
                            log = str(athlete.user.get_full_name()) + "  Musabakaya sporcu eklendi "
                            log = general_methods.logwrite(request, request.user, log)
                            return JsonResponse({'status': 'Success', 'msg': 'Sporcu Başarı ile kaydedilmiştir.'})
                        else:
                            return JsonResponse({'status': 'Fail', 'msg': 'Aynı kategoride kayıt vardır.'})
                    else:
                        if request.POST.get('sporcu'):
                            compAthlete.athleteTwo = Athlete.objects.get(pk=request.POST.get('sporcu'))
                        compAthlete.athlete = athlete
                        compAthlete.competition = competition
                        compAthlete.category = Category.objects.get(pk=request.POST.get('weight'))
                        compAthlete.save()
                        log = str(athlete.user.get_full_name()) + "  Musabakaya sporcu eklendi "
                        log = general_methods.logwrite(request, request.user, log)
                        return JsonResponse({'status': 'Success', 'msg': 'Sporcu Başarı ile kaydedilmiştir.'})


                else:
                    return JsonResponse({'status': 'Fail', 'msg': 'Bir sporcu 3. defa eklenemez.'})

            else:
                return JsonResponse({'status': 'Fail', 'msg': 'Eksik'})


        except SandaAthlete.DoesNotExist:
            return JsonResponse({'status': 'Fail', 'msg': 'Object does not exist'})

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 3
0
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 = 'Taekwondo Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>TÜRKİYE TAEKWONDO 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://172.16.5.25/TaekwondoArsiv/newpassword?query=' + str(
            fdk.uuid) + '">http://172.16.5.25/sbs/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        log = str(user.get_full_name()) + " sifre gonderildi"
        log = general_methods.logwrite(request, request.user, log)

        return JsonResponse({'status': 'Success', 'msg': 'Şifre başarıyla gönderildi'})

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 4
0
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)
    athletes = CompAthlete.objects.filter(competition=pk)


    weights = Weight.objects.all()
    competition_form = CompetitionForm(request.POST or None, instance=musabaka)
    if request.method == 'POST':
        if competition_form.is_valid():
            competition_form.save()
            messages.success(request, 'Müsabaka Başarıyla Güncellenmiştir.')

            log = str(request.POST.get('name')) + "  Musabaka guncellendi "
            log = general_methods.logwrite(request, request.user, log)

            return redirect('sbs: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,
                   'weights': weights})
Exemplo n.º 5
0
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():
            musabaka = competition_form.save(commit=False)
            musabaka.juryCount = 0;
            musabaka.save()

            log = str(request.POST.get('name')) + "  Musabaka eklendi "
            log = general_methods.logwrite(request, request.user, log)

            messages.success(request, 'Müsabaka Başarıyla Kaydedilmiştir.')

            return redirect('sbs:musabaka-duzenle', pk=musabaka.pk)
        else:

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

    return render(request, 'musabaka/musabaka-ekle.html',
                  {'competition_form': competition_form})
Exemplo 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 = CompetitionsAthlete.objects.get(pk=pk)

            log = str(athlete.athlete.user.get_full_name()
                      ) + "  müsabakadan silindi "
            log = general_methods.logwrite(request, request.user, log)

            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'})
Exemplo n.º 7
0
def musabaka_link_update(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:
            link = Link.objects.get(pk=pk)

            if request.POST.get('defi'):
                link.definition = request.POST.get('defi')
            if request.POST.get('link'):
                link.youtubelink = request.POST.get('link')
            link.save()
            log = str(pk) + "  link güncellendi"
            log = general_methods.logwrite(request, request.user, log)
            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'})
Exemplo n.º 8
0
def musabaka_photo_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:
            dokuman = CompetitionPhotoDocumentDocument.objects.get(pk=pk)

            log = str(dokuman.title) + "  resim silindi "
            log = general_methods.logwrite(request, request.user, log)

            dokuman.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'})
Exemplo n.º 9
0
def product_update_deposit(request, pk):
    perm = general_methods.control_access(request)

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

    product = Deposit.objects.get(pk=pk)
    product_form = DepositForm(request.POST or None, instance=product)
    if request.method == 'POST':

        if product_form.is_valid():
            product_form.save()

            log = str(request.POST.get('name')) + " ürün emanet  guncelledi"
            log = general_methods.logwrite(request, request.user, log)

            messages.success(request, 'Ürün  Başarıyla Güncellenmiştir.')

            return redirect('sbs:urunler-emanet')
        else:

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

    return render(request, 'product/emanetDuzenle.html',
                  {'product_form': product_form})
Exemplo n.º 10
0
def return_workdefinitionslist(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 = "EMPLOYEE_WORKDEFINITION"
            categoryItem.isFirst = False
            categoryItem.save()

            log = str(name) + " unvanini ekledi"
            log = general_methods.logwrite(request, log)

            return redirect('sbs:unvanlistesi')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    categoryitem = CategoryItem.objects.filter(forWhichClazz="EMPLOYEE_WORKDEFINITION")
    return render(request, 'epproje/unvanListesi.html',
                  {'category_item_form': category_item_form, 'categoryitem': categoryitem})
Exemplo n.º 11
0
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()

            log = " Kurul eklendi"
            log = general_methods.logwrite(request, request.user, log)
            messages.success(request, 'Kurul Başarıyla Kayıt Edilmiştir.')
            return redirect('sbs:kurullar')

        else:

            messages.warning(request, 'Alanları Kontrol Ediniz')
    commissions = DirectoryCommission.objects.all()
    return render(request, 'yonetim/kurullar.html',
                  {'commission_form': commission_form, 'commissions': commissions})
Exemplo n.º 12
0
def delete_commission(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():
        try:
            obj = DirectoryCommission.objects.get(pk=pk)

            log = str(obj.name) + " kurul silindi"
            log = general_methods.logwrite(request, request.user, log)
            obj.delete()
            return JsonResponse({
                'status': 'Success',
                'messages': 'save successfully'
            })
        except DirectoryCommission.DoesNotExist:
            return JsonResponse({
                'status': 'Fail',
                'msg': 'Object does not exist'
            })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 13
0
def delete_directory_member(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():
        try:
            obj = Employe.objects.get(pk=pk)

            log = str(obj.user.get_full_name()) + " Personel uyesi silindi"
            log = general_methods.logwrite(request, request.user, log)

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

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 14
0
def choose_coach_clup(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)
    clup = SportsClub.objects.get(pk=pk)

    coachsPk = []
    for coach in clup.coachs.all():
        coachsPk.append(coach.pk)
    athletes = Coach.objects.exclude(id__in=coachsPk)

    # license.athlete_set.first

    if request.method == 'POST':
        coach = request.POST.getlist('selected_options')
        if coach:
            for coa in coach:
                clup.coachs.add(Coach.objects.get(pk=coa))
                clup.save()

            log = str(clup) + " Klup antrenor ekledi"
            log = general_methods.logwrite(request, request.user, log)

        return redirect('sbs:update-club', pk=pk)
    return render(request, 'antrenor/Antrenor-sec.html', {'athletes': athletes})
Exemplo n.º 15
0
def faliyet_duzenle(request, pk):
    perm = general_methods.control_access(request)

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

    activity = Activity.objects.get(pk=pk)
    competition_form = ActivityForm(request.POST or None, instance=activity)
    if request.method == 'POST':

        if competition_form.is_valid():
            competition_form.save()

            log = str(request.POST.get('name')) + " faliyeti guncelledi"
            log = general_methods.logwrite(request, request.user, log)

            messages.success(request, 'Faaliyet Başarıyla Güncellenmiştir.')

            return redirect('sbs:faaliyet')
        else:

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

    return render(request, 'faliyet/faaliyet-guncelle.html', {
        'competition_form': competition_form,
        'competition': activity
    })
Exemplo n.º 16
0
def pagelogout(request):
    log = "cikis yaptı "
    log = general_methods.logwrite(request, str(log))
    logout(request)
    print('çikis yaptı ')

    return redirect('accounts:login')
Exemplo n.º 17
0
def forgot(request):
    if request.method == 'POST':
        mail = request.POST.get('username')
        obj = User.objects.filter(username=mail)
        print('ben geldim ')

        if obj.count() != 0:
            user = User.objects.get(username=mail)
            print(user)
            fdk = Forgot(user=user, status=False)
            fdk.save()

            log = general_methods.logwrite(request, " Yeni giris maili gönderildi")

            html_content = ''
            subject, from_email, to = 'Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', mail
            html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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://127.0.0.1:8000/newpassword?query=' + str(
            #     fdk.uuid) + '">http://127.0.0.1:8000/sbs/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'
            html_content = html_content + '<p> <strong>Yeni şifre oluşturma linki:</strong> <a href="'+settings.SITE_URL+'/sbs/newpassword?query=' + str(
                fdk.uuid) + '">'+settings.SITE_URL+'/sbs/profil-guncelle/?query=' + str(
                fdk.uuid) + '</p></a>'

            msg = EmailMultiAlternatives(subject, '', from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            messages.success(request, "Giriş bilgileriniz mail adresinize gönderildi. ")
            return redirect("accounts:login")
        else:
            messages.warning(request, "Geçerli bir mail adresi giriniz.")
            return redirect("accounts:forgot")

    return render(request, 'registration/forgot-password.html')
Exemplo n.º 18
0
def deleteClubUserFromClub(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 = SportClubUser.objects.get(pk=pk)
            club = SportsClub.objects.get(pk=club_pk)

            club.clubUser.remove(obj)

            log = str(club) + " Klup üyesi cikarildi"
            log = general_methods.logwrite(request, request.user, log)


            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'})
Exemplo n.º 19
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()

        log = str(obj.get_full_name()) + " ->" + str(
            obj.is_active) + "Durumu degiştirildi "
        log = general_methods.logwrite(request, request.user, log)
        print(obj.is_active)
        return JsonResponse({
            'status': 'Success',
            'messages': 'save successfully'
        })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 20
0
def updateDirectoryProfile(request):
    perm = general_methods.control_access(request)

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

    user = request.user
    directory_user = DirectoryMember.objects.get(user=user)
    person = Person.objects.get(pk=directory_user.person.pk)
    communication = Communication.objects.get(
        pk=directory_user.communication.pk)
    user_form = DisabledUserForm(request.POST or None, instance=user)
    person_form = DisabledPersonForm(request.POST or None, instance=person)
    communication_form = DisabledCommunicationForm(request.POST or None,
                                                   instance=communication)
    member_form = DisabledDirectoryForm(request.POST or None,
                                        instance=directory_user)
    password_form = SetPasswordForm(request.user, request.POST)

    if request.method == 'POST':

        if user_form.is_valid() and communication_form.is_valid(
        ) and person_form.is_valid() and member_form.is_valid(
        ) and password_form.is_valid():

            user.username = user_form.cleaned_data['email']
            user.first_name = unicode_tr(
                user_form.cleaned_data['first_name']).upper()
            user.last_name = unicode_tr(
                user_form.cleaned_data['last_name']).upper()
            user.email = user_form.cleaned_data['email']
            user.set_password(password_form.cleaned_data['new_password1'])
            user.save()

            person_form.save()
            communication_form.save()
            member_form.save()
            password_form.save()

            messages.success(request,
                             'Yönetim Kurul Üyesi Başarıyla Güncellenmiştir.')

            log = str(user.get_full_name()) + " yönetim kurulu guncellendi"
            log = general_methods.logwrite(request, request.user, log)

            return redirect('sbs:yonetim-kurul-profil-guncelle')

        else:

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

    return render(
        request, 'yonetim/yonetim-kurul-profil-guncelle.html', {
            'user_form': user_form,
            'communication_form': communication_form,
            'person_form': person_form,
            'password_form': password_form,
            'member_form': member_form
        })
Exemplo n.º 21
0
def project_subfirma(request, pk):
    perm = general_methods.control_access_personel(request)

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

    try:
        tasinmaz = Gtasinmaz.objects.get(pk=pk)
        if request.POST.get('title'):
            birim = Gkurum.objects.get(pk=request.POST.get('title'))
            tasinmaz.kurum.add(birim)
            tasinmaz.save()
            log = str(tasinmaz.pk) + " tasinmaz kullanan birim eklendi" + str(
                birim.name)
            log = general_methods.logwrite(request, log)
        return JsonResponse({
            'status': 'Success',
            'messages': 'save successfully',
            'pk': birim.pk
        })

    except:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
        messages.warning(request, 'Yeniden deneyiniz.')

    return redirect('sbs:tasinmaz-duzenle', pk=pk)
Exemplo n.º 22
0
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 = 'Etut Proje Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>ADALET BAKANLIGI PROJE TAKİP  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://127.0.0.1:8000/newpassword?query=' + str(
        #     fdk.uuid) + '">http://127.0.0.1:8000/sbs/profil-guncelle/?query=' + str(fdk.uuid) + '</p></a>'
        html_content = html_content + '<p> <strong>Yeni şifre oluşturma linki:</strong> <a href="' + settings.SITE_URL + '/sbs/newpassword?query=' + str(
            fdk.uuid
        ) + '">' + settings.SITE_URL + '/sbs/profil-guncelle/?query=' + str(
            fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        log = general_methods.logwrite(
            request, " Yeni giris maili gönderildi" + str(user))

        # 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'})
Exemplo n.º 23
0
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 = 'Spor  Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', user.email
        html_content = '<h2>TÜRKİYE GÜREŞ 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.tgf.gov.tr/newpassword?query=' + str(
            fdk.uuid
        ) + '">http://sbs.tgf.gov.tr/sbs/profil-guncelle/?query=' + str(
            fdk.uuid) + '</p></a>'
        msg = EmailMultiAlternatives(subject, '', from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        # 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)

        log = str(user.get_full_name()) + " sifre gonderildi"
        log = general_methods.logwrite(request, request.user, log)

        return JsonResponse({
            'status': 'Success',
            'msg': 'Şifre başarıyla gönderildi'
        })

    else:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})
Exemplo n.º 24
0
def clubUpdate(request, pk):
    perm = general_methods.control_access(request)

    if not perm:
        logout(request)
        return redirect('accounts:login')
    club = SportsClub.objects.get(id=pk)

    athletes = Athlete.objects.filter(licenses__sportsClub=club)


    try:
        com_id = club.communication.pk
        communication = Communication.objects.get(id=com_id)
        communication_form = CommunicationForm(request.POST or None, instance=communication)
    except:
        communication_form = CommunicationForm(request.POST or None)

    club_form = ClubForm(request.POST or None, request.FILES or None, instance=club)
    clubPersons = club.clubUser.all()
    clubCoachs = club.coachs.all()
    if request.method == 'POST':
        if club_form.is_valid():
            club_form.save()

            if not club.communication:
                communication = communication_form.save(commit=False)
                communication.save()
                club.communication = communication
                club.save()








            else:
                communication_form.save()

            log = str(club) + " Klup güncellendi"
            log = general_methods.logwrite(request, request.user, log)


            messages.success(request, 'Başarıyla Güncellendi')
            return redirect('sbs:kulupler')
        else:
            messages.warning(request, 'Alanları Kontrol Ediniz')

    return render(request, 'kulup/kulupDuzenle.html',
                  {'club_form': club_form, 'communication_form': communication_form, 'clubPersons': clubPersons,
                   'athletes': athletes,
                   'club': club, 'clubCoachs': clubCoachs})
Exemplo n.º 25
0
def edit_teskilat(request, pk):
    perm = general_methods.control_access_personel(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    teskilat = Gteskilat.objects.get(pk=pk)
    test = False
    if teskilat.mahaltype.shortname == 'YOK':
        test = True
    teskilat_form = GteskilatForm(request.POST or None, instance=teskilat)
    nitelik = Gbolge.objects.all()
    tasinmazlar = Gtasinmaz.objects.filter(
        tasinmazinTuru=Gtasinmaz.adaletYapisi)
    testasinmaz = Gtasinmaz.objects.filter(teskilat=teskilat)

    teskilat_form.fields['bam'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='BAM')
    teskilat_form.fields['bim'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='BİM')
    teskilat_form.fields['acm'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='ACM')
    teskilat_form.fields['ascm'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='ASCM')
    teskilat_form.fields['ida'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='İDA')
    teskilat_form.fields['ivm'].queryset = Gteskilat.objects.filter(
        mahaltype__shortname='İVD')
    if request.method == 'POST':
        if teskilat_form.is_valid():

            # for item in teskilat.mahaltype.all():
            #     teskilat.mahaltype.remove(item)
            #     teskilat.save()

            teskilat_form.save()
            # if request.POST.getlist('ages'):
            #     for item in request.POST.getlist('ages'):
            #         teskilat.mahaltype.add(Gbolge.objects.get(pk=item))
            #         teskilat.save()
            log = str(teskilat.city) + " teşkilat yapısı güncellendi."
            log = general_methods.logwrite(request, log)
            messages.success(request, 'Teşkilat Yapısı güncellendi.')
        else:
            print('alanlari kontrol ediniz ')
            messages.warning(request, 'Alanları kontrol ediniz.')
    return render(
        request, 'teskilat/teskilatGuncelle.html', {
            'project_form': teskilat_form,
            'nitelik': nitelik,
            'tasinmazlar': tasinmazlar,
            'testasinmaz': testasinmaz,
            'test': test,
        })
Exemplo n.º 26
0
def login(request):
    if request.user.is_authenticated is True:
        return redirect('sbs:admin')

    if request.method == 'POST':

        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(username=username, password=password)
        if user is not None:
            # correct username and password login the user
            auth.login(request, user)

            log = general_methods.logwrite(request, " Giris yapti")



            if user.groups.all()[0].name == 'Yonetim':
                return redirect('sbs:federasyon')

            elif user.groups.all()[0].name == 'Admin':
                return redirect('sbs:admin')

            elif user.groups.all()[0].name == 'Personel':
                return redirect('sbs:personel')

            elif user.groups.all()[0].name == 'Teknik':
                return redirect('sbs:anasayfa-teknik')





            else:
                return redirect('accounts:logout')

        else:
            # eski kullanici olma ihtimaline göre sisteme girme yöntemi
            try:
                user = SportsClub.objects.get(username=request.POST.get('username'),
                                              password=request.POST.get('password'))
                if user is not None:
                    return redirect('accounts:newlogin', user.pk)
            except:
                print()

            messages.add_message(request, messages.SUCCESS, 'Mail Adresi Ve Şifre Uyumsuzluğu')
            return render(request, 'registration/login.html')

    return render(request, 'registration/login.html')
Exemplo n.º 27
0
def rejected_preRegistration(request, pk):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    messages.success(request, 'Klup basvurusu reddedildi ')
    veri = PreRegistration.objects.get(pk=pk)
    veri.status = PreRegistration.DENIED
    veri.save()
    prepegidtration = PreRegistration.objects.all()
    log = str(veri.name) + " Klup basvurusu reddedildi"
    log = general_methods.logwrite(request, request.user, log)
    return render(request, 'kulup/kulupBasvuru.html',
                  {'prepegidtration': prepegidtration})
Exemplo n.º 28
0
def login(request):
    if request.user.is_authenticated is True:
        return redirect('sbs:admin')

    if request.method == 'POST':

        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(username=username, password=password)
        if user is not None:
            # correct username and password login the user
            auth.login(request, user)

            print(general_methods.get_client_ip(request))

            log = general_methods.logwrite(request, request.user,
                                           " Giris yapti")

            # eger user.groups birden fazla ise klup üyesine gönder yoksa devam et

            if user.groups.filter(name='KulupUye').exists():
                return redirect('sbs:kulup-uyesi')

            elif user.groups.all()[0].name == 'Antrenor':
                return redirect('sbs:antrenor')

            elif user.groups.all()[0].name == 'Hakem':
                return redirect('sbs:hakem')

            elif user.groups.all()[0].name == 'Sporcu':
                return redirect('sbs:sporcu')

            elif user.groups.all()[0].name == 'Yonetim':
                return redirect('sbs:federasyon')

            elif user.groups.all()[0].name == 'Admin':
                return redirect('sbs:admin')

            elif user.groups.all()[0].name == 'KulupUye':
                return redirect('sbs:kulup-uyesi')

            else:
                return redirect('accounts:logout')

        else:

            messages.warning(request, 'Mail Adresi Ve Şifre Uyumsuzluğu')
            return render(request, 'registration/login.html')

    return render(request, 'registration/login.html')
Exemplo n.º 29
0
def choose_referee(request, pk):
    perm = general_methods.control_access(request)
    if not perm:
        logout(request)
        return redirect('accounts:login')
    competition = Competition.objects.get(pk=pk)
    competitionRole = JudgeRole.objects.all()
    if request.method == 'POST':
        if request.POST.get('judge') and request.POST.get('role'):
            if Judge.objects.filter(
                    pk=request.POST.get('judge')) and JudgeRole.objects.filter(
                        pk=request.POST.get('role')):
                judge = Judge.objects.get(pk=request.POST.get('judge'))
                role = JudgeRole.objects.get(pk=request.POST.get('role'))
                rol = CompetitionJudgeRole(judge=judge, role=role)
                rol.save()
                competition.judges.add(rol)
                competition.save()

                # mail gönderiliyor

                log = str(judge.user.get_full_name(
                )) + " Hakem " + competition.name + " müsabasına  eklendi"
                log = general_methods.logwrite(request, request.user, log)

                html_content = ''
                subject, from_email, to = 'Güreş Bilgi Sistemi Kullanıcı Bilgileri', '*****@*****.**', judge.user.email
                html_content = '<h2>TÜRKİYE GÜREŞ FEDERASYONU BİLGİ SİSTEMİ</h2>'
                html_content += str(
                    competition.name) + "müsabakasına      " + str(
                        rol.role) + "      olarak eklendiniz."
                msg = EmailMultiAlternatives(subject, '', from_email, [to])
                msg.attach_alternative(html_content, "text/html")
                msg.send()

    coa = []
    for item in competition.judges.all():
        coa.append(item.judge.user.id)

    athletes = Judge.objects.exclude(user__in=coa)
    # return redirect('sbs:musabaka-duzenle', pk=pk)
    return render(
        request, 'musabaka/musabaka-hakem-sec.html', {
            'athletes': athletes,
            'competitionRole': competitionRole,
            'competition': competition
        })
Exemplo n.º 30
0
def add_offer_to_project(request, pk):
    perm = general_methods.control_access_personel(request)

    print('geldim')

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

    message = request.POST.get('message')
    project = Gtasinmaz.objects.get(pk=pk)
    username = request.user.first_name + " " + request.user.last_name
    person = getProfileImage(request)
    imageUrl = MEDIA_URL + "profile/logo.png"
    date = datetime.now()
    dates = date.strftime('%d/%m/%Y %H:%M')

    log = str(
        project.pk) + " tasinmazina  yeni bir görüs ekledi time=" + str(dates)
    log = general_methods.logwrite(request, log)

    project.offers.create(message=message, added_by=request.user)

    # for item in project.employees.all().exclude(employee__user=request.user):
    #     notification = Notification(notification=project.name +" Projesine yeni bir görüs eklendi.",
    #                                 users=item.employee.user,
    #                                 entityId=project.pk,
    #                                 tableName="proje"
    #                                 )
    #     notification.save()
    #
    #
    #

    try:
        print()

        return JsonResponse({
            'status': 'Success',
            'username': username,
            'image': imageUrl,
            'dates': dates
        })
    except:
        return JsonResponse({'status': 'Fail', 'msg': 'Not a valid request'})

    return redirect('sbs:proje-duzenle', pk=pk)