From a1fa74d3ba0319d8e82f3b2c34ff8f3a13a04fa4 Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 8 Jul 2024 13:21:02 +0200 Subject: [PATCH] move all post_edit templates into one --- app/community/forms.py | 58 ++------ app/community/util.py | 20 +-- app/post/routes.py | 30 ++--- .../community/add_discussion_post.html | 12 +- app/templates/community/add_image_post.html | 12 +- app/templates/community/add_link_post.html | 12 +- app/templates/community/add_poll_post.html | 12 +- app/templates/community/add_video_post.html | 12 +- app/templates/post/post_edit.html | 127 ++++++++++++++++++ app/templates/post/post_edit_discussion.html | 77 ----------- app/templates/post/post_edit_image.html | 80 ----------- app/templates/post/post_edit_link.html | 77 ----------- app/templates/post/post_edit_poll.html | 113 ---------------- app/templates/post/post_edit_video.html | 77 ----------- pyfedi.py | 6 +- 15 files changed, 191 insertions(+), 534 deletions(-) create mode 100644 app/templates/post/post_edit.html delete mode 100644 app/templates/post/post_edit_discussion.html delete mode 100644 app/templates/post/post_edit_image.html delete mode 100644 app/templates/post/post_edit_link.html delete mode 100644 app/templates/post/post_edit_poll.html delete mode 100644 app/templates/post/post_edit_video.html diff --git a/app/community/forms.py b/app/community/forms.py index a30b79b4..dfeb5f10 100644 --- a/app/community/forms.py +++ b/app/community/forms.py @@ -92,10 +92,10 @@ class BanUserCommunityForm(FlaskForm): submit = SubmitField(_l('Ban')) -class CreateDiscussionForm(FlaskForm): +class CreatePostForm(FlaskForm): communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - discussion_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) - discussion_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) + title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) + body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)]) sticky = BooleanField(_l('Sticky')) nsfw = BooleanField(_l('NSFW')) @@ -105,19 +105,13 @@ class CreateDiscussionForm(FlaskForm): submit = SubmitField(_l('Save')) -class CreateLinkForm(FlaskForm): - communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - link_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) - link_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) +class CreateDiscussionForm(CreatePostForm): + pass + + +class CreateLinkForm(CreatePostForm): link_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')], render_kw={'placeholder': 'https://...'}) - tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)]) - sticky = BooleanField(_l('Sticky')) - nsfw = BooleanField(_l('NSFW')) - nsfl = BooleanField(_l('Gore/gross')) - notify_author = BooleanField(_l('Notify about replies')) - language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - submit = SubmitField(_l('Save')) def validate(self, extra_validators=None) -> bool: domain = domain_from_url(self.link_url.data, create=False) @@ -127,19 +121,9 @@ class CreateLinkForm(FlaskForm): return True -class CreateVideoForm(FlaskForm): - communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - video_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) - video_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) +class CreateVideoForm(CreatePostForm): video_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')], render_kw={'placeholder': 'https://...'}) - tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)]) - sticky = BooleanField(_l('Sticky')) - nsfw = BooleanField(_l('NSFW')) - nsfl = BooleanField(_l('Gore/gross')) - notify_author = BooleanField(_l('Notify about replies')) - language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - submit = SubmitField(_l('Save')) def validate(self, extra_validators=None) -> bool: domain = domain_from_url(self.video_url.data, create=False) @@ -149,19 +133,9 @@ class CreateVideoForm(FlaskForm): return True -class CreateImageForm(FlaskForm): - communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - image_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) +class CreateImageForm(CreatePostForm): image_alt_text = StringField(_l('Alt text'), validators=[Optional(), Length(min=3, max=1500)]) - image_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) image_file = FileField(_l('Image'), validators=[DataRequired()], render_kw={'accept': 'image/*'}) - tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)]) - sticky = BooleanField(_l('Sticky')) - nsfw = BooleanField(_l('NSFW')) - nsfl = BooleanField(_l('Gore/gross')) - notify_author = BooleanField(_l('Notify about replies')) - language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - submit = SubmitField(_l('Save')) def validate(self, extra_validators=None) -> bool: uploaded_file = request.files['image_file'] @@ -187,10 +161,7 @@ class CreateImageForm(FlaskForm): return True -class CreatePollForm(FlaskForm): - communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - poll_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)]) - poll_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5}) +class CreatePollForm(CreatePostForm): mode = SelectField(_('Mode'), validators=[DataRequired()], choices=[('single', _l('Voters choose one option')), ('multiple', _l('Voters choose many options'))], render_kw={'class': 'form-select'}) finish_choices=[ ('30m', _l('30 minutes')), @@ -213,13 +184,6 @@ class CreatePollForm(FlaskForm): choice_8 = StringField('Choice') choice_9 = StringField('Choice') choice_10 = StringField('Choice') - tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)]) - sticky = BooleanField(_l('Sticky')) - nsfw = BooleanField(_l('NSFW')) - nsfl = BooleanField(_l('Gore/gross')) - notify_author = BooleanField(_l('Notify about replies')) - language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'}) - submit = SubmitField(_l('Save')) def validate(self, extra_validators=None) -> bool: choices_made = 0 diff --git a/app/community/util.py b/app/community/util.py index cec1fe5e..2fbad9a6 100644 --- a/app/community/util.py +++ b/app/community/util.py @@ -250,15 +250,12 @@ def save_post(form, post: Post, type: str): post.notify_author = form.notify_author.data post.language_id = form.language_id.data current_user.language_id = form.language_id.data + post.title = form.title.data + post.body = form.body.data + post.body_html = markdown_to_html(post.body) if type == '' or type == 'discussion': - post.title = form.discussion_title.data - post.body = form.discussion_body.data - post.body_html = markdown_to_html(post.body) post.type = POST_TYPE_ARTICLE elif type == 'link': - post.title = form.link_title.data - post.body = form.link_body.data - post.body_html = markdown_to_html(post.body) url_changed = post.id is None or form.link_url.data != post.url post.url = remove_tracking_from_link(form.link_url.data.strip()) post.type = POST_TYPE_LINK @@ -298,11 +295,8 @@ def save_post(form, post: Post, type: str): db.session.add(file) elif type == 'image': - post.title = form.image_title.data - post.body = form.image_body.data - post.body_html = markdown_to_html(post.body) post.type = POST_TYPE_IMAGE - alt_text = form.image_alt_text.data if form.image_alt_text.data else form.image_title.data + alt_text = form.image_alt_text.data if form.image_alt_text.data else form.title.data uploaded_file = request.files['image_file'] if uploaded_file and uploaded_file.filename != '': if post.image_id: @@ -359,9 +353,6 @@ def save_post(form, post: Post, type: str): post.image_id = file.id elif type == 'video': form.video_url.data = form.video_url.data.strip() - post.title = form.video_title.data - post.body = form.video_body.data - post.body_html = markdown_to_html(post.body) url_changed = post.id is None or form.video_url.data != post.url post.url = remove_tracking_from_link(form.video_url.data.strip()) post.type = POST_TYPE_VIDEO @@ -390,8 +381,7 @@ def save_post(form, post: Post, type: str): db.session.add(file) elif type == 'poll': - post.title = form.poll_title.data - post.body = form.poll_title.data + '\n' + form.poll_body.data if post.title not in form.poll_body.data else form.poll_body.data + post.body = form.title.data + '\n' + form.body.data if post.title not in form.body.data else form.body.data post.body_html = markdown_to_html(post.body) post.type = POST_TYPE_POLL else: diff --git a/app/post/routes.py b/app/post/routes.py index 63584749..3aaf5e7a 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -950,8 +950,8 @@ def post_edit_discussion_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post.id)) else: - form.discussion_title.data = post.title - form.discussion_body.data = post.body + form.title.data = post.title + form.body.data = post.body form.notify_author.data = post.notify_author form.nsfw.data = post.nsfw form.nsfl.data = post.nsfl @@ -960,7 +960,7 @@ def post_edit_discussion_post(post_id: int): form.tags.data = tags_to_string(post) if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()): form.sticky.render_kw = {'disabled': True} - return render_template('post/post_edit_discussion.html', title=_('Edit post'), form=form, post=post, + return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post, markdown_editor=current_user.markdown_editor, mods=mod_list, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), @@ -1036,8 +1036,8 @@ def post_edit_image_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post.id)) else: - form.image_title.data = post.title - form.image_body.data = post.body + form.title.data = post.title + form.body.data = post.body form.image_alt_text.data = post.image.alt_text form.notify_author.data = post.notify_author form.nsfw.data = post.nsfw @@ -1047,7 +1047,7 @@ def post_edit_image_post(post_id: int): form.tags.data = tags_to_string(post) if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()): form.sticky.render_kw = {'disabled': True} - return render_template('post/post_edit_image.html', title=_('Edit post'), form=form, post=post, + return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post, markdown_editor=current_user.markdown_editor, mods=mod_list, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), @@ -1123,8 +1123,8 @@ def post_edit_link_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post.id)) else: - form.link_title.data = post.title - form.link_body.data = post.body + form.title.data = post.title + form.body.data = post.body form.link_url.data = post.url form.notify_author.data = post.notify_author form.nsfw.data = post.nsfw @@ -1134,7 +1134,7 @@ def post_edit_link_post(post_id: int): form.tags.data = tags_to_string(post) if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()): form.sticky.render_kw = {'disabled': True} - return render_template('post/post_edit_link.html', title=_('Edit post'), form=form, post=post, + return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post, markdown_editor=current_user.markdown_editor, mods=mod_list, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), @@ -1210,8 +1210,8 @@ def post_edit_video_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post.id)) else: - form.video_title.data = post.title - form.video_body.data = post.body + form.title.data = post.title + form.body.data = post.body form.video_url.data = post.url form.notify_author.data = post.notify_author form.nsfw.data = post.nsfw @@ -1221,7 +1221,7 @@ def post_edit_video_post(post_id: int): form.tags.data = tags_to_string(post) if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()): form.sticky.render_kw = {'disabled': True} - return render_template('post/post_edit_video.html', title=_('Edit post'), form=form, post=post, + return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post, markdown_editor=current_user.markdown_editor, mods=mod_list, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), @@ -1275,8 +1275,8 @@ def post_edit_poll_post(post_id: int): return redirect(url_for('activitypub.post_ap', post_id=post.id)) else: - form.poll_title.data = post.title - form.poll_body.data = post.body + form.title.data = post.title + form.body.data = post.body form.notify_author.data = post.notify_author form.nsfw.data = post.nsfw form.nsfl.data = post.nsfl @@ -1293,7 +1293,7 @@ def post_edit_poll_post(post_id: int): form.tags.data = tags_to_string(post) if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()): form.sticky.render_kw = {'disabled': True} - return render_template('post/post_edit_poll.html', title=_('Edit post'), form=form, post=post, + return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post, markdown_editor=current_user.markdown_editor, mods=mod_list, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), diff --git a/app/templates/community/add_discussion_post.html b/app/templates/community/add_discussion_post.html index 16bb53cd..8f2708a9 100644 --- a/app/templates/community/add_discussion_post.html +++ b/app/templates/community/add_discussion_post.html @@ -19,22 +19,22 @@ {{ render_field(form.communities) }} - {{ render_field(form.discussion_title) }} - {{ render_field(form.discussion_body) }} + {{ render_field(form.title) }} + {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} {% else %} - + {% endif %} {% endif %} {{ render_field(form.tags) }} @@ -88,4 +88,4 @@ {% include "_inoculation_links.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/community/add_image_post.html b/app/templates/community/add_image_post.html index 3b7c63bb..2bb1d212 100644 --- a/app/templates/community/add_image_post.html +++ b/app/templates/community/add_image_post.html @@ -18,25 +18,25 @@ {% include 'community/_add_post_types.html' %} {{ render_field(form.communities) }} - {{ render_field(form.image_title) }} + {{ render_field(form.title) }} {{ render_field(form.image_file) }} {{ render_field(form.image_alt_text) }} {{ _('Describe the image, to help visually impaired people.') }} - {{ render_field(form.image_body) }} + {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} {% else %} - + {% endif %} {% endif %} {{ render_field(form.tags) }} @@ -90,4 +90,4 @@ {% include "_inoculation_links.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/community/add_link_post.html b/app/templates/community/add_link_post.html index 380b6855..67bd9c22 100644 --- a/app/templates/community/add_link_post.html +++ b/app/templates/community/add_link_post.html @@ -19,23 +19,23 @@ {{ render_field(form.communities) }} - {{ render_field(form.link_title) }} + {{ render_field(form.title) }} {{ render_field(form.link_url) }} - {{ render_field(form.link_body) }} + {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} {% else %} - + {% endif %} {% endif %} {{ render_field(form.tags) }} @@ -89,4 +89,4 @@ {% include "_inoculation_links.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/community/add_poll_post.html b/app/templates/community/add_poll_post.html index 109224a5..6536314c 100644 --- a/app/templates/community/add_poll_post.html +++ b/app/templates/community/add_poll_post.html @@ -19,22 +19,22 @@ {{ render_field(form.communities) }} - {{ render_field(form.poll_title) }} - {{ render_field(form.poll_body) }} + {{ render_field(form.title) }} + {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} {% else %} - + {% endif %} {% endif %}
@@ -125,4 +125,4 @@ {% include "_inoculation_links.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/community/add_video_post.html b/app/templates/community/add_video_post.html index edd342c1..23c899c8 100644 --- a/app/templates/community/add_video_post.html +++ b/app/templates/community/add_video_post.html @@ -19,24 +19,24 @@ {{ render_field(form.communities) }} - {{ render_field(form.video_title) }} + {{ render_field(form.title) }} {{ render_field(form.video_url) }}

{{ _('Provide a URL ending with .mp4 or .webm.') }}

- {{ render_field(form.video_body) }} + {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} {% else %} - + {% endif %} {% endif %} {{ render_field(form.tags) }} @@ -90,4 +90,4 @@ {% include "_inoculation_links.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/templates/post/post_edit.html b/app/templates/post/post_edit.html new file mode 100644 index 00000000..3f3fc173 --- /dev/null +++ b/app/templates/post/post_edit.html @@ -0,0 +1,127 @@ +{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} + {% extends 'themes/' + theme() + '/base.html' %} +{% else %} + {% extends "base.html" %} +{% endif %} %} +{% from 'bootstrap/form.html' import render_form, render_field %} + +{% block app_content %} +
+
+

{{ _('Edit post') }}

+
+ {{ form.csrf_token() }} + {{ render_field(form.title) }} + {% if post.type == POST_TYPE_LINK %} + {{ render_field(form.link_url) }} + {% elif post.type == POST_TYPE_IMAGE %} + {{ render_field(form.image_file) }} + {{ render_field(form.image_alt_text) }} + {{ _('Describe the image, to help visually impaired people.') }} + {% elif post.type == POST_TYPE_VIDEO %} + {{ render_field(form.video_url) }} + {% endif %} + {{ render_field(form.body) }} + + {% if markdown_editor %} + + {% endif %} + + {% if post.type == POST_TYPE_POLL %} +
+ {{ _('Poll choices') }} +
+ {{ form.choice_1(class_="form-control", **{"placeholder": "First choice"}) }} +
+
+ {{ form.choice_2(class_="form-control", **{"placeholder": "Second choice"}) }} +
+
+ {{ form.choice_3(class_="form-control") }} +
+ + + + + + + + +
+ {{ render_field(form.mode) }} + {{ render_field(form.local_only) }} + {% endif %} + + {{ render_field(form.tags) }} + {{ _('Separate each tag with a comma.') }} + +
+
+ {{ render_field(form.notify_author) }} +
+
+ {{ render_field(form.sticky) }} +
+
+ {{ render_field(form.nsfw) }} +
+
+ {{ render_field(form.nsfl) }} +
+ +
+ {{ render_field(form.language_id) }} +
+
+ + {{ render_field(form.submit) }} +
+
+ + + +
+{% endblock %} diff --git a/app/templates/post/post_edit_discussion.html b/app/templates/post/post_edit_discussion.html deleted file mode 100644 index 364ceede..00000000 --- a/app/templates/post/post_edit_discussion.html +++ /dev/null @@ -1,77 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form, render_field %} - -{% block app_content %} -
-
-

{{ _('Edit post') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.discussion_title) }} - {{ render_field(form.discussion_body) }} - {% if markdown_editor %} - - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
- -
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - - -
-{% endblock %} \ No newline at end of file diff --git a/app/templates/post/post_edit_image.html b/app/templates/post/post_edit_image.html deleted file mode 100644 index 7b5f25db..00000000 --- a/app/templates/post/post_edit_image.html +++ /dev/null @@ -1,80 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form, render_field %} - -{% block app_content %} -
-
-

