• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Comment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_parse_comments

    def test_parse_comments(self):

        response = '''{"response":[6,
            {"cid":2505,"uid":16271479,"date":1298365200,"text":"Добрый день , кароче такая идея когда опросы создаешь вместо статуса - можно выбрать аудитории опрашиваемых, например только женский или мужской пол могут участвовать (то бишь голосовать в опросе)."},
            {"cid":2507,"uid":16271479,"date":1286105582,"text":"Это уже не практично, имхо.<br>Для этого делайте группу и там опрос, а в группу принимайте тех, кого нужно.","reply_to_uid":16271479,"reply_to_cid":2505},
            {"cid":2547,"uid":2943,"date":1286218080,"text":"Он будет только для групп благотворительных организаций."}]}
            '''
        group = GroupFactory.create(remote_id=OWNER_ID)
        post = PostFactory.create(remote_id=TR_POST_ID, wall_owner=group)
        instance = CommentFactory.create(post=post)
        author = UserFactory.create(remote_id=16271479)
        instance.parse(json.loads(response)['response'][1])
        instance.save()

        self.assertEqual(instance.remote_id, '201164356_2505')
        self.assertEqual(instance.text, u'Добрый день , кароче такая идея когда опросы создаешь вместо статуса - можно выбрать аудитории опрашиваемых, например только женский или мужской пол могут участвовать (то бишь голосовать в опросе).')
        self.assertEqual(instance.author, author)
        self.assertTrue(isinstance(instance.date, datetime))

        instance = Comment(post=post)
        instance.parse(json.loads(response)['response'][2])
        instance.save()

        self.assertEqual(instance.remote_id, '201164356_2507')
        self.assertEqual(instance.reply_for.remote_id, 16271479)
开发者ID:rkmarvin,项目名称:django-vkontakte-wall,代码行数:25,代码来源:tests.py


示例2: get

    def get(self):
        # see if there is a key
        comment = None
        status = None
        try:
            comment = Comment.get( self.request.get('key') )
            status = self.request.get('status')
        except db.BadKeyError:
            pass

        if comment is None:
            # show all the 'new' comments
            comments = Comment.all().filter('status =', 'new').order('inserted').fetch(page_count+1)
            more = True if len(comments) > page_count else False
            comments = comments[:page_count]
            vals = {
                'comments' : comments,
                'more'     : more,
                }
            self.template( 'comment-list.html', vals, 'admin' )
        else:
            comment.status = status_map[status]
            comment.put()
            comment.node.regenerate()
            self.redirect('./')
            return
开发者ID:ranginui,项目名称:kohacon,代码行数:26,代码来源:comment.py


示例3: api_create_comment

def api_create_comment(id):
    cookie_str = request.cookies.get(COOKIE_NAME)
    user = {}
    if cookie_str:
        user = cookie2user(cookie_str)
    if user is None:
        r=jsonify({'error':'Please signin first'})
        r.content_type = 'application/json'
        return r
    if not request.json['content'] or not request.json['content'].strip():
        r=jsonify({'error':'no content'})
        r.content_type = 'application/json'
        return r
    blog = Blog.query.filter(Blog.id==id).first()
    reprint = Reprint.query.filter(Reprint.id==id).first()
    b_id = ''
    if blog is not None:
        b_id = blog.id
    if reprint is not None:
        b_id = reprint.id
    if not b_id:
        r = jsonify({'error':'no blog'})
        r.content_type = 'application/json'
        return r
    comment = Comment(blog_id=b_id, user_id=user.id, user_name=user.name, user_image=user.image, content=request.json['content'].strip())
    db.session.add(comment)
    db.session.commit()
    a = comment.to_dict()
    r = jsonify(a)
    r.content_type = 'application/json;charset=utf-8'
    return r
开发者ID:sixiaobai,项目名称:awesome_webapp_flask,代码行数:31,代码来源:views.py


示例4: _post_comment

    def _post_comment(self, index_url, comment_str, auther_ip, user):
        title=urlparse(index_url).netloc
        
        print comment_str, user
        logger.debug('Auther_ip:' + auther_ip
                     + ' User:' + str(user)
                     + ' Title:' + title
                     + ' Index_url:' + index_url
                     + ' Comment_str:' + comment_str)

        comment_board, created = CommentBoard.objects.get_or_create(
                                    url=index_url,
                                    title=urlparse(index_url).netloc)
        comment_board.save() if created else None
        if user.is_authenticated():
            comment = Comment(
                    time_added=datetime.datetime.utcnow().replace(
                                    tzinfo=utc),
                    comment_str=comment_str,
                    comment_board=comment_board,
                    auther_ip=auther_ip,
                    user=user) # 以后换成auther,现在先用user
        else:
            '''
            Annoymous User access the site.
            '''
            comment = Comment(
                    time_added=datetime.datetime.utcnow().replace(
                                    tzinfo=utc),
                    comment_str=comment_str,
                    comment_board=comment_board,
                    auther_ip=auther_ip)
        comment.save()
