diff --git a/app/__init__.py b/app/__init__.py index a97b81e3..e5643076 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -106,10 +106,8 @@ def create_app(config_class=Config): from app.tag import bp as tag_bp app.register_blueprint(tag_bp) - # make the dev tools page available if in dev mode - if app.config['MODE'] == 'development': - from app.dev import bp as dev_bp - app.register_blueprint(dev_bp) + from app.dev import bp as dev_bp + app.register_blueprint(dev_bp) # send error reports via email if app.config['MAIL_SERVER'] and app.config['MAIL_ERRORS']: diff --git a/app/dev/routes.py b/app/dev/routes.py index 812c08a8..5043c73f 100644 --- a/app/dev/routes.py +++ b/app/dev/routes.py @@ -1,5 +1,5 @@ import random -from flask import request, flash, url_for, current_app, redirect, g +from flask import request, flash, url_for, current_app, redirect, g, abort from flask_login import login_required, current_user from flask_babel import _ @@ -8,6 +8,7 @@ from app.activitypub.signature import RsaKeys from app.admin.routes import unsubscribe_everyone_then_delete from app.dev import bp from app.dev.forms import AddTestCommunities, AddTestTopics, DeleteTestCommunities, DeleteTestTopics +from app.inoculation import inoculation from app.models import Site, User, Community, CommunityMember, Language, Topic, utcnow from app.utils import render_template, community_membership, moderating_communities, joined_communities, menu_topics, markdown_to_html @@ -16,6 +17,8 @@ from app.utils import render_template, community_membership, moderating_communit @bp.route('/dev/tools', methods=['GET', 'POST']) @login_required def tools(): + if not current_app.debug: + abort(404) communities_form = AddTestCommunities() topics_form = AddTestTopics() delete_communities_form = DeleteTestCommunities() @@ -177,7 +180,12 @@ def tools(): else: return render_template('dev/tools.html', - communities_form=communities_form, - topics_form=topics_form, - delete_communities_form=delete_communities_form, - delete_topics_form=delete_topics_form) + communities_form=communities_form, + topics_form=topics_form, + delete_communities_form=delete_communities_form, + delete_topics_form=delete_topics_form, + moderating_communities=moderating_communities(current_user.get_id()), + joined_communities=joined_communities(current_user.get_id()), + menu_topics=menu_topics(), site=g.site, + inoculation=inoculation[random.randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None + ) diff --git a/app/templates/admin/_nav.html b/app/templates/admin/_nav.html index 8d29147f..e04d0b84 100644 --- a/app/templates/admin/_nav.html +++ b/app/templates/admin/_nav.html @@ -15,7 +15,7 @@ {{ _('Newsletter') }} | {{ _('Permissions') }} | {{ _('Activities') }} - {% if current_mode == 'development' %} + {% if debug_mode %} | {{ _('Dev Tools') }} {% endif%} diff --git a/app/templates/base.html b/app/templates/base.html index bff86699..e4150943 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -211,7 +211,7 @@
{{ _('Use these buttons to quickly generate some testing topics and communities to use during development.') }}