{{ _('Edit post') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.image_title) }} - {{ render_field(form.image_file) }} - {{ render_field(form.image_alt_text) }} - {{ _('Describe the image, to help visually impaired people.') }} - {{ render_field(form.image_body) }} - {% if markdown_editor %} - - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
- -
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - - -
-{% endblock %} \ No newline at end of file diff --git a/app/templates/post/post_edit_link.html b/app/templates/post/post_edit_link.html deleted file mode 100644 index 399f5912..00000000 --- a/app/templates/post/post_edit_link.html +++ /dev/null @@ -1,77 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form, render_field %} - -{% block app_content %} -
-
-

{{ _('Edit post') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.link_title) }} - {{ render_field(form.link_url) }} - {{ render_field(form.link_body) }} - {% if markdown_editor %} - - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
- -
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - - -
-{% endblock %} \ No newline at end of file diff --git a/app/templates/post/post_edit_poll.html b/app/templates/post/post_edit_poll.html deleted file mode 100644 index 41d29960..00000000 --- a/app/templates/post/post_edit_poll.html +++ /dev/null @@ -1,113 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form, render_field %} - -{% block app_content %} -
-
-

{{ _('Edit post') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.poll_title) }} - {{ render_field(form.poll_body) }} - {% if markdown_editor %} - - {% endif %} -
- {{ _('Poll choices') }} -
- {{ form.choice_1(class_="form-control", **{"placeholder": "First choice"}) }} -
-
- {{ form.choice_2(class_="form-control", **{"placeholder": "Second choice"}) }} -
-
- {{ form.choice_3(class_="form-control") }} -
- - - - - - - - -
- {{ render_field(form.mode) }} - {{ render_field(form.local_only) }} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
- -
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - - -
-{% endblock %} \ No newline at end of file diff --git a/app/templates/post/post_edit_video.html b/app/templates/post/post_edit_video.html deleted file mode 100644 index 46a3a50b..00000000 --- a/app/templates/post/post_edit_video.html +++ /dev/null @@ -1,77 +0,0 @@ -{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} - {% extends 'themes/' + theme() + '/base.html' %} -{% else %} - {% extends "base.html" %} -{% endif %} %} -{% from 'bootstrap/form.html' import render_form, render_field %} - -{% block app_content %} -
-
-

