Add import translation action

This commit is contained in:
rubenwardy
2024-03-03 01:13:05 +00:00
parent 028452c2ca
commit 8f9f554749
4 changed files with 93 additions and 38 deletions

View File

@@ -26,7 +26,8 @@ from app.models import PackageRelease, db, Package, PackageState, PackageScreens
NotificationType, PackageUpdateConfig, License, UserRank, PackageType, Thread
from app.tasks.emails import send_pending_digests
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, \
import_languages
from app.utils import add_notification, get_system_user
actions = {}
@@ -321,7 +322,7 @@ def check_releases():
@action("DANGER: Check latest release of all packages (postReleaseCheckUpdate)")
def reimport_packages():
tasks = []
for package in Package.query.filter(Package.state != PackageState.DELETED).all():
for package in Package.query.filter(Package.state == PackageState.APPROVED).all():
release = package.releases.first()
if release:
tasks.append(check_zip_release.s(release.id, release.file_path))
@@ -335,6 +336,22 @@ def reimport_packages():
return redirect(url_for("todo.view_editor"))
@action("DANGER: Import translations")
def reimport_translations():
tasks = []
for package in Package.query.filter(Package.state == PackageState.APPROVED).all():
release = package.releases.first()
if release:
tasks.append(import_languages.s(release.id, release.file_path))
result = group(tasks).apply_async()
while not result.ready():
import time
time.sleep(0.1)
return redirect(url_for("todo.view_editor"))
@action("DANGER: Import screenshots from Git")
def import_screenshots():
packages = Package.query \