Exemplo n.º 1
0
def user_password_change(request):
    is_follow = False
    form = UserPasswordChangeForm2(request.user, request.POST or None)
    user = get_object_or_404(User, username=request.user.username)
    foll_count = Following.get_fol_count(user)
    follower_count = foll_count["followers"]
    followed_count = foll_count["followeds"]
    ppform = PhotoForm()
    cpform = CoverPhotoForm()
    activities = UserLog.objects.filter(
        is_active=True, user=request.user).order_by("-activity_date")[:5]
    if user != request.user:
        is_follow = Following.is_follow_user(follower=request.user,
                                             followed=user)
    if request.method == "POST":
        if form.is_valid():
            user = form.save(commit=True)
            update_session_auth_hash(request, user)
            messages.success(request,
                             'Tebrikler Şifreniz Başarıyla Güncellendi')
            return redirect(request.user.userprofile.get_user_url())
        else:
            messages.warning(request,
                             "Lütfen aşağıdaki uyarılara dikkat edin.")
            return render(request,
                          "user/passchange.html",
                          context={
                              "activities": activities,
                              "cpform": cpform,
                              "ppform": ppform,
                              "follower_count": follower_count,
                              "followed_count": followed_count,
                              "is_follow": is_follow,
                              "form": form
                          })

    search_form = SearchForm(data=request.GET or None)
    if search_form.is_valid():
        arama = search_form.cleaned_data.get("search", None)
        if arama:
            return redirect(
                reverse('pie_thing:index') + '?search={}'.format(arama))
    return render(request,
                  "user/passchange.html",
                  context={
                      "activities": activities,
                      "search_form": search_form,
                      "cpform": cpform,
                      "ppform": ppform,
                      "follower_count": follower_count,
                      "followed_count": followed_count,
                      "is_follow": is_follow,
                      "form": form
                  })
Exemplo n.º 2
0
def about_user(request, username):
    user = get_object_or_404(User, username=username)
    takip_ediyor_mu = False
    takipci_takip_edilen = Following.get_takipci_sayisi(user)
    takipciler = takipci_takip_edilen['takipciler']
    takip_edilenler = takipci_takip_edilen['takip_edilenler']
    if user != request.user:
        takip_ediyor_mu = Following.kullanici_takip_kontrol(
            follower=request.user, followed=user)
    return render(request, "auths/profile/about_me.html",
                  context={'takipciler': takipciler, 'takip_edilenler': takip_edilenler, 'takip_ediyor_mu': takip_ediyor_mu,
                           'user': user, 'page': 'about'})
Exemplo n.º 3
0
def user_settings(request):
    is_follow = False
    gender = request.user.userprofile.gender
    bio = request.user.userprofile.bio
    birth_date = request.user.userprofile.birth_date
    initial = {"gender": gender, "bio": bio, "birth_date": birth_date}
    form = UserProfileUpdateForm(request.POST or None,
                                 request.FILES or None,
                                 instance=request.user,
                                 initial=initial)
    ppform = PhotoForm()
    cpform = CoverPhotoForm()
    activities = UserLog.objects.filter(
        is_active=True, user=request.user).order_by("-activity_date")[:5]
    if form.is_valid():
        user = form.save(commit=True)
        gender = form.cleaned_data.get("gender", None)
        bio = form.cleaned_data.get("bio", None)
        birth_date = form.cleaned_data.get("birth_date", None)

        user.userprofile.gender = gender
        user.userprofile.bio = bio
        user.userprofile.birth_date = birth_date
        user.userprofile.save()
        messages.success(request, "Tebrikler profiliniz başarıyla güncellendi")
        return redirect(user.userprofile.get_user_url())
    user = get_object_or_404(User, username=request.user.username)
    foll_count = Following.get_fol_count(user)
    follower_count = foll_count["followers"]
    followed_count = foll_count["followeds"]
    if user != request.user:
        is_follow = Following.is_follow_user(follower=request.user,
                                             followed=user)
    search_form = SearchForm(data=request.GET or None)
    if search_form.is_valid():
        arama = search_form.cleaned_data.get("search", None)
        if arama:
            return redirect(
                reverse('pie_thing:index') + '?search={}'.format(arama))

    return render(request,
                  "user/settings.html",
                  context={
                      "activities": activities,
                      "cpform": cpform,
                      "ppform": ppform,
                      "search_form": search_form,
                      "follower_count": follower_count,
                      "followed_count": followed_count,
                      "is_follow": is_follow,
                      "form": form
                  })
