From 749d16ee89e5a8ffd791a750ba84a622795aea7e Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 16 Feb 2021 22:00:42 +0100 Subject: [PATCH] Admin | Udelej orga priradi skupinu a ne opravneni Skupina org ma opravneni org by default, tedy se podedi. --- seminar/admin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index 9f780cf2..4ce6ded5 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from django.contrib.auth.models import Permission +from django.contrib.auth.models import Group from django.db import models from django.forms import widgets @@ -32,11 +32,12 @@ class OsobaAdmin(admin.ModelAdmin): synchronizuj_maily.short_description = "Synchronizuj vybraným osobám e-maily do uživatelů" def udelej_orgem(self,request,queryset): - org_perm = Permission.objects.filter(codename__exact='org').first() + org_group = Group.objects.get(name='org') print(queryset) for o in queryset: user = o.user - user.user_permissions.add(org_perm) + print(user) + user.groups.add(org_group) user.is_staff = True user.save() org = m.Organizator.objects.create(osoba=o)