Browse Source

Přidání skupin org a resitel testdatům

export_seznamu_prednasek
Jonas Havelka 3 years ago
parent
commit
bc07d195bf
  1. 5
      seminar/testutils.py

5
seminar/testutils.py

@ -3,6 +3,7 @@
import datetime
from django.contrib.auth.models import Permission
from django.contrib.auth.models import Group
from pytz import timezone
import random
import lorem
@ -129,6 +130,7 @@ def gen_resitele(rnd, osoby, skoly):
resitele = []
x = 0
resitel_perm = Permission.objects.filter(codename__exact='resitel').first()
resitel_group = Group.objects.filter(name__exact='resitel').first()
for os in osoby:
rand = rnd.randint(0, 8)
if not (rand % 8 == 0):
@ -141,6 +143,7 @@ def gen_resitele(rnd, osoby, skoly):
os.user = user
os.save()
os.user.user_permissions.add(resitel_perm)
os.user.groups.add(resitel_group)
resitele.append(Resitel.objects.create(osoba=os, skola=rnd.choice(skoly),
rok_maturity=os.datum_narozeni.year + rnd.randint(18, 21),
zasilat=rnd.choice(Resitel.ZASILAT_CHOICES)[0]))
@ -165,6 +168,7 @@ def gen_organizatori(rnd, osoby, last_rocnik):
x = 0
org_perm = Permission.objects.filter(codename__exact='org').first()
org_group = Group.objects.filter(name__exact='org').first()
for os in osoby:
rand = rnd.randint(0, 8)
if (rand % 8 == 0):
@ -200,6 +204,7 @@ def gen_organizatori(rnd, osoby, last_rocnik):
os.user = user
os.save()
os.user.user_permissions.add(org_perm)
os.user.groups.add(org_group)
os.user.is_staff = True
os.user.save()
organizatori.append(Organizator.objects.create(osoba=os,

Loading…
Cancel
Save