Marginální zlepšení vyrábítka orgů

Podle diskuse na Matrixu
This commit is contained in:
Pavel "LEdoian" Turinsky 2023-06-21 14:45:46 +02:00
parent 01ad1daba9
commit 2cf4d87c6b

View file

@ -2,6 +2,7 @@ from django.contrib import admin
from django.contrib.auth.models import Group
from django_reverse_admin import ReverseModelAdmin
import seminar.models as m
from datetime import datetime
@admin.register(m.Osoba)
@ -22,12 +23,12 @@ class OsobaAdmin(admin.ModelAdmin):
org_group = Group.objects.get(name='org')
print(queryset)
for o in queryset:
if m.Organizator.objects.filter(osoba=o).exists(): continue
user = o.user
print(user)
user.groups.add(org_group)
user.is_staff = True
user.save()
org = m.Organizator.objects.create(osoba=o)
org = m.Organizator.objects.create(osoba=o, organizuje_od=datetime.now())
org.save()
udelej_orgem.short_description = "Udělej vybraných osob organizátory"