JourneyJoker/partners/models.py

32 lines
No EOL
1 KiB
Python

from django.contrib.gis.db import models
from localauth.models import User, Profile, LocationMixin, ImageMixin, PhoneMixin
from django_countries.fields import CountryField
class PartnerProfile(Profile):
pass
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)
@property
def user(self):
return self.owner.user
@property
def is_active(self):
return self.verified and self.active
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)
price = models.DecimalField(max_digits=10, decimal_places=2)