mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-08 16:43:47 +01:00
Update database dependencies
This commit is contained in:
parent
660ef72532
commit
a5ec46f14c
@ -126,7 +126,7 @@ def check_for_ban():
|
||||
models.db.session.commit()
|
||||
|
||||
|
||||
from .utils import clearNotifications, is_safe_url
|
||||
from .utils import clearNotifications, is_safe_url, create_session
|
||||
|
||||
|
||||
@app.before_request
|
||||
@ -159,7 +159,7 @@ def get_locale():
|
||||
locale = request.accept_languages.best_match(locales)
|
||||
|
||||
if locale and current_user.is_authenticated:
|
||||
with models.db.create_session({})() as new_session:
|
||||
with create_session() as new_session:
|
||||
new_session.query(models.User) \
|
||||
.filter(models.User.username == current_user.username) \
|
||||
.update({"locale": locale})
|
||||
|
@ -35,7 +35,7 @@ def audit():
|
||||
abort(404)
|
||||
query = query.filter_by(causer=user)
|
||||
|
||||
pagination = query.paginate(page, num, True)
|
||||
pagination = query.paginate(page=page, per_page=num)
|
||||
return render_template("admin/audit.html", log=pagination.items, pagination=pagination)
|
||||
|
||||
|
||||
|
@ -448,7 +448,7 @@ def list_all_reviews():
|
||||
if q:
|
||||
query = query.filter(PackageReview.thread.has(Thread.title.ilike(f"%{q}%")))
|
||||
|
||||
pagination: flask_sqlalchemy.Pagination = query.paginate(page, num, True)
|
||||
pagination: flask_sqlalchemy.Pagination = query.paginate(page=page, per_page=num)
|
||||
return jsonify({
|
||||
"page": pagination.page,
|
||||
"per_page": pagination.per_page,
|
||||
@ -601,7 +601,7 @@ def all_deps():
|
||||
|
||||
page = get_int_or_abort(request.args.get("page"), 1)
|
||||
num = min(get_int_or_abort(request.args.get("n"), 100), 300)
|
||||
pagination: flask_sqlalchemy.Pagination = query.paginate(page, num, True)
|
||||
pagination: flask_sqlalchemy.Pagination = query.paginate(page=page, per_page=num)
|
||||
return jsonify({
|
||||
"page": pagination.page,
|
||||
"per_page": pagination.per_page,
|
||||
|
@ -85,12 +85,12 @@ def create_edit_token(username, id=None):
|
||||
if form.validate_on_submit():
|
||||
if is_new:
|
||||
token = APIToken()
|
||||
db.session.add(token)
|
||||
token.owner = user
|
||||
token.access_token = randomString(32)
|
||||
|
||||
form.populate_obj(token)
|
||||
db.session.add(token)
|
||||
db.session.commit() # save
|
||||
db.session.commit()
|
||||
|
||||
if is_new:
|
||||
# Store token so it can be shown in the edit page
|
||||
|
@ -76,7 +76,7 @@ def list_all():
|
||||
|
||||
page = get_int_or_abort(request.args.get("page"), 1)
|
||||
num = min(40, get_int_or_abort(request.args.get("n"), 100))
|
||||
query = query.paginate(page, num, True)
|
||||
query = query.paginate(page=page, per_page=num)
|
||||
|
||||
search = request.args.get("q")
|
||||
type_name = request.args.get("type")
|
||||
@ -273,6 +273,7 @@ def handle_create_edit(package: typing.Optional[Package], form: PackageForm, aut
|
||||
return None
|
||||
|
||||
package = Package()
|
||||
db.session.add(package)
|
||||
package.author = author
|
||||
package.maintainers.append(author)
|
||||
wasNew = True
|
||||
@ -563,7 +564,7 @@ def audit(package):
|
||||
|
||||
query = package.audit_log_entries.order_by(db.desc(AuditLogEntry.created_at))
|
||||
|
||||
pagination = query.paginate(page, num, True)
|
||||
pagination = query.paginate(page=page, per_page=num)
|
||||
return render_template("packages/audit.html", log=pagination.items, pagination=pagination,
|
||||
package=package, tabs=get_package_tabs(current_user, package), current_tab="audit")
|
||||
|
||||
|
@ -36,7 +36,7 @@ def list_reviews():
|
||||
page = get_int_or_abort(request.args.get("page"), 1)
|
||||
num = min(40, get_int_or_abort(request.args.get("n"), 100))
|
||||
|
||||
pagination = PackageReview.query.order_by(db.desc(PackageReview.created_at)).paginate(page, num, True)
|
||||
pagination = PackageReview.query.order_by(db.desc(PackageReview.created_at)).paginate(page=page, per_page=num)
|
||||
return render_template("packages/reviews_list.html", pagination=pagination, reviews=pagination.items)
|
||||
|
||||
|
||||
|
@ -50,7 +50,7 @@ def list_all():
|
||||
page = get_int_or_abort(request.args.get("page"), 1)
|
||||
num = min(40, get_int_or_abort(request.args.get("n"), 100))
|
||||
|
||||
pagination = query.paginate(page, num, True)
|
||||
pagination = query.paginate(page=page, per_page=num)
|
||||
|
||||
return render_template("threads/list.html", pagination=pagination, threads=pagination.items, package=package)
|
||||
|
||||
|
@ -108,7 +108,7 @@ def topics():
|
||||
if num > 100 and not current_user.rank.atLeast(UserRank.APPROVER):
|
||||
num = 100
|
||||
|
||||
query = query.paginate(page, num, True)
|
||||
query = query.paginate(page=page, per_page=num)
|
||||
next_url = url_for("todo.topics", page=query.next_num, query=qb.search,
|
||||
show_discarded=qb.show_discarded, n=num, sort=qb.order_by) \
|
||||
if query.has_next else None
|
||||
|
@ -20,6 +20,7 @@ import datetime
|
||||
from sqlalchemy import or_, and_
|
||||
|
||||
from app.models import User, db, UserRank, ThreadReply, Package
|
||||
from app.utils.models import create_session
|
||||
from app.tasks import celery
|
||||
|
||||
|
||||
@ -37,7 +38,7 @@ def delete_inactive_users():
|
||||
|
||||
@celery.task()
|
||||
def upgrade_new_members():
|
||||
with db.create_session({})() as session:
|
||||
with create_session() as session:
|
||||
threshold = datetime.datetime.now() - datetime.timedelta(days=7)
|
||||
|
||||
session.query(User).filter(and_(User.rank == UserRank.NEW_MEMBER, or_(
|
||||
|
@ -34,6 +34,7 @@ def is_int(v):
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with app.app_context():
|
||||
app.config["TESTING"] = True
|
||||
app.config['WTF_CSRF_ENABLED'] = False
|
||||
|
||||
|
@ -22,6 +22,7 @@ import sqlalchemy.orm
|
||||
from flask import abort, redirect, url_for, request
|
||||
from flask_login import current_user
|
||||
from sqlalchemy import or_, and_
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from app.models import User, NotificationType, Package, UserRank, Notification, db, AuditSeverity, AuditLogEntry, ThreadReply, Thread, PackageState, PackageType, PackageAlias
|
||||
|
||||
@ -149,3 +150,7 @@ def get_games_from_csv(session: sqlalchemy.orm.Session, csv: str) -> List[Packag
|
||||
retval.extend(games)
|
||||
|
||||
return retval
|
||||
|
||||
|
||||
def create_session():
|
||||
return sessionmaker(bind=db.engine)()
|
||||
|
@ -70,11 +70,14 @@ def run_migrations_online():
|
||||
poolclass=pool.NullPool)
|
||||
|
||||
connection = engine.connect()
|
||||
|
||||
args = current_app.extensions['migrate'].configure_args
|
||||
args["compare_type"] = True
|
||||
|
||||
context.configure(connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
process_revision_directives=process_revision_directives,
|
||||
compare_type=True,
|
||||
**current_app.extensions['migrate'].configure_args)
|
||||
**args)
|
||||
|
||||
try:
|
||||
with context.begin_transaction():
|
||||
|
@ -25,8 +25,8 @@ Flask-FlatPages==0.8.1
|
||||
Flask-Gravatar==0.5.0
|
||||
Flask-Login==0.6.2
|
||||
Flask-Mail==0.9.1
|
||||
Flask-Migrate==3.1.0
|
||||
Flask-SQLAlchemy==2.5.1
|
||||
Flask-Migrate==4.0.4
|
||||
Flask-SQLAlchemy==3.0.3
|
||||
Flask-WTF==1.1.1
|
||||
git-archive-all==1.23.1
|
||||
gitdb==4.0.10
|
||||
@ -60,9 +60,9 @@ requests==2.28.2
|
||||
six==1.16.0
|
||||
smmap==5.0.0
|
||||
soupsieve==2.4.1
|
||||
SQLAlchemy==1.4.31
|
||||
SQLAlchemy==2.0.9
|
||||
SQLAlchemy-Searchable==1.4.1
|
||||
SQLAlchemy-Utils==0.38.2
|
||||
SQLAlchemy-Utils==0.41.0
|
||||
tomli==2.0.1
|
||||
typing_extensions==4.5.0
|
||||
ua-parser==0.16.1
|
||||
|
Loading…
Reference in New Issue
Block a user