コード例 #1
0
ファイル: views.py プロジェクト: genghisu/eruditio
def list(request, content_type, object_id, comment_class = 'standard'):
    """
    Renders a list of comments associated with a target object.
    
    @param content_type - content type of object which comment belongs to.
    @param object_id - id of parent object.
    @param comment_class - used in template for layout and css purposes.
    """
    option = request_helpers.get_sort(request, 'most_recent')
    content_type_object = ContentType.objects.get(id = content_type)
    node = content_type_object.model_class().objects.get(id = object_id)
    all_comments = models.Comment.objects.comments_for_object(node)
    model_name = content_type_object.model
    
    return shortcuts.render_to_response('django_comments/standard_comment_list.html',   
                                            {'comment_target_node':node,
                                             'comments':all_comments,
                                             'comment_target_model':model_name,
                                             'comment_class':comment_class},  
                                             context_instance = RequestContext(request)
                                        )