JourneyJoker/partners/models.py

38 lines
1.3 KiB
Python

from django.contrib.gis.db import models
from .features import *
from localauth.models import User, Profile, LocationMixin, ImageMixin, PhoneMixin
from django_countries.fields import CountryField
class PartnerProfile(Profile):
@property
def roomcategory_set(self):
return RoomCategory.objects.filter(establishment__in=self.establishment_set.all())
class Establishment(LocationMixin, ImageMixin, PhoneMixin):
owner = models.ForeignKey(PartnerProfile, models.CASCADE)
name = models.CharField("Name", max_length=64)
stars = models.IntegerField("Sterne", null=True, blank=True)
superior = models.BooleanField("Superior", default=False)
verified = models.BooleanField(default=False)
active = models.BooleanField(default=True)
featureset = models.OneToOneField(FeatureSet, models.PROTECT, null=True)
@property
def user(self):
return self.owner.user
@property
def is_active(self):
return self.verified and self.active
@property
def booking_set(self):
return self.offer_set.filter(accepted=True)
class RoomCategory(ImageMixin):
establishment = models.ForeignKey(Establishment, models.CASCADE)
name = models.CharField(max_length=64)
average_price = models.DecimalField(max_digits=10, decimal_places=2)