mirror of
https://github.com/Llloooggg/TextSouls.git
synced 2026-03-06 20:46:23 +03:00
not working mess
This commit is contained in:
11
backend/textsouls/common/admin.py
Normal file
11
backend/textsouls/common/admin.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from flask_admin import Admin
|
||||
from flask_admin.contrib.sqla import ModelView
|
||||
|
||||
|
||||
class CommonAdminView(ModelView):
|
||||
def __init__(self, model, *args, **kwargs):
|
||||
self.column_list = [c.key for c in model.__table__.columns]
|
||||
super(CommonAdminView, self).__init__(model, *args, **kwargs)
|
||||
|
||||
|
||||
admin = Admin(name="TextSouls")
|
||||
@@ -1,15 +1,7 @@
|
||||
from flask import request
|
||||
from flask.views import MethodView
|
||||
|
||||
from flask_admin.contrib.sqla import ModelView
|
||||
|
||||
from textsouls import db
|
||||
|
||||
|
||||
class CommonAdminView(ModelView):
|
||||
def __init__(self, model, *args, **kwargs):
|
||||
self.column_list = [c.key for c in model.__table__.columns]
|
||||
super(CommonAdminView, self).__init__(model, *args, **kwargs)
|
||||
from textsouls.common.database import db
|
||||
|
||||
|
||||
class ItemAPI(MethodView):
|
||||
|
||||
18
backend/textsouls/common/celery.py
Normal file
18
backend/textsouls/common/celery.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from celery import Celery
|
||||
|
||||
|
||||
def make_celery(app):
|
||||
celery = Celery(
|
||||
app.import_name,
|
||||
backend=app.config["CELERY_RESULT_BACKEND"],
|
||||
broker=app.config["CELERY_BROKER_URL"],
|
||||
)
|
||||
celery.conf.update(app.config)
|
||||
|
||||
class ContextTask(celery.Task):
|
||||
def __call__(self, *args, **kwargs):
|
||||
with app.app_context():
|
||||
return self.run(*args, **kwargs)
|
||||
|
||||
celery.Task = ContextTask
|
||||
return celery
|
||||
3
backend/textsouls/common/database.py
Normal file
3
backend/textsouls/common/database.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
Reference in New Issue
Block a user