<commit_before>from django.contrib.postgres.fields import ArrayField
from django.db import models
from django.db.models import Q
from django.utils import timezone
from osf_models.models import Node
from osf_models.models import NodeLog
from osf_models.models.base import GuidMixin, Guid, BaseModel
from osf_models.utils.base import api_v2_url
from osf_models.models.mixins import CommentableMixin
from osf_models.models.spam import SpamMixin
from osf_models.models import validators

from framework.exceptions import PermissionsError
from website import settings
from website.project import signals as project_signals
from website.project.model import get_valid_mentioned_users_guids


class Comment(GuidMixin, SpamMixin, CommentableMixin, BaseModel):
    # TODO DELETE ME POST MIGRATION
    modm_model_path = 'website.project.model.Comment'
    modm_query = None
    # /TODO DELETE ME POST MIGRATION
    __guid_min_length__ = 12

    OVERVIEW = 'node'
    FILES = 'files'
    WIKI = 'wiki'

    user = models.ForeignKey('OSFUser', null=True)
    # the node that the comment belongs to
    node = models.ForeignKey('AbstractNode', null=True)

    # The file or project overview page that the comment is for
    root_target = models.ForeignKey(Guid, on_delete=models.SET_NULL,
                                    related_name='comments',
                                    null=True, blank=True)

    # the direct 'parent' of the comment (e.g. the target of a comment reply is another comment)
    target = models.ForeignKey(Guid, on_delete=models.SET_NULL,
                                    related_name='child_comments',
                                    null=True, blank=True)

    date_created = models.DateTimeField(default=timezone.now)  # auto_now_add=True)
    date_modified = models.DateTimeField(default=timezone.now)  # auto_now=True)
    modified = models.BooleanField(default=False)
    is_deleted = models.BooleanField(default=False)
    # The type of root_target: node/files
    page = models.CharField(max_length=255, blank=True)
    content = models.TextField(
        validators=[validators.CommentMaxLength(settings.COMMENT_MAXLENGTH),
                    validators.string_required],
        blank=True
    )

    # The mentioned users
    # TODO This should be made into an M2M STAT
    ever_mentioned = ArrayField(models.CharField(max_length=10, blank=True), default=list, blank=True)

    @property
    def url(self):
        return '/{}/'.format(self._id)

    @property
    def absolute_api_v2_url(self):
        path = '/comments/{}/'.format(self._id)<commit_msg>Don't allow comment content to be blank, to match validator<commit_after>from django.contrib.postgres.fields import ArrayField
from django.db import models
from django.db.models import Q
from django.utils import timezone
from osf_models.models import Node
from osf_models.models import NodeLog
from osf_models.models.base import GuidMixin, Guid, BaseModel
from osf_models.utils.base import api_v2_url
from osf_models.models.mixins import CommentableMixin
from osf_models.models.spam import SpamMixin
from osf_models.models import validators

from framework.exceptions import PermissionsError
from website import settings
from website.project import signals as project_signals
from website.project.model import get_valid_mentioned_users_guids


class Comment(GuidMixin, SpamMixin, CommentableMixin, BaseModel):
    # TODO DELETE ME POST MIGRATION
    modm_model_path = 'website.project.model.Comment'
    modm_query = None
    # /TODO DELETE ME POST MIGRATION
    __guid_min_length__ = 12

    OVERVIEW = 'node'
    FILES = 'files'
    WIKI = 'wiki'

    user = models.ForeignKey('OSFUser', null=True)
    # the node that the comment belongs to
    node = models.ForeignKey('AbstractNode', null=True)

    # The file or project overview page that the comment is for
    root_target = models.ForeignKey(Guid, on_delete=models.SET_NULL,
                                    related_name='comments',
                                    null=True, blank=True)

    # the direct 'parent' of the comment (e.g. the target of a comment reply is another comment)
    target = models.ForeignKey(Guid, on_delete=models.SET_NULL,
                                    related_name='child_comments',
                                    null=True, blank=True)

    date_created = models.DateTimeField(default=timezone.now)  # auto_now_add=True)
    date_modified = models.DateTimeField(default=timezone.now)  # auto_now=True)
    modified = models.BooleanField(default=False)
    is_deleted = models.BooleanField(default=False)
    # The type of root_target: node/files
    page = models.CharField(max_length=255, blank=True)
    content = models.TextField(
        validators=[validators.CommentMaxLength(settings.COMMENT_MAXLENGTH),
                    validators.string_required]
    )

    # The mentioned users
    # TODO This should be made into an M2M STAT
    ever_mentioned = ArrayField(models.CharField(max_length=10, blank=True), default=list, blank=True)

    @property
    def url(self):
        return '/{}/'.format(self._id)

    @property
    def absolute_api_v2_url(self):
        path = '/comments/{}/'.format(self._id)
{'fraction_non_alphanumeric': 0.07904834996162702, 'fraction_numerical': 0.003837298541826554, 'mean_word_length': 3.2976092333058533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717224', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1482, 'n_words': 393}