当前位置: 首页>>代码示例>>Python>>正文


Python Comment.user方法代码示例

本文整理汇总了Python中django.contrib.comments.models.Comment.user方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.user方法的具体用法?Python Comment.user怎么用?Python Comment.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.comments.models.Comment的用法示例。


在下文中一共展示了Comment.user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
def post(request):
    """Returns a serialized object
    :param obj_id: ID of comment object
    :type obj_id: int
    :returns: json
    """
    guid = request.POST.get('guid', None)
    res = Result()   

    if guid:
        obj = getObjectsFromGuids([guid,])[0]
        c = Comment()
        c.comment = request.POST.get('comment', 'No comment')
        c.user = request.user
        c.user_name = request.user.get_full_name()
        c.user_email = request.user.email
        c.content_object = obj
        c.site_id = 1
        c.save()
        obj.comment_count = obj.comment_count + 1
        obj.save()

        __email(c, obj)

        res.append({'id': c.id, 'comment': c.comment})
        res.isSuccess = True
    else:
        res.isError = True
        res.message = "No guid provided"

    return JsonResponse(res)
开发者ID:davideilering,项目名称:Frog,代码行数:33,代码来源:comment.py

示例2: test_get_user_name_from_comment

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
 def test_get_user_name_from_comment(self):
     comment = Comment(user=None, user_name='')
     self.assertEqual(publicweb_filters.get_user_name_from_comment(comment), "An Anonymous Contributor")
     comment.user_name = "Harry"
     self.assertEqual(publicweb_filters.get_user_name_from_comment(comment), "Harry")
     user = UserFactory()
     comment.user = user
     self.assertEqual(publicweb_filters.get_user_name_from_comment(comment), user.username)
开发者ID:TristramNorman,项目名称:econsensus,代码行数:10,代码来源:templatetags_test.py

示例3: newComment

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
def newComment(model, request, comment):
    user = request.user
    c = Comment()
    
    c.user = user
    c.user_name = user.username
    c.user_email = user.email
    c.ip_address = request.META.get('REMOTE_ADDR')
    c.comment = comment
    
    # c.site = Site.objects.get(id=settings.SITE_ID)
    c.site_id = settings.SITE_ID
    
    c.content_type = ContentType.objects.get_for_model(model)
    c.object_pk = model.id
    
    c.save()
开发者ID:rdrsh,项目名称:logoclone,代码行数:19,代码来源:models.py

示例4: create_comment

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
def create_comment(oldcomment):
    current_site = Site.objects.get(id=settings.SITE_ID)
    content_type = ContentType.objects.get(app_label='blog', model='post')
    fields = oldcomment['fields']
    comment = Comment()
    comment.comment  = fields['comment']
    comment.ip_address  = fields['ip_address']
    comment.is_public  = fields['is_public']
    comment.is_removed  = fields['is_removed']
    comment.object_pk  = fields['object_pk']
    comment.submit_date  = fields['submit_date']
    comment.user  = None
    comment.user_email  = fields['user_email']
    comment.user_name  = fields['user_name']
    comment.user_url  = fields['user_url']
    comment.content_type  = content_type
    comment.site  = current_site
    comment.save()
开发者ID:miniatureape,项目名称:justindonato.com,代码行数:20,代码来源:transfer.py

示例5: test_members_with_comment_by_same_user

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
    def test_members_with_comment_by_same_user(self):
        user = random_user()
        idea = models.Idea(creator=user, title='Transit subsidy to Mars',
                    text='Aliens need assistance.', state=self.state)
        idea.save()

        commenter = user

        comment = Comment()
        comment.user = commenter
        comment.content_object = idea
        comment.comment = 'Test'
        comment.is_public = True
        comment.is_removed = False
        comment.site_id = 1
        comment.save()

        self.assertEqual(len(idea.members), 1)
        self.assertIn(user, idea.members)
开发者ID:Zorig,项目名称:idea-box,代码行数:21,代码来源:model_tests.py

示例6: process_comment

# 需要导入模块: from django.contrib.comments.models import Comment [as 别名]
# 或者: from django.contrib.comments.models.Comment import user [as 别名]
def process_comment(request, commentform, post):
    try:
        comment = Comment.objects.get(id=commentform.cleaned_data.get('id', None))
    except Comment.DoesNotExist:
        comment = Comment()
    comment.content_object = post
    comment.site = Site.objects.get_current()
    comment.user = request.user
    try:
        profile = UserProfile.objects.get(user = request.user)
        comment.user_url = profile.get_absolute_url()
    except UserProfile.DoesNotExist:
        pass
    comment.comment = strip_tags(commentform.cleaned_data['comment'])
    comment.submit_date = datetime.datetime.now()
    comment.ip_address = request.META['REMOTE_ADDR']
    comment.is_public = True
    comment.is_removed = False
    comment.save()
    return comment
开发者ID:calvin,项目名称:seabirds.net,代码行数:22,代码来源:views.py


注:本文中的django.contrib.comments.models.Comment.user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。