This commit is contained in:
p23 2024-11-19 15:29:01 +00:00
parent 0908b836d3
commit d381d1a743
9 changed files with 25 additions and 28 deletions

2
app.py
View File

@ -1,6 +1,6 @@
import os
from flask import Flask, jsonify
from flask import Flask
from bcrypt import checkpw, gensalt, hashpw
from sqlalchemy import create_engine

View File

@ -235,7 +235,7 @@ def setting_get():
@admin.route("/setting", methods=["POST"])
@role_required(["setting.edit"])
def setting_edit():
opuser = g.opuser
opuser = g.opuser.user
req = request.json
d = None

View File

@ -12,7 +12,7 @@ log = Blueprint('log', __name__)
def listlog():
# variables
if request.args.get("start") is None or request.args.get("count") is None or \
request.args.get("start").isdigit()==False or request.args.get("count").isdigit()==False:
not request.args.get("start").isdigit() or not request.args.get("count").isdigit():
return error("Arguments error"), 400
rst = int(request.args.get("start"))
count = int(request.args.get("count"))

View File

@ -1 +1 @@
{"Check_Before_Post": true, "JWT_Valid_Time": 604800, "Niming_Max_Word": 500, "Attachment_Count": 5, "Attachment_Size": 209715200, "Allowed_MIME": ["image/jpeg", "image/pjpeg", "image/png", "image/heic", "image/heif", "video/mp4", "video/quicktime", "video/hevc", "image/gif", "image/webp"]}
{"Check_Before_Post": false, "JWT_Valid_Time": 604800, "Niming_Max_Word": 500, "Attachment_Count": 5, "Attachment_Size": 209715200, "Allowed_MIME": ["image/jpeg", "image/pjpeg", "image/png", "image/heic", "image/heif", "video/mp4", "video/quicktime", "video/hevc", "image/gif", "image/webp"]}

View File

@ -11,12 +11,12 @@ class db:
_engine = None
@classmethod
def __init__(self, engine):
self._engine = engine
def __init__(cls, engine):
cls._engine = engine
@classmethod
def getsession(self):
Session = sessionmaker(bind=self._engine)
def getsession(cls):
Session = sessionmaker(bind=cls._engine)
return Session()
# role (general) (owner) (admin)
@ -56,7 +56,7 @@ def solo_article_fetcher(role:str, key) -> Tuple[Dict,int]: # admin, owner, gene
def multi_article_fetcher(role:str, start:str, count:str) -> Tuple[Response, int]: # general, admin
# checker
if start is None or count is None or \
start.isdigit()==False or count.isdigit()==False:
not start.isdigit() or not count.isdigit():
return error("Arguments error"), 400
start = int(start)
count = int(count)

View File

@ -1,21 +1,16 @@
from utils import pgclass
from utils.dbhelper import db
from utils.platform_consts import EVENT_TYPE_GENERAL, EVENT_TYPE_ADMIN, EVENT_TYPE_SERVER
from utils.platform_consts import EVENT_TYPE
def logger(type, message):
table = pgclass.SQLlog
flag = False
# new post & del post
if type in EVENT_TYPE_GENERAL:
for etl in EVENT_TYPE:
if type in EVENT_TYPE[etl]:
flag = True
log = table(source = "general", message = message)
elif type in EVENT_TYPE_ADMIN:
flag = True
log = table(source = "admin", message = message)
elif type in EVENT_TYPE_SERVER:
flag = True
log = table(source = "server", message = message)
log = table(source = etl, message = message)
break
# session.add
if flag:

View File

@ -1,4 +1,4 @@
from sqlalchemy import Column, Integer, String, TIMESTAMP, func, BIGINT, LargeBinary, ARRAY
from sqlalchemy import Column, String, TIMESTAMP, func, BIGINT, LargeBinary, ARRAY
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()

View File

@ -3,9 +3,11 @@ PLIST = ["article.read", "article.pend", "article.del", "setting.edit"] # no per
PLIST_ROOT = PLIST + ["usermgr"]
# event type
EVENT_TYPE_GENERAL = ["newpost", "delpost"]
EVENT_TYPE_ADMIN = ["login", "user.create", "user.delete", "article.delete", "article.pend", "setting.modify"]
EVENT_TYPE_SERVER = ["server.start"]
EVENT_TYPE = {
"general": ["newpost", "delpost"],
"admin": ["login", "user.create", "user.delete", "article.delete", "article.pend", "setting.modify"],
"server": ["server.start"]
}
# Platform Setting Model
PLATFORM_SETTING_MODEL = {