{{ _('Edit post') }}

-
- {{ form.csrf_token() }} - {{ render_field(form.video_title) }} - {{ render_field(form.video_url) }} - {{ render_field(form.video_body) }} - {% if markdown_editor %} - - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
- -
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - - -
-{% endblock %} \ No newline at end of file diff --git a/pyfedi.py b/pyfedi.py index 6b0f8a6d..45c9b59b 100644 --- a/pyfedi.py +++ b/pyfedi.py @@ -8,7 +8,7 @@ from flask_login import current_user from app import create_app, db, cli import os, click from flask import session, g, json, request, current_app -from app.constants import POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_ARTICLE, POST_TYPE_VIDEO +from app.constants import POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_ARTICLE, POST_TYPE_VIDEO, POST_TYPE_POLL from app.models import Site from app.utils import getmtime, gibberish, shorten_string, shorten_url, digits, user_access, community_membership, \ can_create_post, can_upvote, can_downvote, shorten_number, ap_datetime, current_theme, community_link_to_href, \ @@ -22,8 +22,8 @@ cli.register(app) def app_context_processor(): def getmtime(filename): return os.path.getmtime('app/static/' + filename) - return dict(getmtime=getmtime, post_type_link=POST_TYPE_LINK, post_type_image=POST_TYPE_IMAGE, - post_type_article=POST_TYPE_ARTICLE, post_type_video=POST_TYPE_VIDEO) + return dict(getmtime=getmtime, POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE, + POST_TYPE_ARTICLE=POST_TYPE_ARTICLE, POST_TYPE_VIDEO=POST_TYPE_VIDEO, POST_TYPE_POLL=POST_TYPE_POLL) @app.shell_context_processor