change to factory
This commit is contained in:
parent
7b93c6970e
commit
21fa7e73b9
|
@ -5,59 +5,56 @@ from django.core.validators import RegexValidator
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
import faker as fake_lib
|
|
||||||
from faker.providers import internet
|
|
||||||
faker = fake_lib.Factory.create('ru_RU');
|
|
||||||
|
|
||||||
from pairent_app.models import Apartament
|
from pairent_app.models import Apartament
|
||||||
|
|
||||||
|
factory.Faker.override_default_locale('ru_RU');
|
||||||
|
|
||||||
class ApartmentFactory(factory.django.DjangoModelFactory):
|
class ApartmentFactory(factory.django.DjangoModelFactory):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Apartament
|
model = Apartament
|
||||||
|
|
||||||
# Base data
|
# Base data
|
||||||
price = faker.random.randint(2, 10) * 5000
|
price = factory.Faker('random_number')
|
||||||
lastPrice = price
|
lastPrice = price
|
||||||
bail = faker.random.randint(1, 10) * 100
|
bail = factory.Faker('random_number')
|
||||||
|
|
||||||
# agency comission is either 10% or 15%
|
agencyCommission = factory.Faker('random_number')
|
||||||
agencyCommission = int(price / (10 + (faker.random.randint(0,1) * 5)))
|
utilitiesPrice = factory.Faker('random_number')
|
||||||
utilitiesPrice = faker.random.randint(4, 16) * 1000
|
minimumLeasePeriod = factory.Faker('random_number')
|
||||||
minimumLeasePeriod = math.ceil(faker.random.randint(100,160) / 100) * 6
|
|
||||||
|
|
||||||
address = faker.address();
|
address = factory.Faker('address')
|
||||||
description = ' '.join([faker.sentence() for i in range(5)]);
|
description = factory.Faker('sentence')
|
||||||
|
|
||||||
perimetrs = faker.random.randint(150,400) / 10
|
perimetrs = factory.Faker('random_number')
|
||||||
rooms = faker.random.randint(1, 4) # 0 - гостинка, 4 - трешка
|
rooms = factory.Faker('random_number')
|
||||||
ceilingHeight = faker.random.randint(5, 7)
|
ceilingHeight = factory.Faker('random_number')
|
||||||
floorHouse = faker.random.randint(2, 20)
|
floorHouse = factory.Faker('random_number')
|
||||||
floor = faker.random.randint(1, floorHouse)
|
floor = factory.Faker('random_number')
|
||||||
|
|
||||||
phoneNumber = faker.phone_number()
|
phoneNumber = factory.Faker('phone_number')
|
||||||
|
|
||||||
timeToBus = faker.random.randint(2, 12) * 5
|
timeToBus = factory.Faker('random_number')
|
||||||
timeToTrain = faker.random.randint(2, 12) * 5
|
timeToTrain = factory.Faker('random_number')
|
||||||
|
|
||||||
# Apartment props
|
# Apartment props
|
||||||
isFurniture = faker.random.randint(0, 1)
|
isFurniture = factory.Faker('boolean')
|
||||||
isAnimal = faker.random.randint(0, 1)
|
isAnimal = factory.Faker('boolean')
|
||||||
isTelevision = faker.random.randint(0, 1)
|
isTelevision = factory.Faker('boolean')
|
||||||
isChild = faker.random.randint(0, 1)
|
isChild = factory.Faker('boolean')
|
||||||
isInternet = faker.random.randint(0, 1)
|
isInternet = factory.Faker('boolean')
|
||||||
isBathroom = faker.random.randint(0, 1)
|
isBathroom = factory.Faker('boolean')
|
||||||
isRefrigerator = faker.random.randint(0, 1)
|
isRefrigerator = factory.Faker('boolean')
|
||||||
isWasher = faker.random.randint(0, 1)
|
isWasher = factory.Faker('boolean')
|
||||||
isAirConditioning = faker.random.randint(0, 1)
|
isAirConditioning = factory.Faker('boolean')
|
||||||
isFreshRepair = faker.random.randint(0, 1)
|
isFreshRepair = factory.Faker('boolean')
|
||||||
|
|
||||||
# House props
|
# House props
|
||||||
isElevator = faker.random.randint(0, 1)
|
isElevator = factory.Faker('boolean')
|
||||||
isParking = faker.random.randint(0, 1)
|
isParking = factory.Faker('boolean')
|
||||||
isGarbageChute = faker.random.randint(0, 1)
|
isGarbageChute = factory.Faker('boolean')
|
||||||
isConcierge = faker.random.randint(0, 1)
|
isConcierge = factory.Faker('boolean')
|
||||||
|
|
||||||
views = faker.random.randint(10, 666)
|
views = factory.Faker('random_number')
|
||||||
|
|
||||||
dateCreate = faker.date_between('-1y')
|
dateCreate = factory.Faker('date')
|
Loading…
Reference in New Issue