Web M&M
https://mam.matfyz.cz
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
1 year ago
|
from django.core.management.base import BaseCommand
|
||
|
import logging
|
||
|
|
||
|
from django.contrib.auth.models import User, Group
|
||
|
import seminar.models as m
|
||
|
from datetime import date
|
||
|
|
||
|
logger = logging.getLogger(__name__)
|
||
|
|
||
|
class Command(BaseCommand):
|
||
|
def handle(self, *args, **options):
|
||
|
org_group = Group.objects.get(name='org')
|
||
|
stari_orgove = set()
|
||
|
nesparovani = set()
|
||
|
for u in User.objects.all():
|
||
|
if u.is_staff or u in org_group.user_set.all() or u.has_perm('auth.org'):
|
||
|
# Dohledáme orga
|
||
|
# Používáme .filter, protože se nemusí najít
|
||
|
orgove = m.Organizator.objects.filter(osoba__user=u)
|
||
|
if orgove.count() != 1:
|
||
|
nesparovani.add(u)
|
||
|
org = orgove.first()
|
||
|
# Pokud už není aktivní, tak ho vypíšeme
|
||
|
# Porovnáváme data, protože neřeší časové zóny (datetime.now není tz-aware)
|
||
|
if org.organizuje_do is not None and org.organizuje_do.date() < date.today():
|
||
|
stari_orgove.add(org)
|
||
|
if len(nesparovani) > 0:
|
||
|
print('Účty s právy, ke kterým neznáme orga:')
|
||
|
for x in nesparovani:
|
||
|
print(f'\t{x}')
|
||
|
if len(stari_orgove) > 0:
|
||
|
print('Staří orgové, kterým zóstala práva a neměla:')
|
||
|
for x in stari_orgove:
|
||
|
print(f'\t{x}')
|