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.
41 lines
1.5 KiB
41 lines
1.5 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 projects.models import Project, Portfolio
|
|
from specializations.models import Specialization
|
|
from users.models import User, GENDERS, Team
|
|
from reviews.models import Review
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
print('---------------------------------------')
|
|
print('Generating reviews...')
|
|
print('---------------------------------------')
|
|
|
|
def create_review(i):
|
|
review = Review()
|
|
|
|
review.project = Project.objects.order_by('?').first()
|
|
review.stars = _.random(1, 5)
|
|
review.text = util.lorem(_.random(5, 15))
|
|
review.is_secured = _.sample((True, False))
|
|
|
|
review.save()
|
|
|
|
if _.sample((True, False)):
|
|
review.from_contractor = User.contractor_objects.order_by('?').first()
|
|
review.target_customer = User.customer_objects.order_by('?').first()
|
|
else:
|
|
review.from_customer = User.customer_objects.order_by('?').first()
|
|
review.target_contractor = User.contractor_objects.order_by('?').first()
|
|
|
|
review.save()
|
|
return review
|
|
|
|
_.times(create_review, 300)
|
|
|