mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Adding a dev tools page
This commit is contained in:
parent
058cef2871
commit
40245e65ec
5 changed files with 69 additions and 0 deletions
|
@ -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
|
||||
|
|
5
app/dev/__init__.py
Normal file
5
app/dev/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from flask import Blueprint
|
||||
|
||||
bp = Blueprint('dev', __name__)
|
||||
|
||||
from app.dev import routes
|
12
app/dev/forms.py
Normal file
12
app/dev/forms.py
Normal file
|
@ -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'))
|
25
app/dev/routes.py
Normal file
25
app/dev/routes.py
Normal file
|
@ -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)
|
22
app/templates/dev/populate_communities.html
Normal file
22
app/templates/dev/populate_communities.html
Normal file
|
@ -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 %} %}
|
||||
<!-- {% set active_child = 'populate_testing_communities' %} -->
|
||||
{% from 'bootstrap/form.html' import render_form %}
|
||||
|
||||
{% block app_content %}
|
||||
<div class="row">
|
||||
<div class="col col-login mx-auto">
|
||||
<div class="card mt-5">
|
||||
<div class="card-body p-6">
|
||||
<div class="card-title">{{ _('Add Communities to DB for Testing') }}</div>
|
||||
<div class="card-body">
|
||||
{{ render_form(form) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue