Lets you vote for a comment (Requires login).

        Parameters:
            comment_id (int):
            score (str): Can be: up, down.
550264
def comment_vote(self, comment_id, score):
        
        params = {'score': score}
        return self._get('comments/{0}/votes.json'.format(comment_id), params,
                         method='POST', auth=True)
155741
def use_comparative_comment_view(self):
        """"""
        self._object_views['comment'] = COMPARATIVE
        # self._get_provider_session('comment_lookup_session') # To make sure the session is tracked
        for session in self._get_provider_sessions():
            try:
                session.use_comparative_comment_view()
            except AttributeError:
                pass
1149564
def add(self, score, user, ip_address, cookies={}, commit=True):
        """"""
        try:
            score = int(score)
        except (ValueError, TypeError):
            raise InvalidRating("%s is not a valid choice for %s" % (score, self.field.name))
        
        delete = (score == 0)
        if delete and not self.field.allow_delete:
            raise CannotDeleteVote("you are not allowed to delete votes for %s" % (self.field.name,))
            # ... you're also can't delete your vote if you haven't permissions to change it. I leave this case for CannotChangeVote
        
        if score < 0 or score > self.field.range:
            raise InvalidRating("%s is not a valid choice for %s" % (score, self.field.name))

        is_anonymous = (user is None or not user.is_authenticated())
        if is_anonymous and not self.field.allow_anonymous:
            raise AuthRequired("user must be a user, not '%r'" % (user,))
        
        if is_anonymous:
            user = None
        
        defaults = dict(
            score = score,
            ip_address = ip_address,
        )
        
        kwargs = dict(
            content_type    = self.get_content_type(),
            object_id       = self.instance.pk,
            key             = self.field.key,
            user            = user,
        )
        if not user:
            kwargs['ip_address'] = ip_address
        
        use_cookies = (self.field.allow_anonymous and self.field.use_cookies)
        if use_cookies:
            defaults['cookie'] = now().strftime('%Y%m%d%H%M%S%f') # -> md5_hexdigest?
            # TODO: move 'vote-%d.%d.%s' to settings or something
            cookie_name = 'vote-%d.%d.%s' % (kwargs['content_type'].pk, kwargs['object_id'], kwargs['key'][:6],) # -> md5_hexdigest?
            cookie = cookies.get(cookie_name) # try to get existent cookie value
            if not cookie:
                kwargs['cookie__isnull'] = True
            kwargs['cookie'] = cookie

        try:
            rating, created = Vote.objects.get(**kwargs), False
        except Vote.DoesNotExist:
            if delete:
                raise CannotDeleteVote("attempt to find and delete your vote for %s is failed" % (self.field.name,))
            if getattr(settings, 'RATINGS_VOTES_PER_IP', RATINGS_VOTES_PER_IP):
                num_votes = Vote.objects.filter(
                    content_type=kwargs['content_type'],
                    object_id=kwargs['object_id'],
                    key=kwargs['key'],
                    ip_address=ip_address,
                ).count()
                if num_votes >= getattr(settings, 'RATINGS_VOTES_PER_IP', RATINGS_VOTES_PER_IP):
                    raise IPLimitReached()
            kwargs.update(defaults)
            if use_cookies:
                # record with specified cookie was not found ...
                cookie = defaults['cookie'] # ... thus we need to replace old cookie (if presented) with new one
                kwargs.pop('cookie__isnull', '') # ... and remove 'cookie__isnull' (if presented) from .create()'s **kwargs
            rating, created = Vote.objects.create(**kwargs), True
            
        has_changed = False
        if not created:
            if self.field.can_change_vote:
                has_changed = True
                self.score -= rating.score
                # you can delete your vote only if you have permission to change your vote
                if not delete:
                    rating.score = score
                    rating.save()
                else:
                    self.votes -= 1
                    rating.delete()
            else:
                raise CannotChangeVote()
        else:
            has_changed = True
            self.votes += 1
        if has_changed:
            if not delete:
                self.score += rating.score
            if commit:
                self.instance.save()
            #setattr(self.instance, self.field.name, Rating(score=self.score, votes=self.votes))
            
            defaults = dict(
                score   = self.score,
                votes   = self.votes,
            )
            
            kwargs = dict(
                content_type    = self.get_content_type(),
                object_id       = self.instance.pk,
                key             = self.field.key,
            )
            
            try:
                score, created = Score.objects.get(**kwargs), False
            except Score.DoesNotExist:
                kwargs.update(defaults)
                score, created = Score.objects.create(**kwargs), True
            
            if not created:
                score.__dict__.update(defaults)
                score.save()
        
        # return value
        adds = {}
        if use_cookies:
            adds['cookie_name'] = cookie_name
            adds['cookie'] = cookie
        if delete:
            adds['deleted'] = True
        return adds
