mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +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:
|
||||
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):
|
||||
if not user.is_authenticated:
|
||||
return False
|
||||
|
||||
if type(state) == str:
|
||||
state = PackageState[perm]
|
||||
state = PackageState[state]
|
||||
elif type(state) != PackageState:
|
||||
raise Exception("Unknown state given to Package.canMoveToState()")
|
||||
|
||||
@ -845,8 +853,10 @@ class Package(db.Model):
|
||||
if not self.checkPerm(user, requiredPerm):
|
||||
return False
|
||||
|
||||
if state == PackageState.APPROVED and \
|
||||
("Other" in self.license.name or "Other" in self.media_license.name):
|
||||
if state == PackageState.APPROVED and ("Other" in self.license.name or "Other" in self.media_license.name):
|
||||
return False
|
||||
|
||||
if self.getMissingHardDependenciesQuery().count() > 0:
|
||||
return False
|
||||
|
||||
needsScreenshot = \
|
||||
|
@ -29,9 +29,14 @@
|
||||
A release is required before this package can be approved.
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
|
||||
{% 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." %}
|
||||
|
||||
{% 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 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." %}
|
||||
|
Loading…
Reference in New Issue
Block a user