Merge branch 'dev_unstable' of github.com:vvsu-rent-project/dev_rent into dev_unstable

This commit is contained in:
Денис Сарапулов 2023-05-07 19:53:16 +10:00
commit e7278bc378
3 changed files with 68 additions and 33 deletions

View File

@ -1,55 +1,84 @@
import factory import factory
import random
import time, datetime
from django.db import models
from pairent_app.models import Apartament from pairent_app.models import Apartament
factory.Faker.override_default_locale('ru_RU'); factory.Faker.override_default_locale('ru_RU');
class PhoneNumber(factory.declarations.BaseDeclaration):
def evaluate(self, instance, step, extra):
return '+799' + str(random.randint(0, 99999999)).zfill(8);
class Random(factory.declarations.BaseDeclaration):
def __init__(self, min, max = None, multiply = 1):
if (max == None):
self.min = 0;
self.max = min;
else:
self.min = min;
self.max = max;
self.multiply = multiply;
super().__init__();
def evaluate(self, instance, step, extra):
if (self.multiply != None):
return random.randint(self.min, self.max) * self.multiply;
return random.randint(self.min, self.max);
class Date(factory.declarations.BaseDeclaration):
def evaluate(self, instance, step, extra):
# year_before = time.time() - (60 * 60 * 24 * 30 * 12);
return datetime.datetime(2023, random.randint(1,12), random.randint(1,27)).strftime("%G-%m-%d");
class ApartmentFactory(factory.django.DjangoModelFactory): class ApartmentFactory(factory.django.DjangoModelFactory):
class Meta: class Meta:
model = Apartament model = Apartament
# Base data # Base data
price = factory.Faker('random_number') price = Random(3,10,5000);
lastPrice = price lastPrice = Random(3,10,5000);
bail = factory.Faker('random_number') bail = Random(2,10,1000);
agencyCommission = factory.Faker('random_number') agencyCommission = Random(3,5,2500);
utilitiesPrice = factory.Faker('random_number') utilitiesPrice = Random(4,8,1000)
minimumLeasePeriod = factory.Faker('random_number') minimumLeasePeriod = Random(1,2,6);
address = factory.Faker('address') address = factory.Faker('address', locale='ru_RU');
description = factory.Faker('sentence') description = factory.Faker('sentence', locale='ru_RU');
perimetrs = factory.Faker('random_number') perimetrs = Random(15,40);
rooms = factory.Faker('random_number') rooms = Random(0,4);
ceilingHeight = factory.Faker('random_number') ceilingHeight = Random(3,5);
floorHouse = factory.Faker('random_number') floorHouse = Random(2,20);
floor = factory.Faker('random_number') floor = Random(2,20);
phoneNumber = factory.Faker('phone_number') phoneNumber = PhoneNumber()
timeToBus = factory.Faker('random_number') timeToBus = Random(1, 12, 5);
timeToTrain = factory.Faker('random_number') timeToTrain = Random(1, 12, 5);
# Apartment props # Apartment props
isFurniture = factory.Faker('boolean') isFurniture = Random(0, 1);
isAnimal = factory.Faker('boolean') isAnimal = Random(0, 1);
isTelevision = factory.Faker('boolean') isTelevision = Random(0, 1);
isChild = factory.Faker('boolean') isChild = Random(0, 1);
isInternet = factory.Faker('boolean') isInternet = Random(0, 1);
isBathroom = factory.Faker('boolean') isBathroom = Random(0, 1);
isRefrigerator = factory.Faker('boolean') isRefrigerator = Random(0, 1);
isWasher = factory.Faker('boolean') isWasher = Random(0, 1);
isAirConditioning = factory.Faker('boolean') isAirConditioning = Random(0, 1);
isFreshRepair = factory.Faker('boolean') isFreshRepair = Random(0, 1);
# House props # House props
isElevator = factory.Faker('boolean') isElevator = Random(0, 1);
isParking = factory.Faker('boolean') isParking = Random(0, 1);
isGarbageChute = factory.Faker('boolean') isGarbageChute = Random(0, 1);
isConcierge = factory.Faker('boolean') isConcierge = Random(0, 1);
views = factory.Faker('random_number') # views = [] # factory.Faker('random_number')
dateCreate = factory.Faker('date') dateCreate = Date()

View File

@ -25,7 +25,13 @@ const CardApartament = function (props) {
<div className="apartmentSectionLeft"> <div className="apartmentSectionLeft">
<img src="/images/apartment.png"></img> <img src="/images/apartment.png"></img>
<div className="characteristics"> <div className="characteristics">
<h3>{props.results.perimetrs} м², {props.results.rooms}{props.results.rooms > 1 ? "-х комнатная" : " комнатная"}</h3> <h3>{props.results.perimetrs} м², {props.results.rooms == 0 ? '' : props.results.rooms}
{props.results.rooms == 0 ? 'Гостинка' :
(props.results.rooms > 1 ? "-х комнатная" : " комнатная")
}
</h3>
<p className="address">{props.results.address}, {props.results.floor} этаж из {props.results.floorHouse}</p> <p className="address">{props.results.address}, {props.results.floor} этаж из {props.results.floorHouse}</p>
<div className="transport"> <div className="transport">
<div className="transportBas"> <div className="transportBas">