mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add remind_video_url() admin action
This commit is contained in:
parent
55b5893cce
commit
02b7d55c2d
@ -21,7 +21,7 @@ from typing import List
|
|||||||
import requests
|
import requests
|
||||||
from celery import group
|
from celery import group
|
||||||
from flask import *
|
from flask import *
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_, and_
|
||||||
|
|
||||||
from app.models import *
|
from app.models import *
|
||||||
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
|
||||||
@ -206,7 +206,7 @@ def remind_wip():
|
|||||||
packages = [pkg[0] for pkg in packages]
|
packages = [pkg[0] for pkg in packages]
|
||||||
packages_list = _package_list(packages)
|
packages_list = _package_list(packages)
|
||||||
havent = "haven't" if len(packages) > 1 else "hasn't"
|
havent = "haven't" if len(packages) > 1 else "hasn't"
|
||||||
if len(packages_list) + 54 > 100:
|
if len(packages_list) + 54 > 100:
|
||||||
packages_list = packages_list[0:(100-54-1)] + "…"
|
packages_list = packages_list[0:(100-54-1)] + "…"
|
||||||
|
|
||||||
addNotification(user, system_user, NotificationType.PACKAGE_APPROVAL,
|
addNotification(user, system_user, NotificationType.PACKAGE_APPROVAL,
|
||||||
@ -288,3 +288,26 @@ def delete_inactive_users():
|
|||||||
for user in users:
|
for user in users:
|
||||||
db.session.delete(user)
|
db.session.delete(user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@action("Send Video URL notification")
|
||||||
|
def remind_video_url():
|
||||||
|
users = User.query.filter(User.maintained_packages.any(
|
||||||
|
and_(Package.video_url.is_(None), Package.type==PackageType.GAME, Package.state==PackageState.APPROVED)))
|
||||||
|
system_user = get_system_user()
|
||||||
|
for user in users:
|
||||||
|
packages = db.session.query(Package.title).filter(
|
||||||
|
or_(Package.author==user, Package.maintainers.any(User.id==user.id)),
|
||||||
|
Package.video_url.is_(None),
|
||||||
|
Package.type == PackageType.GAME,
|
||||||
|
Package.state == PackageState.APPROVED) \
|
||||||
|
.all()
|
||||||
|
|
||||||
|
packages = [pkg[0] for pkg in packages]
|
||||||
|
packages_list = _package_list(packages)
|
||||||
|
|
||||||
|
addNotification(user, system_user, NotificationType.PACKAGE_APPROVAL,
|
||||||
|
f"You should add a video to {packages_list}",
|
||||||
|
url_for('users.profile', username=user.username))
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user