Exemplo n.º 4
0
def user_profile(request, username):
    user = get_object_or_404(User, username=username)
    blog_list = Blog.objects.filter(user=user)
    takip_ediyor_mu = False
    takipci_takip_edilen = Following.get_takipci_sayisi(user)
    takipciler = takipci_takip_edilen['takipciler']
    takip_edilenler = takipci_takip_edilen['takip_edilenler']
    if user != request.user:
        takip_ediyor_mu = Following.kullanici_takip_kontrol(
            follower=request.user, followed=user)
    return render(request, 'auths/profile/user_profile.html',
                  context={'takipciler': takipciler, 'takip_edilenler': takip_edilenler, 'takip_ediyor_mu': takip_ediyor_mu,
                           'user': user, 'blog_list': blog_list, 'page': 'user-profile'})
Exemplo n.º 5
0
def userProfile(request, username):
    response = HttpResponseRedirect('/')
    response.delete_cookie('_gat', domain='pencilpie.com')
    response.delete_cookie('_ga', domain='pencilpie.com')
    response.delete_cookie('_gid', domain='pencilpie.com')
    is_follow = False
    search_form = SearchForm(data=request.GET or None)
    usero = get_object_or_404(User, username=username)
    activities = UserLog.objects.filter(
        is_active=True, user=usero).order_by("-activity_date")[:5]
    ppform = PhotoForm()
    cpform = CoverPhotoForm()
    repost_form = RepostForm()
    report_form = ReportForm()
    thing_form = ThingForm()
    user = get_object_or_404(User, username=username)
    follower = Following.is_follow_user(request.user, user)
    is_follow_me = Following.is_follow_user(user, request.user)
    foll_count = Following.get_fol_count(user)
    follower_count = foll_count["followers"]
    followed_count = foll_count["followeds"]
    if user != request.user:
        is_follow = Following.is_follow_user(follower=request.user,
                                             followed=user)

    if search_form.is_valid():
        arama = search_form.cleaned_data.get("search", None)
        if arama:
            return redirect(
                reverse('pie_thing:index') + '?search={}'.format(arama))

    return render(request,
                  "user/profile.html",
                  context={
                      "activities": activities,
                      "search_form": search_form,
                      "is_follow_me": is_follow_me,
                      "isfollow": follower,
                      "thing_form": thing_form,
                      "repost_form": repost_form,
                      "report_form": report_form,
                      "cpform": cpform,
                      "ppform": ppform,
                      "follower_count": follower_count,
                      "followed_count": followed_count,
                      "is_follow": is_follow,
                      "user": user
                  })
