diff --git a/base.yml b/base.yml index b706ee179..9708e9c7a 100644 --- a/base.yml +++ b/base.yml @@ -50,7 +50,7 @@ services: POSTGRES_PASSWORD_FILE: /run/secrets/db_password vite: build: frontend - image: comses/comsesnet-vite + image: comses/vite volumes: - /code/node_modules - ./docker/shared:/shared diff --git a/django/core/mixins.py b/django/core/mixins.py index 9bb16fb3c..f93a23c43 100644 --- a/django/core/mixins.py +++ b/django/core/mixins.py @@ -280,7 +280,7 @@ def handle_spam_detection(self, serializer: serializers.Serializer): def _record_spam(self, instance, spam_context: dict): content_type = ContentType.objects.get_for_model(type(instance)) - # SpamContent updates the content instance on save + # SpamModeration updates the content instance on save spam_moderation, created = SpamModeration.objects.get_or_create( content_type=content_type, object_id=instance.pk, diff --git a/django/core/models.py b/django/core/models.py index 0920ea752..97b2e5696 100644 --- a/django/core/models.py +++ b/django/core/models.py @@ -138,8 +138,13 @@ def update_related_object(self): related_object.is_marked_spam = self.status != self.Status.NOT_SPAM related_object.save() + def __str__(self): + return ( + f"SpamModeration: {self.status} - {self.reviewer} - {self.content_object}" + ) + -class ModeratedContent(index.Indexed, models.Model): +class ModeratedContent(models.Model): spam_moderation = models.ForeignKey( SpamModeration, null=True, blank=True, on_delete=models.SET_NULL ) @@ -152,6 +157,15 @@ class ModeratedContent(index.Indexed, models.Model): ), ) + def mark_spam(self, status=SpamModeration.Status.SPAM, **kwargs): + content_type = ContentType.objects.get_for_model(type(self)) + self.spam_moderation, created = SpamModeration.objects.get_or_create( + status=status, + object_id=self.pk, + content_type=content_type, + **kwargs, + ) + class Meta: abstract = True @@ -634,7 +648,7 @@ def public(self): @add_to_comses_permission_whitelist -class Event(ModeratedContent, ClusterableModel): +class Event(index.Indexed, ModeratedContent, ClusterableModel): title = models.CharField(max_length=300) date_created = models.DateTimeField(default=timezone.now) last_modified = models.DateTimeField(auto_now=True) @@ -767,7 +781,7 @@ def latest_for_feed(self, number=10): @add_to_comses_permission_whitelist -class Job(ModeratedContent, ClusterableModel): +class Job(index.Indexed, ModeratedContent, ClusterableModel): title = models.CharField(max_length=300, help_text=_("Job posting title")) date_created = models.DateTimeField(default=timezone.now) application_deadline = models.DateField( diff --git a/django/home/jinja2/home/index.jinja b/django/home/jinja2/home/index.jinja index 1b8e43f0a..d85d7b287 100644 --- a/django/home/jinja2/home/index.jinja +++ b/django/home/jinja2/home/index.jinja @@ -65,10 +65,9 @@