mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Add action to delete empty threads
This commit is contained in:
parent
77e53b914d
commit
acaf674ec5
@ -23,7 +23,7 @@ from flask import redirect, url_for, flash, current_app
|
|||||||
from sqlalchemy import or_, and_
|
from sqlalchemy import or_, and_
|
||||||
|
|
||||||
from app.models import PackageRelease, db, Package, PackageState, PackageScreenshot, MetaPackage, User, \
|
from app.models import PackageRelease, db, Package, PackageState, PackageScreenshot, MetaPackage, User, \
|
||||||
NotificationType, PackageUpdateConfig, License, UserRank, PackageType
|
NotificationType, PackageUpdateConfig, License, UserRank, PackageType, Thread
|
||||||
from app.tasks.emails import send_pending_digests
|
from app.tasks.emails import send_pending_digests
|
||||||
from app.tasks.forumtasks import import_topic_list, check_all_forum_accounts
|
from app.tasks.forumtasks import import_topic_list, check_all_forum_accounts
|
||||||
from app.tasks.importtasks import import_repo_screenshot, check_zip_release, check_for_updates, update_all_game_support
|
from app.tasks.importtasks import import_repo_screenshot, check_zip_release, check_for_updates, update_all_game_support
|
||||||
@ -347,3 +347,17 @@ def import_screenshots():
|
|||||||
import_repo_screenshot.delay(package.id)
|
import_repo_screenshot.delay(package.id)
|
||||||
|
|
||||||
return redirect(url_for("admin.admin_page"))
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
|
||||||
|
|
||||||
|
@action("DANGER: Delete empty threads")
|
||||||
|
def delete_empty_threads():
|
||||||
|
query = Thread.query.filter(~Thread.replies.any())
|
||||||
|
count = query.count()
|
||||||
|
for thread in query.all():
|
||||||
|
thread.watchers.clear()
|
||||||
|
db.session.delete(thread)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash(f"Deleted {count} threads", "success")
|
||||||
|
|
||||||
|
return redirect(url_for("admin.admin_page"))
|
||||||
|
Loading…
Reference in New Issue
Block a user