Skip to content

Commit

Permalink
fix: prevent release editing if marked as spam
Browse files Browse the repository at this point in the history
- correct alert_if_spam macro reference
- move comment to the right place
  • Loading branch information
alee committed May 22, 2024
1 parent a2ce823 commit 8d4fe55
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
7 changes: 2 additions & 5 deletions django/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ class ModeratedContent(index.Indexed, models.Model):
spam_moderation = models.ForeignKey(
SpamModeration, null=True, blank=True, on_delete=models.SET_NULL
)
# need to have this denormalized field to allow for filtering out spam content
# https://docs.wagtail.org/en/stable/topics/search/indexing.html#filtering-on-index-relatedfields
is_marked_spam = models.BooleanField(
default=False,
help_text=_(
Expand Down Expand Up @@ -647,9 +649,6 @@ class Event(ModeratedContent, ClusterableModel):
tags = ClusterTaggableManager(through=EventTag, blank=True)
external_url = models.URLField(blank=True)
is_deleted = models.BooleanField(default=False)
# need to have this denormalized field to allow for filtering out spam content
# https://docs.wagtail.org/en/stable/topics/search/indexing.html#filtering-on-index-relatedfields

objects = EventQuerySet.as_manager()

submitter = models.ForeignKey(
Expand Down Expand Up @@ -782,8 +781,6 @@ class Job(ModeratedContent, ClusterableModel):
tags = ClusterTaggableManager(through=JobTag, blank=True)
external_url = models.URLField(blank=True)
is_deleted = models.BooleanField(default=False)
# need to have this denormalized field to allow for filtering out spam content
# https://docs.wagtail.org/en/stable/topics/search/indexing.html#filtering-on-index-relatedfields

submitter = models.ForeignKey(
settings.AUTH_USER_MODEL,
Expand Down
10 changes: 6 additions & 4 deletions django/library/jinja2/library/codebases/releases/edit.jinja
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{% extends "base.jinja" %}
{% from "common.jinja" import spam_detected_alert %}
{% from "common.jinja" import alert_if_spam %}

{% block introduction %}
<h1><i class='fas fa-cloud-upload-alt'></i> Publish your computational model</h1>
{% endblock %}
{% block content %}
{% if release.codebase.is_marked_spam %}
{{ spam_detected_alert() }}
{% endif %}
{{ alert_if_spam(true) }}
{% else %}
<div id="app" data-version-number="{{ release.version_number }}" data-identifier="{{ release.codebase.identifier }}"
data-review-status-enum="{{ review_status_enum_json }}"></div>
<div id="release-editor" data-version-number="{{ release.version_number }}"
data-identifier="{{ release.codebase.identifier }}"
data-review-status="{{ release.get_review().get_status_display() if release.get_review() else 'Unreviewed' }}"
data-is-live="{{ release.live }}"
data-can-edit-originals="{{ release.can_edit_originals }}"
></div>
>
</div>
{% endif %}
{% endblock %}

{% block js %}
Expand Down
3 changes: 0 additions & 3 deletions django/library/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,6 @@ class Codebase(ModeratedContent, ClusterableModel):
doi = models.CharField(max_length=128, unique=True, null=True)
uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)

# need to have this denormalized field to allow for filtering out spam content
# https://docs.wagtail.org/en/stable/topics/search/indexing.html#filtering-on-index-relatedfields

latest_version = models.ForeignKey(
"CodebaseRelease",
null=True,
Expand Down

0 comments on commit 8d4fe55

Please sign in to comment.