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