开发者ID:geekben,项目名称:vine,代码行数:33,代码来源:views.py


示例5: post

  def post(self, post_id):
    session = get_current_session()
    if session.has_key('user'):
      message = helper.sanitizeHtml(self.request.get('message'))
      user = session['user']
      key = self.request.get('comment_key')
      if len(message) > 0 and key == keys.comment_key:
        try:
          post = Post.all().filter('nice_url =', helper.parse_post_id( post_id ) ).get()
          if post  == None: #If for some reason the post doesn't have a nice url, we try the id. This is also the case of all old stories
            post = db.get( helper.parse_post_id( post_id ) ) 

          post.remove_from_memcache()
          comment = Comment(message=message,user=user,post=post)
          comment.put()
          helper.killmetrics("Comment","Root", "posted", session, "",self)
          vote = Vote(user=user, comment=comment, target_user=user)
          vote.put()
          Notification.create_notification_for_comment_and_user(comment,post.user)
          self.redirect('/noticia/' + post_id)
        except db.BadKeyError:
          self.redirect('/')
      else:
        self.redirect('/noticia/' + post_id)
    else:
      self.redirect('/login')
开发者ID:grillermo,项目名称:Noticias-HAcker,代码行数:26,代码来源:PostHandler.py


示例6: submit_comment_view

def submit_comment_view(request):
    try:
        if request.method == 'GET':
            paper_id = int(request.GET['id'])
        elif request.method == 'POST':
            paper_id = int(request.POST['id'])
        paper = Paper.objects.filter(id=paper_id).get()
        comment = Comment()
        comment.paper = paper
        comment.user = request.user
        if request.method == 'POST':
            form = forms.SubmitCommentForm(request.POST, instance=comment)
            if form.is_valid():
                form.save(paper)
                return HttpResponseRedirect("paper?id=%d" % paper_id)
        else:
            form = forms.SubmitCommentForm()
    except (ValueError, KeyError, Paper.DoesNotExist):
        paper = None
        form = None

    return render_to_response("submit_comment.html", RequestContext(request, {
        'form' : form,
        'paper' : paper,
    }))
开发者ID:labdalla,项目名称:jeeves,代码行数:25,代码来源:views.py


示例7: review_comment

def review_comment():
    commid = request.json['commid']
    review = request.json['review']
    user = User.current()
    if not user.anonymous:
        Comment.approve(commid, review, user)
    return jsonify(success=True)
开发者ID:misterious-mister-x,项目名称:adverb-front,代码行数:7,代码来源:entry.py


示例8: get

 def get(self):
     post_id = int(self.request.get('id'))
     post = Post.get_by_id(post_id)
     post.comment += 1
     post.put()
     comment = Comment(post=post.key, content=self.request.get("content"))
     comment.put()
开发者ID:crumpledpaper,项目名称:singgest,代码行数:7,代码来源:main.py


示例9: test_parse_comment

    def test_parse_comment(self):

        response = u'''{"attrs": {"flags": "l,s"},
            "author_id": "538901295641",
            "date": "2014-04-11 12:53:02",
            "id": "MTM5NzIwNjM4MjQ3MTotMTU5NDE6MTM5NzIwNjM4MjQ3MTo2MjUwMzkyOTY2MjMyMDox",
            "like_count": 123,
            "liked_it": false,
            "reply_to_comment_id": "MTM5NzIwNjMzNjI2MTotODE0MzoxMzk3MjA2MzM2MjYxOjYyNTAzOTI5NjYyMzIwOjE=",
            "reply_to_id": "134519031824",
            "text": "наверное и я так буду делать!",
            "type": "ACTIVE_MESSAGE"}'''
        comment = CommentFactory(id='MTM5NzIwNjMzNjI2MTotODE0MzoxMzk3MjA2MzM2MjYxOjYyNTAzOTI5NjYyMzIwOjE=')
        author = UserFactory(id=134519031824)
        discussion = DiscussionFactory()
        instance = Comment(discussion=discussion)
        instance.parse(json.loads(response))
        instance.save()

        self.assertEqual(instance.id, 'MTM5NzIwNjM4MjQ3MTotMTU5NDE6MTM5NzIwNjM4MjQ3MTo2MjUwMzkyOTY2MjMyMDox')
        self.assertEqual(instance.object_type, 'ACTIVE_MESSAGE')
        self.assertEqual(instance.text, u"наверное и я так буду делать!")
        self.assertEqual(instance.likes_count, 123)
        self.assertEqual(instance.liked_it, False)
        self.assertEqual(instance.author, User.objects.get(pk=538901295641))
        self.assertEqual(instance.reply_to_comment, comment)
        self.assertEqual(instance.reply_to_author, User.objects.get(pk=134519031824))
        self.assertTrue(isinstance(instance.date, datetime))
        self.assertTrue(isinstance(instance.attrs, dict))