Exemplo n.º 6
0
def user_password_change(request):
    # form = UserPasswordChangeForm(user=request.user, data=request.POST or None)
    form = UserPasswordChangeForm2(user=request.user,
                                   data=request.POST or None)
    takip_ediyor_mu = False
    takipci_ve_takip_edilen = Following.kullanici_takip_edilenler_ve_takipciler(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    if form.is_valid():
        # new_password = form.cleaned_data.get('new_password')
        # request.user.set_password(new_password)
        # request.user.save()
        # update_session_auth_hash(request, request.user)
        user = form.save(commit=True)
        update_session_auth_hash(request, user)
        messages.success(request,
                         'Tebrikler parolanın başırı ile güncelendi',
                         extra_tags='success')
        return HttpResponseRedirect(
            reverse('user-profile', kwargs={'username':
                                            request.user.username}))

    return render(request,
                  'auths/profile/password_change.html',
                  context={
                      'takip_edilenler': takip_edilenler,
                      'takipciler': takipciler,
                      'takip_ediyor_mu': takip_ediyor_mu,
                      'form': form,
                      'page': 'password-change'
                  })
def user_password_change(request):
    # form = UserPasswordChangeForm(user=request.user, data=request.POST or None)
    form = UserPasswordChangeForm2(user=request.user,
                                   data=request.POST or None)
    takipci_ve_takip_edilen = Following.kullaniciyi_takip_edilenler_ve_takipciler(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    if form.is_valid():
        user = form.save(commit=True)
        update_session_auth_hash(request, user)
        # new_password = form.cleaned_data.get('new_password')
        # request.user.set_password(new_password)
        # request.user.save()
        # update_session_auth_hash(request, request.user)
        return HttpResponseRedirect(
            reverse('user_profile', kwargs={'username':
                                            request.user.username}))
    return render(request,
                  'BlogTemplate/password_change.html',
                  context={
                      'form': form,
                      'page': 'change',
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                  })
Exemplo n.º 8
0
def post_list_favorite_user(request, slug):
    page = request.GET.get('page', 1)
    blog = get_object_or_404(Blog, slug=slug)
    users = blog.get_added_favorite_users_object()
    my_followed_users = Following.takip_edilen_kullanici_adlari(
        user=request.user)
    paginator = Paginator(users, 1)
    try:
        users = paginator.page(page)
    except PageNotAnInteger:
        users = paginator.page(1)
    except EmptyPage:
        users = paginator.page(paginator.num_pages)
    html = render_to_string(
        'blog/include/favorite-include/favorite-user-list.html',
        context={
            'users': users,
            'my_followed_users': my_followed_users
        },
        request=request)

    page_html = render_to_string(
        'blog/include/favorite-include/buttons/show_more_button.html',
        context={
            'post': blog,
            'users': users
        },
        request=request)

    return JsonResponse(data={'html': html, 'page_html': page_html})
Exemplo n.º 9
0
def user_river(request, username):
    is_follow = False
    user = get_object_or_404(User, username=username)
    foll_count = Following.get_fol_count(user)
    follower_count = foll_count["followers"]
    followed_count = foll_count["followeds"]
    if user != request.user:
        is_follow = Following.is_follow_user(follower=request.user,
                                             followed=user)
    return render(request,
                  "user/river.html",
                  context={
                      "follower_count": follower_count,
                      "followed_count": followed_count,
                      "is_follow": is_follow,
                      "user": user
                  })
Exemplo n.º 10
0
def user_about(request, username):
    user = get_object_or_404(User, username=username)
    takip_ediyor_mu = False
    takipci_ve_takip_edilen = Following.kullaniciyi_takip_edilenler_ve_takipciler(
        user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    if user != request.user:
        takip_ediyor_mu = Following.kullaniciyi_takip_ediyor_mu(
            follower=request.user, followed=user)

    return render(request,
                  'ProfileTemplate/about.html',
                  context={
                      'user': user,
                      'page': 'about',
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      'takip_ediyor_mu': takip_ediyor_mu,
                  })
Exemplo n.º 11
0
def user_about(request, username):
    takip_ediyor_mu = False
    user = get_object_or_404(User, username=username)
    takipci_ve_takip_edilen = Following.kullanici_takiplesme_tablosu(user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    # eğer kendi profiline girmişse fonksiyon gereksiz çalışmasın diye
    if user != request.user:
        takip_ediyor_mu = Following.kullanici_takip_kontrol(
            follower=request.user, followed=user)

    return render(request,
                  "auths/profile/about_me.html",
                  context={
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      "takip_ediyor_mu": takip_ediyor_mu,
                      "user": user,
                      "page": "about"
                  })
Exemplo n.º 12
0
def user_settings(request):
    sex = request.user.userprofile.sex
    bio = request.user.userprofile.bio
    profile_photo = request.user.userprofile.profile_photo
    dogum_tarihi = request.user.userprofile.dogum_tarihi

    takipci_ve_takip_edilen = Following.kullanici_takiplesme_tablosu(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    initial = {
        'sex': sex,
        'bio': bio,
        'profile_photo': profile_photo,
        "dogum_tarihi": dogum_tarihi
    }
    form = UserProfileUpdateForm(initial=initial,
                                 instance=request.user,
                                 data=request.POST or None,
                                 files=request.FILES or None)
    if request.method == "POST":
        if form.is_valid():
            user = form.save(commit=True)
            bio = form.cleaned_data.get('bio', None)
            sex = form.cleaned_data.get('sex', None)
            dogum_tarihi = form.cleaned_data.get("dogum_tarihi", None)
            profile_photo = form.cleaned_data.get('profile_photo', None)

            user.userprofile.bio = bio
            user.userprofile.sex = sex
            user.userprofile.dogum_tarihi = dogum_tarihi
            user.userprofile.profile_photo = profile_photo
            user.userprofile.save()
            messages.success(
                request,
                "Tebrikler Kullanıcı Bilgileriniz Başarıyla Güncellendi.",
                extra_tags="success")
            return HttpResponseRedirect(
                reverse('auths:user_profile',
                        kwargs={'username': user.username}))
        else:
            messages.warning(request,
                             "Lütfen Form Alanlarına Doğru Giriniz.",
                             extra_tags="danger")
    return render(request,
                  "auths/profile/settings.html",
                  context={
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      "form": form,
                      'page': 'settings'
                  })
Exemplo n.º 13
0
def user_profile(request, username):
    takip_ediyor_mu = False
    user = get_object_or_404(User, username=username)
    takipci_ve_takip_edilen = Following.kullanici_takip_edilenler_ve_takipciler(
        user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    if user != request.user:
        takip_ediyor_mu = Following.kullaniciyi_takip_ediyor_mu(
            follower=request.user, followed=user)

    return render(request,
                  'auths/profile/user_profile.html',
                  context={
                      'takip_edilenler': takip_edilenler,
                      'takipciler': takipciler,
                      'takip_ediyor_mu': takip_ediyor_mu,
                      'user': user,
                      'page': 'profile',
                  })
Exemplo n.º 14
0
def kullanici_takip_et_cikar(request):
    if not request.is_ajax():
        return HttpResponseBadRequest()

    data = {'html': ' ','is_valid': True, 'msg':'<b>Takip Ediliyor</b>'}
    follower_username = request.GET.get('follower_username', None)
    followed_username = request.GET.get('followed_username', None)

    follower = get_object_or_404(User, username=follower_username)
    followed = get_object_or_404(User, username=followed_username)
    takip_ediyor_mu = Following.kullaniciyi_takip_ediyor_mu(follower=follower,followed=followed)

    if not takip_ediyor_mu:
        Following.kullanici_takip_et(follower=follower, followed=followed)
        data.update({'msg': 'Takipten Çıkar'})
    else:
        Following.kullaniciyi_takipten_cikar(follower=follower, followed=followed)
        data.update({'msg':'Takip Et'})

    takipci_ve_takip_edilen_sayisi = Following.kullaniciyi_takip_edilenler_ve_takipciler(followed)
    context = {'takipciler':takipci_ve_takip_edilen_sayisi['takipciler'],
               'takip_edilenler':takipci_ve_takip_edilen_sayisi['takip_edilenler']}
    html = render_to_string('ProfileTemplate/index.html',context=context, request=request)
    data.update({'html':html})
    return JsonResponse(data=data)
Exemplo n.º 15
0
def user_profile(request, username):
    takip_ediyor_mu = False
    user = get_object_or_404(User, username=username)
    blog_list = Blog.objects.filter(user=user)
    takipci_ve_takip_edilen = Following.kullanici_takiplesme_tablosu(user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    #eğer kendi profiline girmişse fonksiyon gereksiz çalışmasın diye
    if user != request.user:
        takip_ediyor_mu = Following.kullanici_takip_kontrol(
            follower=request.user, followed=user)
    return render(request,
                  "auths/profile/userprofile.html",
                  context={
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      "takip_ediyor_mu": takip_ediyor_mu,
                      "user": user,
                      "blog_list": blog_list,
                      'page': 'user_profile'
                  })
Exemplo n.º 16
0
def user_settings(request):
    sex = request.user.userprofile.sex
    bio = request.user.userprofile.bio
    profile_photo = request.user.userprofile.profile_photo
    dogum_tarihi = request.user.userprofile.dogum_tarihi
    initial = {
        'sex': sex,
        'bio': bio,
        'profile_photo': profile_photo,
        'dogum_tarihi': dogum_tarihi
    }
    form = UserProfileUpdateForm(initial=initial,
                                 instance=request.user,
                                 data=request.POST or None,
                                 files=request.FILES or None)
    takip_ediyor_mu = False
    takipci_ve_takip_edilen = Following.kullanici_takip_edilenler_ve_takipciler(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']
    if request.method == 'POST':
        if form.is_valid():
            user = form.save(commit=True)
            bio = form.cleaned_data.get('bio', None)
            sex = form.cleaned_data.get('sex', None)
            dogum_tarihi = form.cleaned_data.get('dogum_tarihi', None)
            profile_photo = form.cleaned_data.get('profile_photo', None)
            user.userprofile.sex = sex
            user.userprofile.profile_photo = profile_photo
            user.userprofile.bio = bio
            user.userprofile.dogum_tarihi = dogum_tarihi
            user.userprofile.save()
            messages.success(
                request,
                'Tebrikler kullanıcı bilgileriniz başarı ile güncellendi',
                extra_tags='success')
            return HttpResponseRedirect(
                reverse('user-profile', kwargs={'username': user.username}))
    else:
        messages.warning(request,
                         'Lütfen form alanlarını doğru giriniz',
                         extra_tags='danger')
    return render(request,
                  'auths/profile/settings.html',
                  context={
                      'takip_edilenler': takip_edilenler,
                      'takipciler': takipciler,
                      'takip_ediyor_mu': takip_ediyor_mu,
                      'form': form,
                      'page': 'settings'
                  })
Exemplo n.º 17
0
def user_profile(request, username):
    takip_ediyor_mu = False
    user = get_object_or_404(User, username=username)
    article_list = Product.objects.filter(user=user)
    takipci_ve_takip_edilen = Following.kullaniciyi_takip_edilenler_ve_takipciler(
        user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    comments = len(Comment.objects.filter(user=user))
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']
    if user != request.user:
        takip_ediyor_mu = Following.kullaniciyi_takip_ediyor_mu(
            follower=request.user, followed=user)

    return render(request,
                  'ProfileTemplate/articles.html',
                  context={
                      'user': user,
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      'comments': comments,
                      'takip_ediyor_mu': takip_ediyor_mu,
                      'article_list': article_list,
                      'page': 'user_profile'
                  })
Exemplo n.º 18
0
def get_comments_on_anywhere(user):

    content_type = ContentType.objects.get_for_model(Thing)
    user = User.objects.get(username=user.username)
    listemiz = list(Following.get_followed_username(user))
    listemiz.append(user)
    comments = Comment.objects.filter(
        user__username__in=listemiz,
        content_type=content_type).order_by("-created_date")
    things = Thing.objects.filter(
        author__username__in=listemiz).order_by("-created_date")
    if comments and things:
        result_list = sorted(chain(things, comments),
                             key=lambda instance: instance.created_date)[::-1]
        print(result_list[0]._meta.object_name)
        return result_list
    else:
        return False
Exemplo n.º 19
0
def user_password_change(request):
    # form = PasswordChangeForm(user=request.user, data=request.POST or None) Manuel Oluşturduğumuz
    form = PasswordChangeForm2(user=request.user, data=request.POST or None)
    takipci_takip_edilen = Following.get_takipci_sayisi(request.user)
    takipciler = takipci_takip_edilen['takipciler']
    takip_edilenler = takipci_takip_edilen['takip_edilenler']
    if form.is_valid():
        # new_password = form.cleaned_data.get('new_password')
        # request.user.set_password(new_password)
        # request.user.save()
        # update_session_auth_hash(request, request.user)
        user = form.save(commit=True)
        update_session_auth_hash(request, user)
        messages.success(
            request, "Tebrikler şifreniz değiştirilmiştir.", extra_tags="success")
        return HttpResponseRedirect(reverse('user-profile', kwargs={'username': request.user.username}))
    return render(request, "auths/profile/change_password.html",
                  context={'takipciler': takipciler, 'takip_edilenler': takip_edilenler,
                           'form': form, 'page': 'password-change'})
Exemplo n.º 20
0
def user_settings(request):
    cinsiyet = request.user.userprofile.cinsiyet
    bio = request.user.userprofile.bio
    profile_photo = request.user.userprofile.profile_photo
    # dogum_tarihi = request.user.userprofile.dogum_tarihi
    initial = {
        'cinsiyet': cinsiyet,
        'bio': bio,
        'profile_photo': profile_photo
    }
    form = UserProfileUpdateForm(initial=initial,
                                 instance=request.user,
                                 data=request.POST or None,
                                 files=request.FILES or None)
    takipci_ve_takip_edilen = Following.kullaniciyi_takip_edilenler_ve_takipciler(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']
    if form.is_valid():
        user = form.save(commit=True)
        bio = form.cleaned_data.get('bio', None)
        cinsiyet = form.cleaned_data.get('cinsiyet', None)
        profile_photo = form.cleaned_data.get('profile_photo', None)
        email = form.cleaned_data.get('email', None)
        print("email", email)
        user.userprofile.cinsiyet = cinsiyet
        user.userprofile.bio = bio
        user.userprofile.email = email
        user.userprofile.profile_photo = profile_photo
        user.userprofile.save()
        return HttpResponseRedirect(
            reverse('user_profile', kwargs={'username': user.username}))

    return render(request,
                  'ProfileTemplate/settings.html',
                  context={
                      'form': form,
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                  })
Exemplo n.º 21
0
def user_password_change(request):
    form = UserPasswordChangeForm2(user=request.user,
                                   data=request.POST or None)
    takipci_ve_takip_edilen = Following.kullanici_takiplesme_tablosu(
        request.user)
    takipciler = takipci_ve_takip_edilen['takipciler']
    takip_edilenler = takipci_ve_takip_edilen['takip_edilenler']

    if form.is_valid():
        user = form.save(commit=True)
        update_session_auth_hash(request, user)
        messages.success(request, "Tebrikler Şifreniz Başarıyla Güncellendi.")
        return HttpResponseRedirect(
            reverse('auths:user_profile',
                    kwargs={"username": request.user.username}))
    return render(request,
                  "auths/profile/password_change.html",
                  context={
                      'takipciler': takipciler,
                      'takip_edilenler': takip_edilenler,
                      "form": form,
                      'page': 'password_change'
                  })
Exemplo n.º 22
0
def user_settings(request):
    bio = request.user.userprofile.bio
    sex = request.user.userprofile.sex
    profile_photo = request.user.userprofile.profile_photo
    dogum_tarihi = request.user.userprofile.born_time
    initial = {'sex': sex, 'bio': bio,
               'profile_photo': profile_photo, 'dogum_tarihi': dogum_tarihi}

    form = UserProfileUpdateForm(initial=initial, instance=request.user,
                                 data=request.POST or None, files=request.FILES or None)

    takipci_takip_edilen = Following.get_takipci_sayisi(request.user)
    takipciler = takipci_takip_edilen['takipciler']
    takip_edilenler = takipci_takip_edilen['takip_edilenler']

    if request.method == "POST":
        if form.is_valid():
            user = form.save(commit=True)
            bio = form.cleaned_data.get('bio', None)
            sex = form.cleaned_data.get('sex', None)
            profile_photo = form.cleaned_data.get('profile_photo', None)
            dogum_tarihi = form.cleaned_data.get('dogum_tarihi', None)

            user.userprofile.sex = sex
            user.userprofile.profile_photo = profile_photo
            user.userprofile.bio = bio
            user.userprofile.born_time = dogum_tarihi
            user.userprofile.save()
            messages.success(
                request, "Tebrikler kullanıcı bilgileriniz başarıyla güncellendi.", extra_tags='success')
            return HttpResponseRedirect(reverse('user-profile', kwargs={'username': user.username}))
        else:
            messages.warning(
                request, message="Lütfen verileri doğru giriniz.", extra_tags="danger")
    return render(request, 'auths/profile/settings.html',
                  context={'takipciler': takipciler, 'takip_edilenler': takip_edilenler,
                           'form': form, 'page': 'settings'})
Exemplo n.º 23
0
def user_followeds(request, username):
    user = get_object_or_404(User, username=username)
    followers = Following.get_followeds(user)
    ppform = PhotoForm()
    cpform = CoverPhotoForm()
    search_form = SearchForm(data=request.GET or None)
    if search_form.is_valid():
        arama = search_form.cleaned_data.get("search", None)
        if arama:
            return redirect(
                reverse('pie_thing:index') + '?search={}'.format(arama))
    usero = get_object_or_404(User, username=username)
    activities = UserLog.objects.filter(
        is_active=True, user=usero).order_by("-activity_date")[:5]
    return render(request,
                  "user/followeds.html",
                  context={
                      "activities": activities,
                      "cpform": cpform,
                      "ppform": ppform,
                      "search_form": search_form,
                      "user": user,
                      "followers": followers
                  })
Exemplo n.º 24
0
def get_post_on_anywhere(user):
    user = User.objects.get(username=user.username)
    listemiz = list(Following.get_followed_username(user))

    posts = Comment.objects.filter(user__username__in=listemiz)
    return posts
Exemplo n.º 25
0
def explore(request):
    user = User.objects.get(username=request.user.username)
    listemiz = list(Following.get_followed_username(user))
    print(type(listemiz))
    comments = Comment.objects.filter(user__username__in=listemiz)
    pass
Exemplo n.º 26
0
 def get_followed_count(self):
     foll_count = Following.get_fol_count(self.user)
     followed_count = foll_count["followeds"]
     return followed_count
Exemplo n.º 27
0
    def get_followed_list(self):

        followed = Following.get_followeds(self.user)

        return followed.values_list('followed__username', flat=True)