644979
def post_comment(self, bugid, comment):
        ''''''
        data = {'id': bugid, "comment": comment}
        return self._post('bug/{bugid}/comment'.format(bugid=bugid), json.dumps(data))
52631
def request_comment_show(self, request_id, id, **kwargs):
        ""
        api_path = "/api/v2/requests/{request_id}/comments/{id}.json"
        api_path = api_path.format(request_id=request_id, id=id)
        return self.call(api_path, **kwargs)
1330483
def help_center_user_votes(self, user_id, **kwargs):
        ""
        api_path = "/api/v2/help_center/users/{user_id}/votes.json"
        api_path = api_path.format(user_id=user_id)
        return self.call(api_path, **kwargs)
257837
def get_comment(self, id):
        
        assert isinstance(id, (int, long)), id
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/comments/" + str(id)
        )
        return github.GistComment.GistComment(self._requester, headers, data, completed=True)
280665
def cli(ctx, id_number, new_value, metadata=""):
    
    return ctx.gi.cannedcomments.update_comment(id_number, new_value, metadata=metadata)
1337257
def help_center_article_comment_down_create(self, article_id, id, data, **kwargs):
        ""
        api_path = "/api/v2/help_center/articles/{article_id}/comments/{id}/down.json"
        api_path = api_path.format(article_id=article_id, id=id)
        return self.call(api_path, method="POST", data=data, **kwargs)
966094
def upvote
      begin
        client.post("/cards/#{id}/membersVoted", {
          value: me.id
        })
      rescue Trello::Error => e
        fail e unless e.message =~ /has already voted/i
      end

      self
    end
907736
def add_comment(self, comment):
        
        if not comment:
            return

        self.__comments[comment.name] = comment
        self.comment_added_signal(self, comment)
743264
def deleteComment(self, commentId):
        
        url = "%s/comments/%s/delete" % (self.root, commentId)
        params = {
            "f": "json",
        }
        return self._post(url,
                             params,
                             securityHandler=self._securityHandler,
                             proxy_port=self._proxy_port,
                             proxy_url=self._proxy_url)
1272448
def _get_comments(session, group_or_user_id, wall_id):
        
        return session.fetch_items("wall.getComments", Comment.from_json, count=100, owner_id=group_or_user_id, post_id=wall_id, need_likes=1)
475932
def comments(recid):
    """"""
    from invenio_access.local_config import VIEWRESTRCOLL
    from invenio_access.mailcookie import \
        mail_cookie_create_authorize_action
    from .api import check_user_can_view_comments
    auth_code, auth_msg = check_user_can_view_comments(current_user, recid)
    if auth_code and current_user.is_guest:
        cookie = mail_cookie_create_authorize_action(VIEWRESTRCOLL, {
            'collection': g.collection})
        url_args = {'action': cookie, 'ln': g.ln, 'referer': request.referrer}
        flash(_("Authorization failure"), 'error')
        return redirect(url_for('webaccount.login', **url_args))
    elif auth_code:
        flash(auth_msg, 'error')
        abort(401)

    # FIXME check restricted discussion
    comments = CmtRECORDCOMMENT.query.filter(db.and_(
        CmtRECORDCOMMENT.id_bibrec == recid,
        CmtRECORDCOMMENT.in_reply_to_id_cmtRECORDCOMMENT == 0,
        CmtRECORDCOMMENT.star_score == 0
    )).order_by(CmtRECORDCOMMENT.date_creation).all()
    return render_template('comments/comments.html', comments=comments,
                           option='comments')
221082
def addcomment(self, creditmemo_increment_id,
            comment, email=True, include_in_email=False):
        
        return bool(
            self.call(
                'sales_order_creditmemo.addComment',
                [creditmemo_increment_id, comment, email, include_in_email]
            )
        )
900363
def itemComment(self, commentId):
        
        url = "%s/comments/%s" % (self.root, commentId)
        params = {
            "f": "json"
        }
        return self._get(url,
                            params,
                            securityHandler=self._securityHandler,
                            proxy_port=self._proxy_port,
                             proxy_url=self._proxy_url)
590956
def from_id(reddit_session, subreddit_id):
        """"""
        pseudo_data = {'id': subreddit_id,
                       'permalink': '/comments/{0}'.format(subreddit_id)}
        return Submission(reddit_session, pseudo_data)