Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pydis_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
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)
)
Expand Down Expand Up @@ -373,6 +378,25 @@
'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 = (
Expand Down