Skip to content

Commit 57033b1

Browse files
committed
add guardian to allow creating per-project permissions
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 4e3d25d commit 57033b1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎patchwork/admin.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from django.contrib.auth.models import User
99
from django.db.models import Prefetch
1010

11+
from guardian.admin import GuardedModelAdmin
12+
1113
from patchwork.models import Bundle
1214
from patchwork.models import Check
1315
from patchwork.models import Cover
@@ -44,7 +46,7 @@ class DelegationRuleInline(admin.TabularInline):
4446
fields = ('path', 'user', 'priority')
4547

4648

47-
class ProjectAdmin(admin.ModelAdmin):
49+
class ProjectAdmin(GuardedModelAdmin):
4850
list_display = ('name', 'linkname', 'listid', 'listemail')
4951
inlines = [
5052
DelegationRuleInline,

‎patchwork/settings/base.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'django.contrib.sites',
2323
'django.contrib.admin',
2424
'django.contrib.staticfiles',
25+
'guardian',
2526
'patchwork',
2627
]
2728

@@ -71,6 +72,11 @@
7172
},
7273
]
7374

75+
AUTHENTICATION_BACKENDS = [
76+
'django.contrib.auth.backends.ModelBackend',
77+
'guardian.backends.ObjectPermissionBackend',
78+
]
79+
7480
FORM_RENDERER = 'patchwork.forms.PatchworkTableRenderer'
7581

7682
# TODO(stephenfin): Consider changing to BigAutoField when we drop support for

0 commit comments

Comments
 (0)