开发者ID:Romeno,项目名称:django-odnoklassniki-discussions,代码行数:29,代码来源:tests.py


示例10: post

 def post(self):
     photo_id = int(self.request.get('pid'))
     Author = self.request.get('comment-name')
     comment = self.request.get('comment')
     photo = Image.get_Detail(photo_id)
     logging.error("Author is" + Author)
     logging.error(comment)
     if Author == '' or comment == '':
         pic_id = "/Home#" + str(photo_id)
         self.redirect(pic_id)
     else:
         if photo:
             try:
                 comment = Comment(
                     Author=Author,
                     Comment=comment, Image=photo.key)
                 comment.put()
                 logging.info("Horray, a comment is saved.")
             except:
                 logging.error("Error saving comment in datastore.")
             finally:
                 pic_id = "/Home#" + str(photo_id)
                 render = template.render('templates/redirect.html',
                                          {'link': pic_id, 'message': 'Commented'})
                 self.response.write(render)
开发者ID:AnikChat,项目名称:EngineApp,代码行数:25,代码来源:views.py


示例11: add_comment

def add_comment(request, movie_id):
    newcomment = Comment(text=request.POST['comment_text'], movie=Movie.objects.filter(id=movie_id)[0])        
    newcomment.save()
    comments = Comment.objects.filter(movie=movie_id)
    movie = Movie.objects.filter(id=movie_id)[0]
    context = {'comments':comments,'movie':movie}
    return render(request, 'movies/movie.html', context)
开发者ID:nadeen12-meet,项目名称:MEET-YL2,代码行数:7,代码来源:views.py


示例12: product_page

def product_page(request, product_id):
    product = Product.objects.get(pk=product_id)
    product = get_object_or_404(Product, pk=product_id)

    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            author_name = form.cleaned_data.get("author_name") or u"Гость"
            body = form.cleaned_data.get("body")
            c = Comment(author_name=author_name,
                        body=body,
                        product=product)
            c.save()
            return HttpResponseRedirect('/product/' + product_id)
    else:
        form = CommentForm()

    categories = get_categories()
    comments = product.comment_set.all().order_by('-date')[:10]
    bread_categories = [MainMock()] + product.category.get_path_up()
    print(bread_categories)

    context_dict = dict(product=product,
                        categories=categories,
                        comments=comments,
                        form=form,
                        cart=get_cart(request),
                        bread_categories=bread_categories,
                        )

    return render(request, 'store/product.html', context_dict)
开发者ID:Riliam,项目名称:test-shop,代码行数:31,代码来源:views.py


示例13: add_comment

def add_comment(post_id):
    comment = Comment(request.form['text'])
    comment.author_id = current_user().id
    comment.post_id = post_id
    db.session.add(comment)
    db.session.commit()
    return redirect('/post/' + str(post_id))
开发者ID:adicu,项目名称:intro-webapps,代码行数:7,代码来源:routes.py


示例14: newcomment

def newcomment(request, blog_id):
    if request.user.is_authenticated():
        comment = Comment(comment=request.POST.get('comment'), blog=Blog(pk=blog_id) )
        comment.save()
        return HttpResponseRedirect(reverse('Blog:main'))
    else:
        return HttpResponse("You are not logged in.")
开发者ID:hossamsalah,项目名称:django-Blog,代码行数:7,代码来源:views.py


示例15: post_comment

