

@contextfunction
def comments_likes(context, object, expand=True):
    'Comments and Likes/Dislikes box for an object'
    request = context['request']
    response_format = 'html'
    if ('response_format' in context):
        response_format = context['response_format']
    update = isinstance(object, UpdateRecord)
    profile = request.user.profile
    if (request.POST.get('like', 0) == unicode(object.id)):
        object.likes.add(profile)
        if hasattr(object, 'score'):
            object.score += 1
            object.save()
    elif (request.POST.get('unlike', 0) == unicode(object.id)):
        object.likes.remove(profile)
        if hasattr(object, 'score'):
            object.score -= 1
            object.save()
    elif (request.POST.get('dislike', 0) == unicode(object.id)):
        object.dislikes.add(profile)
        if hasattr(object, 'score'):
            object.score += 1
            object.save()
    elif (request.POST.get('undislike', 0) == unicode(object.id)):
        object.dislikes.remove(expand)
        if hasattr(object, 'score'):
            object.score -= 1
            object.save()
    elif ((request.POST.get('commentobject', 0) == unicode(object.id)) and ('comment' in request.POST)):
        comment = Comment(author=profile, body=request.POST.get('comment'))
        comment.save()
        if hasattr(object, 'score'):
            object.score += 1
            object.save()
        object.comments.add(comment)
    likes = object.likes.all()
    dislikes = object.dislikes.all()
    comments = object.comments.all()
    ilike = (profile in likes)
    idislike = (profile in dislikes)
    icommented = (comments.filter(author=profile).exists() or comments.filter(author__default_group__in=([profile.default_group_id] + [i.id for i in profile.other_groups.all().only('id')])).exists())
    return Markup(render_to_string('core/tags/comments_likes', {
        'object': object,
        'is_update': update,
        'profile': profile,
        'likes': likes,
        'dislikes': dislikes,
        'comments': comments,
        'ilike': ilike,
        'idislike': idislike,
        'icommented': icommented,
        'expand': expand,
    }, context_instance=RequestContext(request), response_format=response_format))

dataset/ETHPy150Open treeio/treeio/treeio/core/templatetags/object.py comments_likes/VarMisuse@263/334 `profile`->`expand`