mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Fix crash on unimplemented is_
Whilst is_ is documented, it appears to be unimplemented for certain objects.
This commit is contained in:
parent
e7f5f7055d
commit
766765b1f8
@ -107,7 +107,7 @@ def import_screenshots():
|
|||||||
packages = Package.query \
|
packages = Package.query \
|
||||||
.filter(Package.state != PackageState.DELETED) \
|
.filter(Package.state != PackageState.DELETED) \
|
||||||
.outerjoin(PackageScreenshot, Package.id == PackageScreenshot.package_id) \
|
.outerjoin(PackageScreenshot, Package.id == PackageScreenshot.package_id) \
|
||||||
.filter(PackageScreenshot.id.is_(None)) \
|
.filter(PackageScreenshot.id==None) \
|
||||||
.all()
|
.all()
|
||||||
for package in packages:
|
for package in packages:
|
||||||
importRepoScreenshot.delay(package.id)
|
importRepoScreenshot.delay(package.id)
|
||||||
@ -293,12 +293,12 @@ def delete_inactive_users():
|
|||||||
@action("Send Video URL notification")
|
@action("Send Video URL notification")
|
||||||
def remind_video_url():
|
def remind_video_url():
|
||||||
users = User.query.filter(User.maintained_packages.any(
|
users = User.query.filter(User.maintained_packages.any(
|
||||||
and_(Package.video_url.is_(None), Package.type==PackageType.GAME, Package.state==PackageState.APPROVED)))
|
and_(Package.video_url==None, Package.type==PackageType.GAME, Package.state==PackageState.APPROVED)))
|
||||||
system_user = get_system_user()
|
system_user = get_system_user()
|
||||||
for user in users:
|
for user in users:
|
||||||
packages = db.session.query(Package.title).filter(
|
packages = db.session.query(Package.title).filter(
|
||||||
or_(Package.author==user, Package.maintainers.any(User.id==user.id)),
|
or_(Package.author==user, Package.maintainers.any(User.id==user.id)),
|
||||||
Package.video_url.is_(None),
|
Package.video_url==None,
|
||||||
Package.type == PackageType.GAME,
|
Package.type == PackageType.GAME,
|
||||||
Package.state == PackageState.APPROVED) \
|
Package.state == PackageState.APPROVED) \
|
||||||
.all()
|
.all()
|
||||||
|
@ -96,7 +96,7 @@ def webhook():
|
|||||||
|
|
||||||
# Get all tokens for package
|
# Get all tokens for package
|
||||||
tokens_query = APIToken.query.filter(or_(APIToken.package==package,
|
tokens_query = APIToken.query.filter(or_(APIToken.package==package,
|
||||||
and_(APIToken.package.is_(None), APIToken.owner==package.author)))
|
and_(APIToken.package==None, APIToken.owner==package.author)))
|
||||||
|
|
||||||
possible_tokens = tokens_query.all()
|
possible_tokens = tokens_query.all()
|
||||||
actual_token = None
|
actual_token = None
|
||||||
|
@ -307,7 +307,7 @@ def mtver_support():
|
|||||||
current_stable = MinetestRelease.query.filter(~MinetestRelease.name.like("%-dev")).order_by(db.desc(MinetestRelease.id)).first()
|
current_stable = MinetestRelease.query.filter(~MinetestRelease.name.like("%-dev")).order_by(db.desc(MinetestRelease.id)).first()
|
||||||
|
|
||||||
query = db.session.query(Package) \
|
query = db.session.query(Package) \
|
||||||
.filter(~Package.releases.any(or_(PackageRelease.max_rel.is_(None), PackageRelease.max_rel == current_stable))) \
|
.filter(~Package.releases.any(or_(PackageRelease.max_rel==None, PackageRelease.max_rel == current_stable))) \
|
||||||
.filter(Package.state == PackageState.APPROVED)
|
.filter(Package.state == PackageState.APPROVED)
|
||||||
|
|
||||||
if is_mtm_only:
|
if is_mtm_only:
|
||||||
|
@ -19,7 +19,7 @@ def validate_package_for_approval(package: Package) -> List[ValidationError]:
|
|||||||
Package.name == normalised_name + "_game"))).count() > 0:
|
Package.name == normalised_name + "_game"))).count() > 0:
|
||||||
retval.append(("danger", lazy_gettext("A package already exists with this name. Please see Policy and Guidance 3")))
|
retval.append(("danger", lazy_gettext("A package already exists with this name. Please see Policy and Guidance 3")))
|
||||||
|
|
||||||
if package.releases.filter(PackageRelease.task_id.is_(None)).count() == 0:
|
if package.releases.filter(PackageRelease.task_id==None).count() == 0:
|
||||||
retval.append(("danger", lazy_gettext("A release is required before this package can be approved.")))
|
retval.append(("danger", lazy_gettext("A release is required before this package can be approved.")))
|
||||||
# Don't bother validating any more until we have a release
|
# Don't bother validating any more until we have a release
|
||||||
return retval
|
return retval
|
||||||
|
@ -748,7 +748,7 @@ class Package(db.Model):
|
|||||||
(self.type == self.type.GAME or self.type == self.type.TXP) and \
|
(self.type == self.type.GAME or self.type == self.type.TXP) and \
|
||||||
self.screenshots.count() == 0
|
self.screenshots.count() == 0
|
||||||
|
|
||||||
return self.releases.filter(PackageRelease.task_id.is_(None)).count() > 0 and not needsScreenshot
|
return self.releases.filter(PackageRelease.task_id==None).count() > 0 and not needsScreenshot
|
||||||
|
|
||||||
elif state == PackageState.CHANGES_NEEDED:
|
elif state == PackageState.CHANGES_NEEDED:
|
||||||
return self.checkPerm(user, Permission.APPROVE_NEW)
|
return self.checkPerm(user, Permission.APPROVE_NEW)
|
||||||
|
@ -109,9 +109,9 @@ class QueryBuilder:
|
|||||||
|
|
||||||
if self.version:
|
if self.version:
|
||||||
releases_query = releases_query \
|
releases_query = releases_query \
|
||||||
.filter(or_(PackageRelease.min_rel_id.is_(None),
|
.filter(or_(PackageRelease.min_rel_id==None,
|
||||||
PackageRelease.min_rel_id <= self.version.id)) \
|
PackageRelease.min_rel_id <= self.version.id)) \
|
||||||
.filter(or_(PackageRelease.max_rel_id.is_(None),
|
.filter(or_(PackageRelease.max_rel_id==None,
|
||||||
PackageRelease.max_rel_id >= self.version.id))
|
PackageRelease.max_rel_id >= self.version.id))
|
||||||
|
|
||||||
return releases_query.all()
|
return releases_query.all()
|
||||||
@ -173,16 +173,16 @@ class QueryBuilder:
|
|||||||
query = query.filter(Package.media_license.has(License.is_foss == True))
|
query = query.filter(Package.media_license.has(License.is_foss == True))
|
||||||
|
|
||||||
if self.hide_wip:
|
if self.hide_wip:
|
||||||
query = query.filter(or_(Package.dev_state.is_(None), Package.dev_state != PackageDevState.WIP))
|
query = query.filter(or_(Package.dev_state==None, Package.dev_state != PackageDevState.WIP))
|
||||||
if self.hide_deprecated:
|
if self.hide_deprecated:
|
||||||
query = query.filter(or_(Package.dev_state.is_(None), Package.dev_state != PackageDevState.DEPRECATED))
|
query = query.filter(or_(Package.dev_state==None, Package.dev_state != PackageDevState.DEPRECATED))
|
||||||
|
|
||||||
if self.version:
|
if self.version:
|
||||||
query = query.join(Package.releases) \
|
query = query.join(Package.releases) \
|
||||||
.filter(PackageRelease.approved == True) \
|
.filter(PackageRelease.approved == True) \
|
||||||
.filter(or_(PackageRelease.min_rel_id.is_(None),
|
.filter(or_(PackageRelease.min_rel_id==None,
|
||||||
PackageRelease.min_rel_id <= self.version.id)) \
|
PackageRelease.min_rel_id <= self.version.id)) \
|
||||||
.filter(or_(PackageRelease.max_rel_id.is_(None),
|
.filter(or_(PackageRelease.max_rel_id==None,
|
||||||
PackageRelease.max_rel_id >= self.version.id))
|
PackageRelease.max_rel_id >= self.version.id))
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
Loading…
Reference in New Issue
Block a user