parent
ff323a7e25
commit
5a7592c222
9 changed files with 239 additions and 77 deletions
@ -0,0 +1,19 @@ |
||||
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 |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
print('---------------------------------------') |
||||
print('Generating permission groups...') |
||||
print('---------------------------------------') |
||||
|
||||
|
||||
Group.objects.create(name='Исполнители') |
||||
Group.objects.create(name='Заказчики') |
||||
@ -0,0 +1,52 @@ |
||||
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 projects.models import Realty, BuildingClassfication, ConstructionType |
||||
from users.models import User |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
print('---------------------------------------') |
||||
print('Generating realties...') |
||||
print('---------------------------------------') |
||||
|
||||
|
||||
# # Fields: |
||||
# |
||||
# |
||||
# ('building_classification', 'Relation? True', 'Null? False', '(relation)', 'Hidden? False'), |
||||
# ('construction_type', 'Relation? True', 'Null? False', '(relation)', 'Hidden? False'), |
||||
# ('user', 'Relation? True', 'Null? False', '(relation)', 'Hidden? False'), |
||||
# |
||||
# ('projects', 'Relation? True', 'Null? True', '(relation)', 'Hidden? False'), |
||||
# ('location', 'Relation? True', 'Null? True', '(relation)', 'Hidden? False'), |
||||
# |
||||
# |
||||
# |
||||
# ('name', 'Relation? False', 'Null? False', 'Blank? False', 'Hidden? False'), |
||||
|
||||
|
||||
|
||||
_.times(lambda i: BuildingClassfication.objects.create(name='Build. classif. %s' % i), 50) |
||||
_.times(lambda i: ConstructionType.objects.create(name='Constr. type %s' % i), 50) |
||||
|
||||
|
||||
def create_realty(i): |
||||
realty = Realty(name='Realty %s' % i) |
||||
|
||||
realty.building_classification = BuildingClassfication.objects.order_by('?').first() |
||||
realty.construction_type = ConstructionType.objects.order_by('?').first() |
||||
realty.location = Location.objects.root_nodes()[0].get_descendants().order_by('?').first() |
||||
realty.user = User.objects.filter(groups__name='Заказчики', is_active=True, is_superuser=False).order_by('?').first() |
||||
|
||||
realty.save() |
||||
return realty |
||||
|
||||
_.times(create_realty, 100) |
||||
@ -0,0 +1,18 @@ |
||||
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 users.models import User |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
print('---------------------------------------') |
||||
print('Generating superusers...') |
||||
print('---------------------------------------') |
||||
|
||||
User.objects.create_superuser('admin@example.com', '123456') |
||||
Loading…
Reference in new issue