mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-13 02:53:51 +01:00
Require packages to have all hard deps in approval process
This commit is contained in:
parent
15821fe796
commit
15063d92cd
@ -826,13 +826,21 @@ class Package(db.Model):
|
|||||||
else:
|
else:
|
||||||
raise Exception("Permission {} is not related to packages".format(perm.name))
|
raise Exception("Permission {} is not related to packages".format(perm.name))
|
||||||
|
|
||||||
|
def getMissingHardDependenciesQuery(self):
|
||||||
|
return MetaPackage.query \
|
||||||
|
.filter(~ MetaPackage.packages.any(state=PackageState.APPROVED)) \
|
||||||
|
.filter(MetaPackage.dependencies.any(optional=False, depender=self)) \
|
||||||
|
.order_by(db.asc(MetaPackage.name))
|
||||||
|
|
||||||
|
def getMissingHardDependencies(self):
|
||||||
|
return [mp.name for mp in self.getMissingHardDependenciesQuery().all()]
|
||||||
|
|
||||||
def canMoveToState(self, user, state):
|
def canMoveToState(self, user, state):
|
||||||
if not user.is_authenticated:
|
if not user.is_authenticated:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if type(state) == str:
|
if type(state) == str:
|
||||||
state = PackageState[perm]
|
state = PackageState[state]
|
||||||
elif type(state) != PackageState:
|
elif type(state) != PackageState:
|
||||||
raise Exception("Unknown state given to Package.canMoveToState()")
|
raise Exception("Unknown state given to Package.canMoveToState()")
|
||||||
|
|
||||||
@ -845,8 +853,10 @@ class Package(db.Model):
|
|||||||
if not self.checkPerm(user, requiredPerm):
|
if not self.checkPerm(user, requiredPerm):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if state == PackageState.APPROVED and \
|
if state == PackageState.APPROVED and ("Other" in self.license.name or "Other" in self.media_license.name):
|
||||||
("Other" in self.license.name or "Other" in self.media_license.name):
|
return False
|
||||||
|
|
||||||
|
if self.getMissingHardDependenciesQuery().count() > 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
needsScreenshot = \
|
needsScreenshot = \
|
||||||
|
@ -29,9 +29,14 @@
|
|||||||
A release is required before this package can be approved.
|
A release is required before this package can be approved.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endset %}
|
{% endset %}
|
||||||
|
|
||||||
{% elif (package.type == package.type.GAME or package.type == package.type.TXP) and package.screenshots.count() == 0 %}
|
{% elif (package.type == package.type.GAME or package.type == package.type.TXP) and package.screenshots.count() == 0 %}
|
||||||
{% set message = "You need to add at least one screenshot." %}
|
{% set message = "You need to add at least one screenshot." %}
|
||||||
|
|
||||||
|
{% elif package.getMissingHardDependenciesQuery().count() > 0 %}
|
||||||
|
{% set deps = package.getMissingHardDependencies() | join(", ") %}
|
||||||
|
{% set message = "The following hard dependencies need to be added to ContentDB first: " + deps %}
|
||||||
|
|
||||||
{% elif topic_error_lvl == "danger" %}
|
{% elif topic_error_lvl == "danger" %}
|
||||||
{% elif package.state == package.state.READY_FOR_REVIEW and ("Other" in package.license.name or "Other" in package.media_license.name) %}
|
{% elif package.state == package.state.READY_FOR_REVIEW and ("Other" in package.license.name or "Other" in package.media_license.name) %}
|
||||||
{% set message = "Please wait for the license to be added to CDB." %}
|
{% set message = "Please wait for the license to be added to CDB." %}
|
||||||
|
Loading…
Reference in New Issue
Block a user