diff --git a/app/community/forms.py b/app/community/forms.py index ca80ba6c..797df505 100644 --- a/app/community/forms.py +++ b/app/community/forms.py @@ -3,7 +3,7 @@ from flask_login import current_user from flask_wtf import FlaskForm from wtforms import StringField, SubmitField, TextAreaField, BooleanField, HiddenField, SelectField, FileField, \ DateField -from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Optional +from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Regexp, Optional from flask_babel import _, lazy_gettext as _l from app import db @@ -82,7 +82,7 @@ class CreatePostForm(FlaskForm): link_title = StringField(_l('Title'), validators={Optional(), Length(min=3, max=255)}) link_body = TextAreaField(_l('Body'), validators={Optional(), Length(min=3, max=5000)}, render_kw={'placeholder': 'Text (optional)'}) - link_url = StringField(_l('URL'), render_kw={'placeholder': 'https://...'}) + link_url = StringField(_l('URL'), validators=[Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')], render_kw={'placeholder': 'https://...'}) image_title = StringField(_l('Title'), validators={Optional(), Length(min=3, max=255)}) image_alt_text = StringField(_l('Alt text'), validators={Optional(), Length(min=3, max=255)}) image_body = TextAreaField(_l('Body'), validators={Optional(), Length(min=3, max=5000)}, diff --git a/app/community/routes.py b/app/community/routes.py index 5ebc165a..c711ed47 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -639,7 +639,8 @@ def community_edit(community_id: int): community.image = file db.session.commit() - community.topic.num_communities = community.topic.communities.count() + if community.topic: + community.topic.num_communities = community.topic.communities.count() db.session.commit() flash(_('Saved')) return redirect(url_for('activitypub.community_profile', actor=community.ap_id if community.ap_id is not None else community.name)) @@ -654,7 +655,7 @@ def community_edit(community_id: int): form.topic.data = community.topic_id if community.topic_id else None form.default_layout.data = community.default_layout return render_template('community/community_edit.html', title=_('Edit community'), form=form, - current_app=current_app, + current_app=current_app, current="edit_settings", community=community, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id())) else: @@ -695,7 +696,7 @@ def community_mod_list(community_id: int): filter(CommunityMember.community_id == community_id, or_(CommunityMember.is_moderator == True, CommunityMember.is_owner == True)).all() return render_template('community/community_mod_list.html', title=_('Moderators for %(community)s', community=community.display_name()), - moderators=moderators, community=community, + moderators=moderators, community=community, current="moderators", moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()) ) diff --git a/app/templates/community/_community_moderation_nav.html b/app/templates/community/_community_moderation_nav.html index 51dea95d..12a54047 100644 --- a/app/templates/community/_community_moderation_nav.html +++ b/app/templates/community/_community_moderation_nav.html @@ -1,14 +1,22 @@
Are you sure you want to delete this community? This is irreversible and will delete all posts and comments associated with it.
{{ render_form(form) }} + Go back{{ _('Edit and configure this community') }}
diff --git a/app/templates/community/community_mod_list.html b/app/templates/community/community_mod_list.html index fcb13f22..16e306a6 100644 --- a/app/templates/community/community_mod_list.html +++ b/app/templates/community/community_mod_list.html @@ -16,10 +16,12 @@{{ _('See and change who moderates this community') }}
diff --git a/app/templates/community/community_moderate.html b/app/templates/community/community_moderate.html index df481696..881c9618 100644 --- a/app/templates/community/community_moderate.html +++ b/app/templates/community/community_moderate.html @@ -15,16 +15,16 @@{{ _('See and handle all reports made about %(community)s', community=community.display_name()) }}
{% if reports.items %}