def post_comment(request):

    user = request.POST.get('user')
    content = request.POST.get('content')
    email = request.POST.get('email')
    blog_id = request.POST.get('blog_id')
    quote = request.POST.get("quote", "").split("###")

    #过滤content里面的JS字符
    content = content.replace("<", "&lt;").replace(">", "&gt; ")

    blog = get_object_or_404(Article, pk=blog_id)
    if len(quote) == 3 and \
        Comment.objects.filter(pk=quote[2]):
        content = u"""
        <p>
        引用来自<code>%s楼-%s</code>的发言
        </p>""" % (quote[0], quote[1]) + content

    comment = Comment(
        article=blog,
        email=email,
        name=user, 
        content=content)
    comment.save()

    return HttpResponse("%d" % comment.id)
开发者ID:umelly,项目名称:sina_young_blog,代码行数:27,代码来源:views.py


示例16: createComment

    def createComment(self, request):
        """Create new Comment object, returning CommentForm/request."""
        
        author = self._getAuthorFromUser()
        data['authorName'] = author.displayName
        data['authorID'] = author.authorID

        self._checkComment(request)

        data = {'comment': request.comment}

        # get the article key for where the comment will be added
        article_key = self._checkKey(request.websafeArticleKey, 'Article')

        comment_id = Comment.allocate_ids(size=1, parent=article_key)[0]
        comment_key = ndb.Key(Comment, comment_id, parent=article_key)
        data['key'] = comment_key

        # create Comment
        comment_key = Comment(**data).put()

        # send alerts to all authors of Article and all other comments
        #taskqueue.add(params={'email': author.mainEmail,
        #    'CommentInfo': repr(request)},
        #    url='/tasks/send_comment_alert'
        #)

        return self._copyCommentToForm(comment_key.get(), article_key=article_key, author=author)
开发者ID:dansalmo,项目名称:new-aca,代码行数:28,代码来源:aca.py


示例17: get

 def get(self):
     params = self.request.url_params
     print params
     category = params[0]
     which = params[1]
     article, comment, comments, user = None, None, None, None
     if category == 'article':
         # delete article and all related comments
         old_article = Article.select_one('created_at=?', which)
         article = old_article
         old_article.delete()
         old_comments = Comment.select_all('article_id=?', article.id)
         comments = old_comments
         if old_comments:
             for comment in old_comments:
                 comment.delete()
     elif category == 'user':
         old_user = User.select_one('id=?', which)
         user = old_user
         old_user.delete()
     elif category == 'comment':
         old_comment = Comment.select_one('id=?', which)
         comment = old_comment
         old_comment.delete()
     return self.render('_delete.html', article=article, comment=comment, \
             comments=comments, user=user)
开发者ID:damnever,项目名称:LTsite,代码行数:26,代码来源:urls.py


示例18: teamProfile

def teamProfile(teamId):
	if current_user.team:
		if int(teamId) == int(current_user.team_id):
			return redirect(url_for('team_page'))
	form = CommentForm()
	team = db.session.query(Team).filter(Team.id == teamId).first()
	comments = db.session.query(Comment).filter(Comment.idea_id == team.idea.id).all()

	if not team:
		flash('Team '+teamId+' not found.', 'error')
		return redirect(url_for('home'))
	else:
		if form.validate_on_submit():
			comment = Comment()
			comment.content = form.comment.data
			team.idea.comment.append(comment)
			current_user.comment.append(comment)
			db.session.add(comment)

			for member in comment.idea.team.members:
				notif = PersonalNotification()
				notif.content = current_user.username + " commented on your team's idea."
				member.notification.append(notif)

			db.session.commit()
			return render_template('team_view.html', form=form, team=team, comments=comments)

		return render_template('team_view.html', form=form, team=team, comments=comments)
开发者ID:berc-web,项目名称:berc_web,代码行数:28,代码来源:__init__.py


示例19: test_comment_approved

 def test_comment_approved(self):
     post = Post(author=self.me, title="Hi", created_date=timezone.now())
     post.save()
     comment = Comment(author=self.me.username, post=post)
     comment.approve()
     comment.save()
     assert comment in post.approved_comments()
开发者ID:bananayana,项目名称:blog-igi,代码行数:7,代码来源:tests.py


示例20: post_comment

def post_comment(text, author, suggestion):
	brtext = text.replace('\n', '<br/>')
	comment = Comment(text=brtext, author=author, suggestion=suggestion)
	comment.put()
	author.lastposted = date.today()
	author.put()
	notify_comment(text, comment)
开发者ID:paulsc,项目名称:lunchdiscussion,代码行数:7,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Company类代码示例发布时间:2022-05-27
下一篇:
Python models.Client类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap