diff --git a/archilance/management/commands/generate_projects.py b/archilance/management/commands/generate_projects.py new file mode 100644 index 0000000..0ab0bc8 --- /dev/null +++ b/archilance/management/commands/generate_projects.py @@ -0,0 +1,68 @@ +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 projects.models import Project, CURRENCIES, TERMS + + +class Command(BaseCommand): + def handle(self, *args, **options): + print('---------------------------------------') + print('Generating projects...') + print('---------------------------------------') + + + # Fields: + # + # [('files', True), + # ('answers', True), + # ('order', True), + # ('candidates', True), + # ('reviews', True), + # ('customer', True), + # ('realty', True), + # ('specialization', True), + # + # ('id', False), + # ('budget', False), + # ('budget_by_agreement', False), + # ('created', False), + # ('cro', False), + # ('currency', False), + # ('name', False), + # ('price_and_term_required', False), + # ('deal_type', False), + # ('term', False), + # ('term_type', False), + # ('text', False), + # ('work_type', False), + # ('state', False)] + + + def create_project(i): + # project = Project() + # pr.specialization = + # pr. + + return Project.objects.create( + budget=util.random_amount(), + budget_by_agreement=_.sample((True, False)), + created=util.random_date(), + cro=_.sample((True, False)), + currency=_.sample(CURRENCIES)[0], + name='Project %s' % i, + price_and_term_required=_.sample((True, False)), + deal_type=_.sample(Project.DEAL_TYPES)[0], + term=_.random(0, 20), + term_type=_.sample(TERMS)[0], + text='Project %s text' % i, + work_type=_.sample(Project.WORK_TYPES)[0], + state='active', + + ) + + projects = _.times(create_project, 1000) diff --git a/archilance/util.py b/archilance/util.py index eb6698e..49b766e 100644 --- a/archilance/util.py +++ b/archilance/util.py @@ -1,4 +1,5 @@ from django.utils import timezone +import pydash as _; _.map = _.map_; _.filter = _.filter_ import random diff --git a/projects/models.py b/projects/models.py index 6eea696..f166d57 100644 --- a/projects/models.py +++ b/projects/models.py @@ -61,12 +61,12 @@ class Project(models.Model): (1, 'Проектирование'), (2, 'Техническое сопровождение') ) - + DEAL_TYPES = ( ('secure_deal', 'Безопасная сделка (с резервированием бюджета) '), ('direct_payment', 'Прямая оплата Исполнителю на его кошелек/счет'), ) - + STATES = ( ('active', 'Активный'), ('trashed', 'В корзине'),