villafleurie/rental/models/place.py
Ruidy 780188e7d6
Refactor (#7)
* crete setting module to split prod and dev configs

* fix calendar midmatch

* lint imports using isort

* doc: add doctrings
2020-07-31 08:02:10 +02:00

34 lines
1.2 KiB
Python

from django.db import models
import rental.services.calendar as calendar
from rental.models.picture import Picture
class Place(models.Model):
"""Place encapsulates a loaction information."""
class Meta:
verbose_name = "Appartement"
def __str__(self):
return self.name
name = models.CharField(max_length=10, unique=True)
description = models.TextField(blank=True)
info = models.TextField(blank=True)
subname = models.CharField(max_length=100, blank=True)
tagline = models.CharField(max_length=100, blank=True)
price = models.DecimalField(max_digits=6, decimal_places=2, null=True)
surface = models.IntegerField(null=True, blank=True)
beds = models.IntegerField(null=True, blank=True)
max_occupation = models.IntegerField(null=True, blank=True)
thumbnail = models.ForeignKey(
Picture, on_delete=models.CASCADE, blank=True, null=True
)
images = models.ManyToManyField(Picture, related_name="places", blank=True)
calendar = models.CharField(max_length=350, blank=True, null=True)
def is_available(self, start, end):
"""Check weither a location is available at a given time period."""
return calendar.check_availability(self, start, end)