diff options
author | 2019-10-18 12:34:09 +0200 | |
---|---|---|
committer | 2019-10-18 12:34:09 +0200 | |
commit | 6670a3ba48dad0b2e6e79d77d780c5ee77773e3e (patch) | |
tree | 30fdc507353e902f194fa84bfcb7516ea72903fd /pydis_site/settings.py | |
parent | Prevent double active infractions with constraint (diff) | |
parent | Add Code of Conduct to navbar submenu (diff) |
Merge branch 'master' into active-infractions-validation
Diffstat (limited to 'pydis_site/settings.py')
-rw-r--r-- | pydis_site/settings.py | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 4534f54b..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) ) @@ -82,6 +87,12 @@ INSTALLED_APPS = [ 'django.contrib.sites.apps.SitesConfig', 'django.contrib.staticfiles', + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + + 'allauth.socialaccount.providers.discord', + 'crispy_forms', 'django_crispy_bulma', 'django_hosts', @@ -265,6 +276,16 @@ LOGGING = { } } +# Django Messages framework config + +MESSAGE_TAGS = { + messages.DEBUG: 'primary', + messages.INFO: 'info', + messages.SUCCESS: 'success', + messages.WARNING: 'warning', + messages.ERROR: 'danger', +} + # Custom settings for Crispyforms CRISPY_ALLOWED_TEMPLATE_PACKS = ( "bootstrap", @@ -278,9 +299,18 @@ CRISPY_TEMPLATE_PACK = "bulma" # Custom settings for django-simple-bulma BULMA_SETTINGS = { - "variables": { - "green": "#21c65c", # Accessibility: Better contrast with the light text - "primary": "#7289DA", + "variables": { # If you update these colours, please update the notification.css file + "primary": "#7289DA", # Discord blurple + + "orange": "#ffb39b", # Bulma default, but at a saturation of 100 + "yellow": "#ffea9b", # Bulma default, but at a saturation of 100 + "green": "#7fd19c", # Bulma default, but at a saturation of 100 + "turquoise": "#7289DA", # Blurple, because Bulma uses this as the default primary + "cyan": "#91cbee", # Bulma default, but at a saturation of 100 + "blue": "#86a7dc", # Bulma default, but at a saturation of 100 + "purple": "#b86bff", # Bulma default, but at a saturation of 100 + "red": "#ffafc2", # Bulma default, but at a saturation of 80 + "link": "$primary", "dimensions": "16 24 32 48 64 96 128 256 512", # Possible image dimensions @@ -347,3 +377,35 @@ WIKI_MARKDOWN_HTML_ATTRIBUTES = { 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 = ( + # Needed to login by username in Django admin, regardless of `allauth` + 'django.contrib.auth.backends.ModelBackend', + + # `allauth` specific authentication methods, such as login by e-mail + 'allauth.account.auth_backends.AuthenticationBackend', +) + +ACCOUNT_EMAIL_VERIFICATION = "none" # No verification required; we don't use emails for anything +LOGIN_REDIRECT_URL = "home" |