add apartment faker
This commit is contained in:
parent
d3d594577a
commit
6eaaf50ac5
|
@ -0,0 +1,66 @@
|
|||
import factory
|
||||
import factory.fuzzy
|
||||
|
||||
from django.core.validators import RegexValidator
|
||||
|
||||
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
|
||||
|
||||
class ApartmentFactory(factory.django.DjangoModelFactory):
|
||||
|
||||
class Meta:
|
||||
model = Apartament
|
||||
django_get_or_create = ('address',)
|
||||
|
||||
# Base data
|
||||
ipAddress = faker.ipv4_private(address_class='a')
|
||||
price = faker.random.randint(2, 10) * 5000
|
||||
lastPrice = price
|
||||
bail = faker.random.randint(1, 10) * 100
|
||||
|
||||
# agency comission is either 10% or 15%
|
||||
agencyCommission = int(price / (10 + (faker.random.randint(0,1) * 5)))
|
||||
utilitiesPrice = faker.random.randint(4, 16) * 1000
|
||||
minimumLeasePeriod = math.ceil(faker.random.randint(100,160) / 100) * 6
|
||||
|
||||
address = faker.address();
|
||||
description = ' '.join([faker.sentence() for i in range(5)]);
|
||||
|
||||
perimetrs = faker.random.randint(150,400) / 10
|
||||
rooms = faker.random.randint(1, 4) # 0 - гостинка, 4 - трешка
|
||||
ceilingHeight = faker.random.randint(5, 7)
|
||||
floorHouse = faker.random.randint(2, 20)
|
||||
floor = faker.random.randint(1, floorHouse)
|
||||
|
||||
phoneNumberRegex = RegexValidator(regex = r"^\+?1?\d{8,15}$")
|
||||
phoneNumber = faker.phone_number()
|
||||
|
||||
timeToBus = faker.random.randint(2, 12) * 5
|
||||
timeToTrain = faker.random.randint(2, 12) * 5
|
||||
|
||||
# Apartment props
|
||||
isFurniture = faker.random.randint(0, 1)
|
||||
isAnimal = faker.random.randint(0, 1)
|
||||
isTelevision = faker.random.randint(0, 1)
|
||||
isChild = faker.random.randint(0, 1)
|
||||
isInternet = faker.random.randint(0, 1)
|
||||
isBathroom = faker.random.randint(0, 1)
|
||||
isRefrigerator = faker.random.randint(0, 1)
|
||||
isWasher = faker.random.randint(0, 1)
|
||||
isAirConditioning = faker.random.randint(0, 1)
|
||||
isFreshRepair = faker.random.randint(0, 1)
|
||||
|
||||
# House props
|
||||
isElevator = faker.random.randint(0, 1)
|
||||
isParking = faker.random.randint(0, 1)
|
||||
isGarbageChute = faker.random.randint(0, 1)
|
||||
isConcierge = faker.random.randint(0, 1)
|
||||
|
||||
views = faker.random.randint(10, 666)
|
||||
|
||||
dateCreate = faker.date_between('-1y')
|
Loading…
Reference in New Issue