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.
32 lines
1.3 KiB
32 lines
1.3 KiB
from django.contrib.auth.models import Group, Permission
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.core.management import BaseCommand
|
|
from django.utils import timezone
|
|
import pydash as _; _.map = _.map_; _.filter = _.filter_
|
|
import random
|
|
|
|
from archilance import util
|
|
from common.models import Location
|
|
from specializations.models import Specialization
|
|
from users.models import User, GENDERS, Team
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
print('---------------------------------------')
|
|
print('Generating teams...')
|
|
print('---------------------------------------')
|
|
|
|
|
|
# ('owner', 'Relation? True', 'Null? True', '(relation)', 'Hidden? False'),
|
|
# ('users', 'Relation? True', 'Null? False', '(relation)', 'Hidden? False'),
|
|
#
|
|
# ('name', 'Relation? False', 'Null? False', 'Blank? False', 'Hidden? False'),
|
|
|
|
|
|
contractors = User.contractor_objects.order_by('?')
|
|
contractors = contractors[:contractors.count() // 2]
|
|
|
|
for contr in contractors:
|
|
team = Team.objects.create(name="%s's team" % contr.username, owner=contr)
|
|
team.users = User.contractor_objects.filter(team=None)[:_.random(1, 4)]
|
|
|