Esempio n. 1
0
def profile(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    form = None
    age = None
    invited = False

    if user.is_authenticated():
        #check if we've invited the user to be our friend
        try:
            inv = other_user.userprofile.invites.get(sender=user)
            invited = True
        except Invite.DoesNotExist:
            invited = False

        age = util.get_age(other_user.userprofile.birthdate)

        # post a comment
        if util.can_users_interract(user, other_user):
            form = myforms.CommentForm()
        else:
            form = None

    return render_to_response('profile/profile.html', {
        'other_user': other_user,
        'form': form,
        'invited': invited,
        'age': age
    },
                              context_instance=RequestContext(request))
Esempio n. 2
0
File: views.py Progetto: jcnix/shade
def profile(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    form = None
    age = None
    invited = False

    if user.is_authenticated():
        #check if we've invited the user to be our friend
        try:
            inv = other_user.userprofile.invites.get(sender=user)
            invited = True
        except Invite.DoesNotExist:
            invited = False

        age = util.get_age(other_user.userprofile.birthdate)

        # post a comment
        if util.can_users_interract(user, other_user):
            form = myforms.CommentForm()
        else:
            form = None

    return render_to_response('profile/profile.html', {'other_user': other_user, 
        'form': form, 'invited': invited, 'age': age},
        context_instance=RequestContext(request))
Esempio n. 3
0
File: views.py Progetto: jcnix/shade
def view_friends(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if util.can_users_interract(user, other_user):
        return render_to_response('profile/friends.html', {'other_user': other_user},
                context_instance=RequestContext(request))
Esempio n. 4
0
def view_friends(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if util.can_users_interract(user, other_user):
        return render_to_response('profile/friends.html',
                                  {'other_user': other_user},
                                  context_instance=RequestContext(request))
Esempio n. 5
0
def post(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if util.can_users_interract(user, other_user):
        if request.method == 'POST':
            comment = Comment.objects.create(author=user,
                                             read=False,
                                             sent=datetime.datetime.now())
            form = myforms.CommentForm(request.POST, instance=comment)
            comment = form.save()
            other_user.userprofile.comments.add(comment)
    return HttpResponseRedirect('/dashboard/')
Esempio n. 6
0
def comment_img(request, url, img_id):
    user = request.user
    prof = UserProfile.objects.get(url=url)
    other_user = prof.user
    img = get_object_or_404(Picture, id=img_id)
    if util.can_users_interract(user, other_user):
        if request.method == 'POST':
            comment = Comment.objects.create(author=user,
                                             read=False,
                                             sent=datetime.datetime.now())
            form = myforms.CommentForm(request.POST, instance=comment)
            comment = form.save()
            img.comments.add(comment)
    return HttpResponseRedirect('/profile/' + url + '/images/' + str(img_id) +
                                '/view/')
Esempio n. 7
0
def comment_img(request, url, img_id):
    user = request.user
    prof = UserProfile.objects.get(url=url)
    other_user = prof.user
    img = get_object_or_404(Picture, id=img_id)
    if util.can_users_interract(user, other_user):
        if request.method == 'POST':
            comment = Comment.objects.create(
                    author=user,
                    read=False,
                    sent = datetime.datetime.now()
                    )
            form = myforms.CommentForm(request.POST, instance=comment)
            comment = form.save()
            img.comments.add(comment)
    return HttpResponseRedirect('/profile/'+url+'/images/'+str(img_id)+'/view/')
Esempio n. 8
0
def post(request, url):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if util.can_users_interract(user, other_user):
        if request.method == 'POST':
            comment = Comment.objects.create(
                    author=user,
                    read=False,
                    sent = datetime.datetime.now()
                    )
            form = myforms.CommentForm(request.POST, instance=comment)
            comment = form.save()
            other_user.userprofile.comments.add(comment)
    return HttpResponseRedirect('/dashboard/')
Esempio n. 9
0
def reply(request, comment_id):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if request.method == 'POST':
        if util.can_users_interract(user, other_user):
            comment = get_object_or_404(Comment, id=comment_id)
            subcomment = SubComment.objects.create(
                author=user,
                post=request.POST['post'],
                read=False,
                sent=datetime.datetime.now(),
                parent=comment,
            )
            comment.subcomments.add(subcomment)

    return HttpResponseRedirect('/profile/' + other_user.userprofile.url)
Esempio n. 10
0
def reply(request, comment_id):
    user = request.user
    prof = get_object_or_404(UserProfile, url=url)
    other_user = prof.user

    if request.method == 'POST':
        if util.can_users_interract(user, other_user):
            comment = get_object_or_404(Comment, id=comment_id)
            subcomment = SubComment.objects.create(
                    author=user,
                    post=request.POST['post'],
                    read=False,
                    sent=datetime.datetime.now(),
                    parent=comment,
                    )
            comment.subcomments.add(subcomment)

    return HttpResponseRedirect('/profile/'+other_user.userprofile.url)