diff --git a/app/models.py b/app/models.py
index d24c2189..839bc49f 100644
--- a/app/models.py
+++ b/app/models.py
@@ -35,6 +35,12 @@ class Permission(enum.Enum):
APPROVE_NEW = "APPROVE_NEW"
CHANGE_RELEASE_URL = "CHANGE_RELEASE_URL"
+ def check(self, user):
+ if self == Permission.APPROVE_NEW:
+ return user.rank.atLeast(UserRank.EDITOR)
+ else:
+ raise Exception("Non-global permission checked globally. Use Package.checkPerm or User.checkPerm instead.")
+
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
@@ -102,6 +108,8 @@ class Package(db.Model):
desc = db.Column(db.Text, nullable=True)
type = db.Column(db.Enum(PackageType))
+ approved = db.Column(db.Boolean, nullable=False, default=False)
+
# Downloads
repo = db.Column(db.String(200), nullable=True)
website = db.Column(db.String(200), nullable=True)
@@ -122,6 +130,11 @@ class Package(db.Model):
type=self.type.toName(),
author=self.author.username, name=self.name)
+ def getApproveURL(self):
+ return url_for("approve_package_page",
+ type=self.type.toName(),
+ author=self.author.username, name=self.name)
+
def getCreateReleaseURL(self):
return url_for("create_release_page",
type=self.type.toName(),
diff --git a/app/templates/package_details.html b/app/templates/package_details.html
index 58facbc8..d0d13e11 100644
--- a/app/templates/package_details.html
+++ b/app/templates/package_details.html
@@ -5,6 +5,17 @@
{% endblock %}
{% block content %}
+ {% if not package.approved %}
+
+
+ This package needs to be approved before it can be found.
+ {% if package.checkPerm(current_user, "APPROVE_NEW") %}
+
Approve
+ {% endif %}
+
+
+ {% endif %}
+
{{ package.title }} by {{ package.author.display_name }}