]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add trusted member rank v1.2.0
authorrubenwardy <rw@rubenwardy.com>
Sun, 27 May 2018 22:53:55 +0000 (23:53 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sun, 27 May 2018 22:56:13 +0000 (23:56 +0100)
app/flatpages/help.md
app/flatpages/help/ranks_permissions.md
app/models.py
migrations/versions/b254f55eadd2_.py [new file with mode: 0644]

index 774aa28907484e24d46927352a6f30fdc1ed5287..7713de8e4b45a2c28efbde00f7350b9999cb5182 100644 (file)
@@ -1,4 +1,4 @@
 title: Help
 
-* [Ranks and Permissions](ranks_permissions)
 * [Package Tags](package_tags)
+* [Ranks and Permissions](ranks_permissions)
index 61b70e363395bd4019a019269c5d3f9083a1b119..39e979b68752e5c7b2070c725e42f6717ab18fad 100644 (file)
@@ -4,6 +4,7 @@ title: Ranks and Permissions
 
 * **New Members** - mostly untrusted, cannot change package meta data or publish releases without approval.
 * **Members** - Trusted to change the meta data of their own packages', but cannot publish releases.
+* **Trusted Members** - Same as above, but can approve their own releases and packages.
 * **Editors** - Trusted to change the meta data of any package, and also make and publish releases.
 * **Moderators** - Same as above, but can manage users.
 * **Admins** - Full access.
@@ -16,6 +17,7 @@ title: Ranks and Permissions
                        <th>Rank</th>
                        <th colspan=2>New Member</th>
                        <th colspan=2>Member</th>
+                       <th colspan=2>Trusted Member</th>
                        <th colspan=2>Editor</th>
                        <th colspan=2>Moderator</th>
                        <th colspan=2>Admin</th>
@@ -41,6 +43,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -54,6 +58,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th></th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -67,6 +73,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -80,6 +88,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -93,6 +103,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -106,6 +118,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -119,6 +133,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -132,6 +148,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -145,6 +163,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th></th> <!-- member -->
                        <th></th>
+                       <th>✓</th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th>✓</th>
                        <th>✓</th> <!-- moderator -->
@@ -158,6 +178,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th></th> <!-- member -->
                        <th></th>
+                       <th></th> <!-- trusted member -->
+                       <th></th>
                        <th></th> <!-- editor -->
                        <th></th>
                        <th></th> <!-- moderator -->
@@ -171,6 +193,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th>✓</th> <!-- member -->
                        <th></th>
+                       <th></th> <!-- trusted member -->
+                       <th></th>
                        <th>✓</th> <!-- editor -->
                        <th></th>
                        <th>✓</th> <!-- moderator -->
@@ -184,6 +208,8 @@ title: Ranks and Permissions
                        <th></th>
                        <th></th> <!-- member -->
                        <th></th>
+                       <th></th> <!-- trusted member -->
+                       <th></th>
                        <th></th> <!-- editor -->
                        <th></th>
                        <th>✓<sup>3</sup></th> <!-- moderator -->
index e79b00fc8042294ba12f025512d6589da9396d37..d414589a9843d6cb7e1150d7bc827b1980b51c10 100644 (file)
@@ -31,13 +31,14 @@ migrate = Migrate(app, db)
 
 
 class UserRank(enum.Enum):
-       BANNED     = 0
-       NOT_JOINED = 1
-       NEW_MEMBER = 2
-       MEMBER     = 3
-       EDITOR     = 4
-       MODERATOR  = 5
-       ADMIN      = 6
+       BANNED         = 0
+       NOT_JOINED     = 1
+       NEW_MEMBER     = 2
+       MEMBER         = 3
+       TRUSTED_MEMBER = 4
+       EDITOR         = 5
+       MODERATOR      = 6
+       ADMIN          = 7
 
        def atLeast(self, min):
                return self.value >= min.value
@@ -460,11 +461,14 @@ class Package(db.Model):
                        else:
                                return user.rank.atLeast(UserRank.EDITOR)
 
-               # Editors can change authors, approve new packages, and approve releases
-               elif perm == Permission.CHANGE_AUTHOR or perm == Permission.APPROVE_NEW \
-                               or perm == Permission.APPROVE_RELEASE or perm == Permission.APPROVE_SCREENSHOT:
+               # Editors can change authors
+               elif perm == Permission.CHANGE_AUTHOR:
                        return user.rank.atLeast(UserRank.EDITOR)
 
+               elif perm == Permission.APPROVE_NEW or perm == Permission.APPROVE_RELEASE \
+                               or perm == Permission.APPROVE_SCREENSHOT:
+                       return user.rank.atLeast(UserRank.TRUSTED_MEMBER if isOwner else UserRank.EDITOR)
+
                # Moderators can delete packages
                elif perm == Permission.DELETE_PACKAGE or perm == Permission.CHANGE_RELEASE_URL:
                        return user.rank.atLeast(UserRank.MODERATOR)
diff --git a/migrations/versions/b254f55eadd2_.py b/migrations/versions/b254f55eadd2_.py
new file mode 100644 (file)
index 0000000..601ac4a
--- /dev/null
@@ -0,0 +1,29 @@
+"""empty message
+
+Revision ID: b254f55eadd2
+Revises: 4e482c47e519
+Create Date: 2018-05-27 23:51:11.008936
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = 'b254f55eadd2'
+down_revision = '4e482c47e519'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    conn = op.get_bind()
+    conn.execute("ALTER TYPE userrank ADD VALUE 'TRUSTED_MEMBER'")
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    pass
+    # ### end Alembic commands ###