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 @@
+{% if community.is_owner() or current_user.is_admin() %} + + {{ _('Settings') }} + + + {{ _('Moderators') }} + +{% endif %} {{ _('Reports') }} {{ _('Banned people') }} - + {{ _('Appeals') }} - + {{ _('Mod log') }}
\ No newline at end of file diff --git a/app/templates/community/community.html b/app/templates/community/community.html index 24252648..712758bf 100644 --- a/app/templates/community/community.html +++ b/app/templates/community/community.html @@ -175,14 +175,10 @@

{{ _('Community Settings') }}

- {% if is_moderator or is_owner or is_admin %} -

{{ _('Moderate') }}

- {% endif %} {% if is_owner or is_admin %} -

{{ _('Settings') }}

- {% endif %} - {% if community.is_local() and (community.is_owner() or current_user.is_admin()) %} -

Delete community

+

{{ _('Settings & Moderation') }}

+ {% elif is_moderator %} +

{{ _('Moderation') }}

{% endif %}
diff --git a/app/templates/community/community_delete.html b/app/templates/community/community_delete.html index 28e1bf91..486ee070 100644 --- a/app/templates/community/community_delete.html +++ b/app/templates/community/community_delete.html @@ -12,7 +12,9 @@
{{ _('Delete "%(community_title)s"', community_title=community.title) }}
+

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
diff --git a/app/templates/community/community_edit.html b/app/templates/community/community_edit.html index 6bf3744e..9e3bc21b 100644 --- a/app/templates/community/community_edit.html +++ b/app/templates/community/community_edit.html @@ -15,13 +15,17 @@ + {% if community %} + {% include "community/_community_moderation_nav.html" %} + {% endif %}

{% if community %} - {{ _('Edit community') }} + {{ _('Edit %(community)s', community=community.display_name()) }} {% else %} {{ _('Create community') }} {% endif %}

+

{{ _('Edit and configure this community') }}

{{ form.csrf_token() }} {{ render_field(form.title) }} @@ -48,10 +52,12 @@ {{ render_field(form.submit) }}
- {{ _('Moderators') }} -
+ {% if community.is_local() and (community.is_owner() or current_user.is_admin()) %} +

Delete community

+ {% endif %} +
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 @@ + {% include "community/_community_moderation_nav.html" %}

{{ _('Moderators for %(community)s', community=community.display_name()) }}

+

{{ _('See and change who moderates this community') }}

{{ _('Add moderator') }}
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 @@ + {% include "community/_community_moderation_nav.html" %}
-

{{ _('Moderation of %(community)s', community=community.display_name()) }}

+

{{ _('Reports') }}

- {% include "community/_community_moderation_nav.html" %} -

{{ _('Reports') }}

+

{{ _('See and handle all reports made about %(community)s', community=community.display_name()) }}

{% if reports.items %}
diff --git a/app/templates/community/community_moderate_banned.html b/app/templates/community/community_moderate_banned.html index 96505f46..74a5b200 100644 --- a/app/templates/community/community_moderate_banned.html +++ b/app/templates/community/community_moderate_banned.html @@ -15,16 +15,17 @@ + {% include "community/_community_moderation_nav.html" %}
-

{{ _('Moderation of %(community)s', community=community.display_name()) }}

+

{{ _('Banned people') }}

- {% include "community/_community_moderation_nav.html" %} -

{{ _('Banned people') }}

+

{{ _('See and manage who is banned from %(community)s', community=community.display_name()) }}

+

{% if banned_people %} diff --git a/app/templates/user/show_profile.html b/app/templates/user/show_profile.html index 17cced75..b6d17c05 100644 --- a/app/templates/user/show_profile.html +++ b/app/templates/user/show_profile.html @@ -159,7 +159,7 @@ {% if current_user.is_authenticated and (user_access('ban users', current_user.id) or user_access('manage users', current_user.id)) and user.id != current_user.id %}
-

{{ _('Crush') }}

+

{{ _('Moderate user') }}