2017-08-26 01:48:02 +00:00
|
|
|
from django.db import models
|
|
|
|
from utils.models import CampRelatedModel
|
|
|
|
|
|
|
|
|
|
|
|
class ProductCategory(CampRelatedModel):
|
|
|
|
name = models.CharField(max_length=255)
|
2018-03-04 15:26:35 +00:00
|
|
|
camp = models.ForeignKey('camps.Camp', on_delete=models.PROTECT)
|
2017-08-26 01:48:02 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2017-08-26 18:28:11 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ("name",)
|
|
|
|
|
2017-08-26 01:48:02 +00:00
|
|
|
|
|
|
|
class Product(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
price = models.IntegerField()
|
2018-03-04 15:26:35 +00:00
|
|
|
category = models.ForeignKey(
|
|
|
|
ProductCategory,
|
|
|
|
related_name="products",
|
|
|
|
on_delete=models.PROTECT
|
|
|
|
)
|
2017-08-26 01:48:02 +00:00
|
|
|
in_stock = models.BooleanField(default=True)
|
|
|
|
|
2017-08-26 18:28:11 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ("name",)
|
|
|
|
|
2017-08-26 01:48:02 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|