warnings on domains

This commit is contained in:
rimu 2024-12-13 19:24:09 +13:00
parent 27ecfafcd4
commit d98a5e19d3
4 changed files with 42 additions and 3 deletions

View file

@ -1929,7 +1929,6 @@ class PostReply(db.Model):
return undo
class Domain(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), index=True)
@ -1937,6 +1936,7 @@ class Domain(db.Model):
banned = db.Column(db.Boolean, default=False, index=True) # Domains can be banned site-wide (by admin) or DomainBlock'ed by users
notify_mods = db.Column(db.Boolean, default=False, index=True)
notify_admins = db.Column(db.Boolean, default=False, index=True)
post_warning = db.Column(db.String(512))
def blocked_by(self, user):
block = DomainBlock.query.filter_by(domain_id=self.id, user_id=user.id).first()

View file

@ -41,7 +41,10 @@
</div>
{% elif post.type == POST_TYPE_LINK -%}
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" class="post_link" aria-label="Go to post url">{{ post.url|shorten_url }}
<span class="fe fe-external"></span></a></p>
<span class="fe fe-external"></span></a>
{% if post.domain.post_warning -%}
<span class="fe fe-warning red" title="{{ post.domain.post_warning }}"></span>
{% endif -%}</p>
{% if post.url.endswith('.mp3') -%}
<p><audio controls preload="{{ 'none' if low_bandwidth else 'metadata' }}" src="{{ post.url }}"></audio></p>
{% elif post.url.endswith('.mp4') or post.url.endswith('.webm') -%}

View file

@ -9,7 +9,11 @@
{% if post.type == POST_TYPE_VIDEO -%}
<span class="fe fe-video" aria-hidden="true"></span>
{% endif -%}
<span class="domain_link" aria-hidden="true">(<a href="/d/{{ post.domain_id }}" aria-label="{{ _('All posts about this domain') }}">{{ post.domain.name }}</a>)</span>
<span class="domain_link" aria-hidden="true">(<a href="/d/{{ post.domain_id }}" aria-label="{{ _('All posts about this domain') }}">{{ post.domain.name }}</a>)
{% if post.domain.post_warning -%}
<span class="fe fe-warning red" title="{{ post.domain.post_warning }}"></span>
{% endif -%}
</span>
{% endif -%}
{% if post.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if post.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Potentially emotionally scarring content') }}">nsfl</span>{% endif -%}

View file

@ -0,0 +1,32 @@
"""domain post warning
Revision ID: 1189f921aca6
Revises: f2fa25ab5e52
Create Date: 2024-12-13 19:17:15.319197
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1189f921aca6'
down_revision = 'f2fa25ab5e52'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('domain', schema=None) as batch_op:
batch_op.add_column(sa.Column('post_warning', sa.String(length=512), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('domain', schema=None) as batch_op:
batch_op.drop_column('post_warning')
# ### end Alembic commands ###