Skip to content

Instantly share code, notes, and snippets.

@ijharulislam
Last active December 21, 2015 08:26
Show Gist options
  • Save ijharulislam/36780d045814f6b8c1d7 to your computer and use it in GitHub Desktop.
Save ijharulislam/36780d045814f6b8c1d7 to your computer and use it in GitHub Desktop.
from django.db import models
from django.contrib.auth.models import User
from clubs.models import Club
# Create your models here.
BOOKING_PERIOD = (
("1", "Choose Booking Period"),
("2", "60 minutes"),
("3", "120 minutes")
)
class Court(models.Model):
court_name = models.CharField(max_length=80)
club = models.ForeignKey(Club, null=True, blank=True)
description = models.TextField(max_length=500)
city = models.CharField(max_length=80)
country = models.CharField(max_length=80)
sport = models.CharField(max_length=80, null=True, blank=True)
surface = models.CharField(max_length=80)
roof = models.BooleanField(default=False)
lighting = models.BooleanField(default=True)
booking_length = models.CharField(max_length=80, null=True, blank=True)
address = models.TextField(max_length=500, null=True, blank=True)
registration_details = models.TextField(max_length=500, null=True, blank=True)
remarks = models.TextField(max_length=300, null=True, blank=True)
opening_hour = models.DateTimeField()
closing_hour = models.DateTimeField()
booking_date = models.DateTimeField()
booking_period = models.CharField(max_length=80, choices=BOOKING_PERIOD)
sixty_minutes_price = models.IntegerField(null=True, blank=True)
onetwenty_minutes_price = models.IntegerField(null=True, blank=True)
deposit_amount = models.IntegerField(null=True, blank=True)
created_on = models.DateTimeField(auto_now_add=True, null=True, blank=True)
modified_on = models.DateTimeField(auto_now=True, null=True, blank=True)
created_by = models.ForeignKey(User, related_name="court_created_by", null=True, blank=True)
modified_by = models.ForeignKey(User, related_name="court_modified_by", null=True, blank=True)
is_active = models.BooleanField(default=True)
is_booked = models.BooleanField(default=False)
def __unicode__(self):
return self.court_name
def __unicode__(self):
return self.court_name
class RecurringEvent(models.Model):
DAYS_CHOICES = (
(1, 'Monday'),
(2, 'Tuesday'),
(3, 'Wednesday'),
(4, 'Thursday'),
(5, 'Friday'),
(6, 'Saturday'),
(0, 'Sunday'),
)
TYPE_CHOICES = (
(1, "Booking"),
(2, "Blackout")
)
court = models.ForeignKey(Court)
day = models.IntegerField("Day", choices=DAYS_CHOICES, default=1)
start_time = models.TimeField("Start Time")
end_time = models.TimeField("End Time")
event_type = models.IntegerField("Type", choices=TYPE_CHOICES, default=1)
description = models.CharField("Description", max_length=255)
def get_court_name(self):
return self.court.name
from django.db import models
from django.core.validators import URLValidator
from django.contrib.auth.models import User
from courts.models import Court
from django.core.validators import MaxValueValidator
# Create your models here.
class Price(models.Model):
court = models.ForeignKey(Court)
options = models.CharField("Pricing Options", max_length=255)
price = models.FloatField("Price")
def __unicode__(self):
return u'%s - %s (%s - $ %s)' % (self.court.club.name, self.court.name, self.options, self.price)
STATUS_CHOICES = (
(1, 'Pending Payment'),
(2, 'Confirmed'),
(3, 'Cancelled'),
)
TYPE_CHOICES = (
(1, "Backoffice"),
(2, "Online")
)
class Booking(models.Model):
user = models.ForeignKey(User, null=True)
court = models.ForeignKey(Court)
status = models.IntegerField("Status", choices=STATUS_CHOICES)
booking_type = models.IntegerField("Type", choices=TYPE_CHOICES)
day = models.DateTimeField()
start_time = models.DateTimeField()
end_time = models.DateTimeField()
description = models.CharField("Description", max_length=160)
options = models.CharField("Pricing Options", max_length=255)
total_price = models.FloatField("Total Price")
paid_online = models.FloatField("Paid Online")
payment_left = models.FloatField("Payment Left")
rating = models.IntegerField("Rating", validators=[MaxValueValidator(5)])
review = models.TextField("Review")
created_by = models.ForeignKey(User, related_name="booking_created_by", null=True)
created_on = models.DateTimeField("Created On")
deleted_by = models.ForeignKey(User, related_name="booking_deleted_by", null=True, blank=True)
deleted_on = models.DateTimeField("Deleted On", blank=True, null=True)
attendance = models.BooleanField("Attendance")
zooz_id = models.TextField("Zooz Transaction ID", blank=True, null=True)
customer = models.TextField("Customer", blank=True, null=True)
phone = models.CharField("Phone", max_length=250, blank=True, null=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment