<commit_before>import html
import logging

from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import post_save
from django.dispatch import receiver
from geotrek.common.mixins import PicturesMixin
from mapentity.models import MapEntityMixin

from geotrek.common.mixins import TimeStampedModelMixin

from .helpers import send_report_managers, post_report_to_suricate


logger = logging.getLogger(__name__)


class Report(MapEntityMixin, PicturesMixin, TimeStampedModelMixin):
    """ User reports, mainly submitted via *Geotrek-rando*.
    """
    email = models.EmailField(verbose_name=_("Email"))
    comment = models.TextField(blank=True,
                               default="",
                               verbose_name=_("Comment"))
    activity = models.ForeignKey('ReportActivity',
                                 on_delete=models.SET_NULL,
                                 null=True,
                                 blank=True,
                                 verbose_name=_("Activity"))
    category = models.ForeignKey('ReportCategory',
                                 on_delete=models.SET_NULL,
                                 null=True,
                                 blank=True,
                                 verbose_name=_("Category"))
    problem_magnitude = models.ForeignKey('ReportProblemMagnitude',
                                          null=True,
                                          blank=True,
                                          on_delete=models.SET_NULL,
                                          verbose_name=_("Problem magnitude"))
    status = models.ForeignKey('ReportStatus',
                               on_delete=models.SET_NULL,
                               null=True,
                               blank=True,
                               default=None,
                               verbose_name=_("Status"))
    geom = models.PointField(null=True,
                             blank=True,
                             default=None,
                             verbose_name=_("Location"),
                             srid=settings.SRID)
    context_content_type = models.ForeignKey(ContentType,
                                             on_delete=models.CASCADE,
                                             null=True,
                                             blank=True,
                                             editable=False)
    context_object_id = models.PositiveIntegerField(null=True,
                                                    blank=True,
                                                    editable=False)
    context_object = GenericForeignKey('context_content_type',
                                       'context_object_id')

    class Meta:
        verbose_name = _("Report")
        verbose_name_plural = _("Reports")
        ordering = ['-date_insert']

    def __str__(self):
        if self.email:
            return self.email
        return "Anonymous report"

    @property
    def name_display(self):
        return '<a data-pk="%s" href="%s" title="%s" >%s</a>' % (self.pk,
                                                                 self.get_detail_url(),
                                                                 self,
                                                                 self)

    @classmethod
    def get_create_label(cls):
        return _("Add a new feedback")

    @property
    def geom_wgs84(self):
        return self.geom.transform(4326, clone=True)<commit_msg>Fix link display on email<commit_after>import html
import logging

from django.conf import settings
from django.contrib.gis.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import post_save
from django.dispatch import receiver
from geotrek.common.mixins import PicturesMixin
from mapentity.models import MapEntityMixin

from geotrek.common.mixins import TimeStampedModelMixin

from .helpers import send_report_managers, post_report_to_suricate


logger = logging.getLogger(__name__)


class Report(MapEntityMixin, PicturesMixin, TimeStampedModelMixin):
    """ User reports, mainly submitted via *Geotrek-rando*.
    """
    email = models.EmailField(verbose_name=_("Email"))
    comment = models.TextField(blank=True,
                               default="",
                               verbose_name=_("Comment"))
    activity = models.ForeignKey('ReportActivity',
                                 on_delete=models.SET_NULL,
                                 null=True,
                                 blank=True,
                                 verbose_name=_("Activity"))
    category = models.ForeignKey('ReportCategory',
                                 on_delete=models.SET_NULL,
                                 null=True,
                                 blank=True,
                                 verbose_name=_("Category"))
    problem_magnitude = models.ForeignKey('ReportProblemMagnitude',
                                          null=True,
                                          blank=True,
                                          on_delete=models.SET_NULL,
                                          verbose_name=_("Problem magnitude"))
    status = models.ForeignKey('ReportStatus',
                               on_delete=models.SET_NULL,
                               null=True,
                               blank=True,
                               default=None,
                               verbose_name=_("Status"))
    geom = models.PointField(null=True,
                             blank=True,
                             default=None,
                             verbose_name=_("Location"),
                             srid=settings.SRID)
    context_content_type = models.ForeignKey(ContentType,
                                             on_delete=models.CASCADE,
                                             null=True,
                                             blank=True,
                                             editable=False)
    context_object_id = models.PositiveIntegerField(null=True,
                                                    blank=True,
                                                    editable=False)
    context_object = GenericForeignKey('context_content_type',
                                       'context_object_id')

    class Meta:
        verbose_name = _("Report")
        verbose_name_plural = _("Reports")
        ordering = ['-date_insert']

    def __str__(self):
        if self.email:
            return self.email
        return "Anonymous report"

    @property
    def email_display(self):
        return '<a data-pk="%s" href="%s" title="%s" >%s</a>' % (self.pk,
                                                                 self.get_detail_url(),
                                                                 self,
                                                                 self)

    @classmethod
    def get_create_label(cls):
        return _("Add a new feedback")

    @property
    def geom_wgs84(self):
        return self.geom.transform(4326, clone=True)
{'fraction_non_alphanumeric': 0.07305692574323423, 'fraction_numerical': 0.001599786695107319, 'mean_word_length': 1.2373993438711601, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 70, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2981215', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1603, 'n_words': 317}