Check if comments are moderated for the instance
199203
def get_comments_are_moderated(instance):
    
    if not IS_INSTALLED:
        return False

    try:
        # Get the moderator which is installed for this model.
        mod = moderator._registry[instance.__class__]
    except KeyError:
        # No moderator = no moderation
        return False

    # Check the 'auto_moderate_field', 'moderate_after',
    # by reusing the basic Django policies.
    return CommentModerator.moderate(mod, None, instance, None)
1191845
private void checkJsDocInBlockComments(String fileName) {
    if (!compiler.getOptions().preservesDetailedSourceInfo()) {
      // Comments only available if preservesDetailedSourceInfo is true.
      return;
    }

    for (Comment comment : compiler.getComments(fileName)) {
      if (comment.type == Comment.Type.BLOCK) {
        if (COMMENT_PATTERN.matcher(comment.value).find()) {
          compiler.report(
              JSError.make(
                  fileName,
                  comment.location.start.line + 1,
                  comment.location.start.column,
                  JSDOC_IN_BLOCK_COMMENT));
        }
      }
    }
  }
747848
def clean(self, *args, **kwargs):
        
        # check done only for new nodes!
        if not self.pk:
            node = self.node
            # ensure comments for this node are allowed
            if node.participation_settings.comments_allowed is False:
                raise ValidationError("Comments not allowed for this node")
            # ensure comments for this layer are allowed
            if 'nodeshot.core.layers' in settings.INSTALLED_APPS:
                layer = node.layer
                if layer.participation_settings.comments_allowed is False:
                    raise ValidationError("Comments not allowed for this layer")
257295
def isComment(self, block, column):
        
        dataObject = block.userData()
        data = dataObject.data if dataObject is not None else None
        return self._syntax.isComment(data, column)
205485
def get_cached_moderated_reddits(self):
        
        if self._mod_subs is None:
            self._mod_subs = {'mod': self.reddit_session.get_subreddit('mod')}
            for sub in self.reddit_session.get_my_moderation(limit=None):
                self._mod_subs[six.text_type(sub).lower()] = sub
        return self._mod_subs
888115
def _is_really_comment(tokens, index):
    """"""
    if tokens[index].type == TokenType.Comment:
        return True

    # Really a comment in disguise!
    try:
        if tokens[index].content.lstrip()[0] == "#":
            return True
    except IndexError:
        return False
1162015
def load_default_moderator():
    
    if appsettings.FLUENT_COMMENTS_DEFAULT_MODERATOR == 'default':
        # Perform spam checks
        return moderation.FluentCommentsModerator(None)
    elif appsettings.FLUENT_COMMENTS_DEFAULT_MODERATOR == 'deny':
        # Deny all comments not from known registered models.
        return moderation.AlwaysDeny(None)
    elif str(appsettings.FLUENT_COMMENTS_DEFAULT_MODERATOR).lower() == 'none':
        # Disables default moderator
        return moderation.NullModerator(None)
    elif '.' in appsettings.FLUENT_COMMENTS_DEFAULT_MODERATOR:
        return import_string(appsettings.FLUENT_COMMENTS_DEFAULT_MODERATOR)(None)
    else:
        raise ImproperlyConfigured(
            "Bad FLUENT_COMMENTS_DEFAULT_MODERATOR value. Provide default/deny/none or a dotted path"
        )
87836
private boolean gatherComments(org.parboiled.Node<Node> parsed) {
		boolean foundComments = false;
		for (org.parboiled.Node<Node> child : parsed.getChildren()) {
			foundComments |= gatherComments(child);
		}
		
		List<Comment> cmts = registeredComments.get(parsed);
		if (cmts != null) for (Comment c : cmts) {
			comments.add(c);
			return true;
		}
		
		return foundComments;
	}
141754
def allow(self, comment, content_object, request):
        """"""
        # Tests for cookie:
        if settings.COOKIE_KEY not in request.COOKIES \
            and (settings.DISCARD_SPAM or settings.DISCARD_NO_COOKIE):
                return False
        elif settings.COOKIE_KEY not in request.COOKIES:
            comment.is_removed = True
            comment.is_public = False
            return True
        return True
1083024
def comment_count(self):
        
        # Get the comment model.
        comment_model = comments.get_model()

        modelbase_content_type = ContentType.objects.get(app_label="panya", model="modelbase")

        # Create a qs filtered for the ModelBase or content_type objects.
        qs = comment_model.objects.filter(
            content_type__in = [self.content_type, modelbase_content_type],
            object_pk    = smart_unicode(self.pk),
            site__pk     = settings.SITE_ID,
        )

        # The is_public and is_removed fields are implementation details of the
        # built-in comment model's spam filtering system, so they might not
        # be present on a custom comment model subclass. If they exist, we
        # should filter on them.
        field_names = [f.name for f in comment_model._meta.fields]
        if 'is_public' in field_names:
            qs = qs.filter(is_public=True)
        if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names:
            qs = qs.filter(is_removed=False)

        # Return ammount of items in qs.
        return qs.count()
