aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-10-14 23:27:33 +1000
committerGravatar GitHub <[email protected]>2019-10-14 23:27:33 +1000
commite6f4573cbba0665e52b904c89555df4c47eb1681 (patch)
tree9726126d4281277dc0e8b5d3fb02ef60fec65a21 /pydis_site
parentDjango Allauth (#201) (#274) (diff)
parentRemove accidental comment before docstring (diff)
Wiki: Permissions hotfix (#285)
Wiki: Permissions hotfix
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/settings.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/pydis_site/settings.py b/pydis_site/settings.py
index 9c88a056..56ac0a1d 100644
--- a/pydis_site/settings.py
+++ b/pydis_site/settings.py
@@ -13,10 +13,15 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
import os
import secrets
import sys
+import typing
import environ
from django.contrib.messages import constants as messages
+if typing.TYPE_CHECKING:
+ from django.contrib.auth.models import User
+ from wiki.models import Article
+
env = environ.Env(
DEBUG=(bool, False)
)
@@ -373,6 +378,25 @@ WIKI_MARKDOWN_HTML_WHITELIST = [
'article', 'section', 'button'
]
+
+# Wiki permissions
+
+
+def WIKI_CAN_DELETE(article: "Article", user: "User") -> bool: # noqa: N802
+ """Check whether a user may delete an article."""
+ return user.has_perm('wiki.delete_article')
+
+
+def WIKI_CAN_MODERATE(article: "Article", user: "User") -> bool: # noqa: N802
+ """Check whether a user may moderate an article."""
+ return user.has_perm('wiki.moderate')
+
+
+def WIKI_CAN_WRITE(article: "Article", user: "User") -> bool: # noqa: N802
+ """Check whether a user may create or edit an article."""
+ return user.has_perm('wiki.change_article')
+
+
# Django Allauth stuff
AUTHENTICATION_BACKENDS = (