mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
customisable posting warning
This commit is contained in:
parent
035f0f2ea9
commit
326b53e73d
7 changed files with 48 additions and 2 deletions
|
@ -81,6 +81,7 @@ class EditCommunityForm(FlaskForm):
|
||||||
('masonry', _l('Masonry')),
|
('masonry', _l('Masonry')),
|
||||||
('masonry_wide', _l('Wide masonry'))]
|
('masonry_wide', _l('Wide masonry'))]
|
||||||
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()])
|
default_layout = SelectField(_l('Layout'), coerce=str, choices=layouts, validators=[Optional()])
|
||||||
|
posting_warning = StringField(_('Posting warning'))
|
||||||
submit = SubmitField(_l('Save'))
|
submit = SubmitField(_l('Save'))
|
||||||
|
|
||||||
def validate(self, extra_validators=None):
|
def validate(self, extra_validators=None):
|
||||||
|
|
|
@ -252,6 +252,7 @@ def admin_community_edit(community_id):
|
||||||
community.content_retention = form.content_retention.data
|
community.content_retention = form.content_retention.data
|
||||||
community.topic_id = form.topic.data if form.topic.data != 0 else None
|
community.topic_id = form.topic.data if form.topic.data != 0 else None
|
||||||
community.default_layout = form.default_layout.data
|
community.default_layout = form.default_layout.data
|
||||||
|
community.posting_warning = form.posting_warning.data
|
||||||
|
|
||||||
icon_file = request.files['icon_file']
|
icon_file = request.files['icon_file']
|
||||||
if icon_file and icon_file.filename != '':
|
if icon_file and icon_file.filename != '':
|
||||||
|
@ -293,6 +294,7 @@ def admin_community_edit(community_id):
|
||||||
form.content_retention.data = community.content_retention
|
form.content_retention.data = community.content_retention
|
||||||
form.topic.data = community.topic_id if community.topic_id else None
|
form.topic.data = community.topic_id if community.topic_id else None
|
||||||
form.default_layout.data = community.default_layout
|
form.default_layout.data = community.default_layout
|
||||||
|
form.posting_warning.data = community.posting_warning
|
||||||
return render_template('admin/edit_community.html', title=_('Edit community'), form=form, community=community,
|
return render_template('admin/edit_community.html', title=_('Edit community'), form=form, community=community,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
|
|
@ -504,6 +504,8 @@ def add_discussion_post(actor):
|
||||||
else:
|
else:
|
||||||
form.communities.data = community.id
|
form.communities.data = community.id
|
||||||
form.notify_author.data = True
|
form.notify_author.data = True
|
||||||
|
if community.posting_warning:
|
||||||
|
flash(community.posting_warning)
|
||||||
|
|
||||||
return render_template('community/add_discussion_post.html', title=_('Add post to community'), form=form, community=community,
|
return render_template('community/add_discussion_post.html', title=_('Add post to community'), form=form, community=community,
|
||||||
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
|
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
|
||||||
|
|
|
@ -65,6 +65,7 @@ class Instance(db.Model):
|
||||||
gone_forever = db.Column(db.Boolean, default=False) # True once this instance is considered offline forever - never start trying again
|
gone_forever = db.Column(db.Boolean, default=False) # True once this instance is considered offline forever - never start trying again
|
||||||
ip_address = db.Column(db.String(50))
|
ip_address = db.Column(db.String(50))
|
||||||
trusted = db.Column(db.Boolean, default=False)
|
trusted = db.Column(db.Boolean, default=False)
|
||||||
|
posting_warning = db.Column(db.String(512))
|
||||||
|
|
||||||
posts = db.relationship('Post', backref='instance', lazy='dynamic')
|
posts = db.relationship('Post', backref='instance', lazy='dynamic')
|
||||||
post_replies = db.relationship('PostReply', backref='instance', lazy='dynamic')
|
post_replies = db.relationship('PostReply', backref='instance', lazy='dynamic')
|
||||||
|
@ -354,6 +355,7 @@ class Community(db.Model):
|
||||||
content_retention = db.Column(db.Integer, default=-1)
|
content_retention = db.Column(db.Integer, default=-1)
|
||||||
topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'), index=True)
|
topic_id = db.Column(db.Integer, db.ForeignKey('topic.id'), index=True)
|
||||||
default_layout = db.Column(db.String(15))
|
default_layout = db.Column(db.String(15))
|
||||||
|
posting_warning = db.Column(db.String(512))
|
||||||
|
|
||||||
ap_id = db.Column(db.String(255), index=True)
|
ap_id = db.Column(db.String(255), index=True)
|
||||||
ap_profile_id = db.Column(db.String(255), index=True)
|
ap_profile_id = db.Column(db.String(255), index=True)
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
{{ render_field(form.content_retention) }}
|
{{ render_field(form.content_retention) }}
|
||||||
{{ render_field(form.topic) }}
|
{{ render_field(form.topic) }}
|
||||||
{{ render_field(form.default_layout) }}
|
{{ render_field(form.default_layout) }}
|
||||||
|
{{ render_field(form.posting_warning) }}
|
||||||
{% if not community.is_local() %}
|
{% if not community.is_local() %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
{% if post.community.ap_id and '@beehaw.org' in post.community.ap_id %}
|
{% if post.community.ap_id and '@beehaw.org' in post.community.ap_id %}
|
||||||
<p>{{ _('This post is hosted on beehaw.org which has <a href="https://docs.beehaw.org/docs/core-principles/what-is-beehaw/" target="_blank" rel="nofollow">higher standards of behaviour than most places. Be nice</a>.') }}</p>
|
<p>{{ _('This post is hosted on beehaw.org which has <a href="https://docs.beehaw.org/docs/core-principles/what-is-beehaw/" target="_blank" rel="nofollow">higher standards of behaviour than most places. Be nice</a>.') }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if post.community.ap_id and '@lemmy.ml' in post.community.ap_id %}
|
{% if post.community.posting_warning %}
|
||||||
<p>{{ _('This post is hosted on lemmy.ml which will ban you for saying anything negative about China, Russia or Putin. Tread carefully.') }}</p>
|
<p align="center">{{ post.community.posting_warning|safe }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ render_form(form) }}
|
{{ render_form(form) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
|
|
38
migrations/versions/944c5ae8f4ba_posting_warning.py
Normal file
38
migrations/versions/944c5ae8f4ba_posting_warning.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
"""posting warning
|
||||||
|
|
||||||
|
Revision ID: 944c5ae8f4ba
|
||||||
|
Revises: 980966fba5f4
|
||||||
|
Create Date: 2024-04-18 20:42:54.287260
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '944c5ae8f4ba'
|
||||||
|
down_revision = '980966fba5f4'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('community', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('posting_warning', sa.String(length=512), nullable=True))
|
||||||
|
|
||||||
|
with op.batch_alter_table('instance', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('posting_warning', sa.String(length=512), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('instance', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('posting_warning')
|
||||||
|
|
||||||
|
with op.batch_alter_table('community', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('posting_warning')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in a new issue