969314
function hasCommentBefore(node, sourceCode) {
  return sourceCode.getCommentsBefore(node)
    .some(comment => comment.loc.end.line >= node.loc.start.line - 1)
}
1344270
def notify_admin_of_new_comment(comID):
    
    comment = query_get_comment(comID)
    if len(comment) > 0:
        (comID2,
         id_bibrec,
         id_user,
         body,
         date_creation,
         star_score, nb_votes_yes, nb_votes_total,
         title,
         nb_abuse_reports, round_name, restriction) = comment
    else:
        return
    user_info = query_get_user_contact_info(id_user)
    if len(user_info) > 0:
        (nickname, email, last_login) = user_info
        if not len(nickname) > 0:
            nickname = email.split('@')[0]
    else:
        nickname = email = "ERROR: Could not retrieve"

    review_stuff = '''
    Star score  = %s
    Title       = %s''' % (star_score, title)

    washer = EmailWasher()
    try:
        body = washer.wash(body)
    except:
        body = cgi.escape(body)

    record_info = webcomment_templates.tmpl_email_new_comment_admin(id_bibrec)
    out = '''
The following %(comment_or_review)s has just been posted (%(date)s).

AUTHOR:
    Nickname    = %(nickname)s
    Email       = %(email)s
    User ID     = %(uid)s

RECORD CONCERNED:
    Record ID   = %(recID)s
    URL         = <%(siteurl)s/%(CFG_SITE_RECORD)s/%(recID)s/%(comments_or_reviews)s/>
%(record_details)s

%(comment_or_review_caps)s:
    %(comment_or_review)s ID    = %(comID)s %(review_stuff)s
    Body        =
<--------------->
%(body)s

<--------------->
ADMIN OPTIONS:
To moderate the %(comment_or_review)s go to %(siteurl)s/%(CFG_SITE_RECORD)s/%(recID)s/%(comments_or_reviews)s/display?%(arguments)s
    ''' % \
        {'comment_or_review': star_score > 0 and 'review' or 'comment',
            'comment_or_review_caps': star_score > 0 and 'REVIEW' or 'COMMENT',
            'comments_or_reviews': star_score > 0 and 'reviews' or 'comments',
            'date': date_creation,
            'nickname': nickname,
            'email': email,
            'uid': id_user,
            'recID': id_bibrec,
            'record_details': record_info,
            'comID': comID2,
            'review_stuff': star_score > 0 and review_stuff or "",
            'body': body.replace('<br />', '\n'),
            'siteurl': CFG_SITE_URL,
            'CFG_SITE_RECORD': CFG_SITE_RECORD,
            'arguments': 'ln=en&do=od#%s' % comID
         }

    from_addr = '%s WebComment <%s>' % (
        CFG_SITE_NAME, CFG_WEBALERT_ALERT_ENGINE_EMAIL)
    comment_collection = get_comment_collection(comID)
    to_addrs = get_collection_moderators(comment_collection)

    rec_collection = guess_primary_collection_of_a_record(id_bibrec)
    report_nums = get_fieldvalues(id_bibrec, "037__a")
    report_nums += get_fieldvalues(id_bibrec, "088__a")
    report_nums = ', '.join(report_nums)
    subject = "A new comment/review has just been posted [%s|%s]" % (
        rec_collection, report_nums)

    send_email(from_addr, to_addrs, subject, out)
496998
private function check_permissions() {
        $this->postcap = has_capability('moodle/comment:post', $this->context);
        $this->viewcap = has_capability('moodle/comment:view', $this->context);
        if (!empty($this->plugintype)) {
            $permissions = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'permissions', array($this->comment_param), array('post'=>false, 'view'=>false));
            $this->postcap = $this->postcap && $permissions['post'];
            $this->viewcap = $this->viewcap && $permissions['view'];
        }
    }
917918
def count_discussions_handler(sender, **kwargs):
    
    if kwargs.get('instance') and kwargs.get('created'):
        # The signal is emitted by the comment creation,
        # so we do nothing, comment_was_posted is used instead.
        return

    comment = 'comment' in kwargs and kwargs['comment'] or kwargs['instance']
    entry = comment.content_object

    if isinstance(entry, Entry):
        entry.comment_count = entry.comments.count()
        entry.pingback_count = entry.pingbacks.count()
        entry.trackback_count = entry.trackbacks.count()
        entry.save(update_fields=[
            'comment_count', 'pingback_count', 'trackback_count'])
255917
function createCommentDiv(comment) {
    if (!comment.displayed && !opts.moderator) {
      return $('<div class="moderate">Thank you!  Your comment will show up '
               + 'once it is has been approved by a moderator.</div>');
    }
    // Prettify the comment rating.
    comment.pretty_rating = comment.rating + ' point' +
      (comment.rating == 1 ? '' : 's');
    // Make a class (for displaying not yet moderated comments differently)
    comment.css_class = comment.displayed ? '' : ' moderate';
    // Create a div for this comment.
    var context = $.extend({}, opts, comment);
    var div = $(renderTemplate(commentTemplate, context));

    // If the user has voted on this comment, highlight the correct arrow.
    if (comment.vote) {
      var direction = (comment.vote == 1) ? 'u' : 'd';
      div.find('#' + direction + 'v' + comment.id).hide();
      div.find('#' + direction + 'u' + comment.id).show();
    }

    if (opts.moderator || comment.text != '[deleted]') {
      div.find('a.reply').show();
      if (comment.proposal_diff)
        div.find('#sp' + comment.id).show();
      if (opts.moderator && !comment.displayed)
        div.find('#cm' + comment.id).show();
      if (opts.moderator || (opts.username == comment.username))
        div.find('#dc' + comment.id).show();
    }
    return div;
  }
1260413
def comments(tag, limit=0, flags=0, **kwargs):
    """"""

    return [comment for comment in cm.CommentsMatch(tag).get_comments(limit)]
904217
function hasProblematicComments(node, sourceCode) {
  return (
    hasCommentBefore(node, sourceCode) ||
    hasCommentAfter(node, sourceCode) ||
    hasCommentInsideNonSpecifiers(node, sourceCode)
  )
}