Skip to content

Commit 4c3eb98

Browse files
authored
Merge pull request #2 from samiuelson/KG/flaskAdmin
Adding moderation of Prayer requests
2 parents 72e9972 + 4a0dcf5 commit 4c3eb98

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

dbms/rdb.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
from flask_sqlalchemy import SQLAlchemy
2+
from flask_admin.contrib.sqla import ModelView
23

34
db = SQLAlchemy()
5+
6+
def register_admin(admin):
7+
from .models import Intent
8+
admin.add_view(ModelView(Intent, db.session))

intent.db

0 Bytes
Binary file not shown.

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ ipdb==0.10.1
3737
SQLAlchemy
3838
Flask-SQLAlchemy
3939
psycopg2==2.6.2
40+
Flask-Admin==1.4.2

web.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22

33
from flask import Flask, request
44
from flask.views import MethodView
5+
from flask_admin import Admin
6+
from flask_admin.contrib.sqla import ModelView
57
from flask_babel import Babel
68
from facebook.api import FacebookApi
79
from prayer import PrayerWebhook as webhook
8-
from dbms.rdb import db
10+
from dbms.rdb import db, register_admin
911

1012

1113
def create_app():
1214
app = Flask(__name__)
1315
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///intent.db'
1416
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
1517
babel = Babel(app)
18+
admin = Admin(app, name='PrayerBot', template_mode='bootstrap3')
1619
db.init_app(app)
20+
register_admin(admin)
1721
return app
1822

1923
###
@@ -63,4 +67,4 @@ def post(self):
6367
app.add_url_rule('/webhook', view_func=WebhookAPI.as_view('webhook'))
6468

6569
if __name__ == '__main__':
66-
app.run(host='0.0.0.0')
70+
app.run(host="0.0.0.0")

0 commit comments

Comments
 (0)