diff --git a/app/__init__.py b/app/__init__.py index 9154cdae..a97b81e3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -106,6 +106,11 @@ 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) + # send error reports via email if app.config['MAIL_SERVER'] and app.config['MAIL_ERRORS']: auth = None diff --git a/app/dev/__init__.py b/app/dev/__init__.py new file mode 100644 index 00000000..9685833f --- /dev/null +++ b/app/dev/__init__.py @@ -0,0 +1,5 @@ +from flask import Blueprint + +bp = Blueprint('dev', __name__) + +from app.dev import routes diff --git a/app/dev/forms.py b/app/dev/forms.py new file mode 100644 index 00000000..7fb9bedb --- /dev/null +++ b/app/dev/forms.py @@ -0,0 +1,12 @@ +from flask import request, g +from flask_login import current_user +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField, TextAreaField, BooleanField, HiddenField, SelectField, FileField +from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Optional +from flask_babel import _, lazy_gettext as _l + +from app import db + + +class AddTestCommunities(FlaskForm): + submit = SubmitField(_l('Populate Communities for Testing')) \ No newline at end of file diff --git a/app/dev/routes.py b/app/dev/routes.py new file mode 100644 index 00000000..690a3f0c --- /dev/null +++ b/app/dev/routes.py @@ -0,0 +1,25 @@ +from flask import request, flash, json, url_for, current_app, redirect, g, abort +from flask_login import login_required, current_user +from flask_babel import _ +from sqlalchemy import desc, or_, and_, text + +from app import db, celery +from app.dev.forms import AddTestCommunities +# from app.chat.forms import AddReply, ReportConversationForm +# from app.chat.util import send_message +from app.models import Site, User, Community +# from app.user.forms import ReportUserForm +from app.utils import render_template, moderating_communities, joined_communities, menu_topics +from app.dev import bp + + +# use this to populate communities in the database +@bp.route('/dev/populate-communities', methods=['GET', 'POST']) +@login_required +def populate_communities(): + form = AddTestCommunities() + if form.validate_on_submit(): + flash(_('form sumbit button pressed')) + return redirect(url_for('dev.populate_communities')) + else: + return render_template('dev/populate_communities.html', form=form) diff --git a/app/templates/dev/populate_communities.html b/app/templates/dev/populate_communities.html new file mode 100644 index 00000000..2a5c4ef1 --- /dev/null +++ b/app/templates/dev/populate_communities.html @@ -0,0 +1,22 @@ +{% 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 %} + +{% block app_content %} +