From 94931900e51d51ed15158979a70b0d90e9d40ac8 Mon Sep 17 00:00:00 2001 From: Evert Date: Mon, 11 Dec 2017 19:23:19 +0200 Subject: [PATCH] Install django-guardian --- EpisodesCommunity/settings.py | 2 ++ LandingPage/admin.py | 7 ++++++- requirements.txt | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/EpisodesCommunity/settings.py b/EpisodesCommunity/settings.py index 63e691d..89949cd 100644 --- a/EpisodesCommunity/settings.py +++ b/EpisodesCommunity/settings.py @@ -44,6 +44,7 @@ ALLOWED_HOSTS = [] AUTHENTICATION_BACKENDS = ( 'LandingPage.backends.OAuthBackend', + 'guardian.backends.ObjectPermissionBackend', 'django.contrib.auth.backends.ModelBackend', ) @@ -59,6 +60,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'guardian', ] MIDDLEWARE = [ diff --git a/LandingPage/admin.py b/LandingPage/admin.py index 44f4c55..b772b2c 100644 --- a/LandingPage/admin.py +++ b/LandingPage/admin.py @@ -3,6 +3,8 @@ from django.contrib.auth.admin import UserAdmin from .models import * from .forms import SpecialUserChangeForm +from guardian.admin import GuardedModelAdmin + class SpecialUserAdmin(UserAdmin): form = SpecialUserChangeForm @@ -10,8 +12,11 @@ class SpecialUserAdmin(UserAdmin): (None, {'fields': ('display_name',)}), ) +class ShowAdmin(GuardedModelAdmin): + pass + # Register your models here. -admin.site.register(Show) +admin.site.register(Show, ShowAdmin) admin.site.register(User, SpecialUserAdmin) admin.site.register(Ban) admin.site.register(ShowModerator) diff --git a/requirements.txt b/requirements.txt index 2b00bcd..71ad7c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ Django==1.11.4 Pillow==4.2.1 dj-database-url==0.4.2 requests==2.18.4 +django-guardian==1.4.9