Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- class Supplier(models.Model):
- name = models.CharField('Supplier Name', max_length=200)
- address1 = models.CharField('Street', max_length=200)
- address2 = models.CharField(blank=True, null=True, max_length=200)
- address3 = models.CharField('Town', max_length=200)
- address4 = models.CharField('Postcode', max_length=200)
- telephone = models.CharField(max_length=200)
- email = models.EmailField()
- notes = models.TextField(blank=True, null=True, help_text = "Notes about this supplier")
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- class Product(models.Model):
- supplier = models.ManyToManyField(Supplier)
- name = models.CharField(max_length=200, help_text="The name of the case. Will form the URL of page. e.g. Mixed Rioja Case")
- slug = models.SlugField(max_length=255, unique=True,
- help_text='Unique value for product page URL, created automatically from name.')
- sku = models.CharField(max_length=50)
- is_featured = models.BooleanField(default=False, help_text="To appear on front page? Most recent item first.")
- is_active = models.BooleanField(default=True)
- is_bestseller = models.BooleanField(default=False, help_text="Click to add to 'bestsellers' list.")
- price = models.DecimalField(max_digits=5, decimal_places=2, help_text="pounds.pence")
- old_price = models.DecimalField(max_digits=9,decimal_places=2,
- blank=True,default=0.00, help_text="If item is on sale, put the old price here, and change price to sale price. Will automatically be added to 'offers' section")
- description = models.TextField(help_text="Prose. Promotion. Propaganda")
- head_line = models.CharField(max_length=200, help_text="Will be main title in large letters on home page. E.g. Gobsmacking Rioja.")
- tag_line = models.CharField(max_length=200, help_text="In italics inder main title. Call to action. E.g. Buy this you really really want it.")
- stock = models.IntegerField(max_length=4, help_text="Amount of item you have to sell")
- control_stock = models.BooleanField(default=True, help_text="Uncheck if you don't want the stock controlled. i.e. it won't say sold out when stock goes to zero")
- created_at = models.DateTimeField(auto_now_add=True)
- updated_at = models.DateTimeField(auto_now=True)
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- def price_pence(self):
- return int(self.price*100)
- @property
- def sale_price(self):
- if self.old_price > self.price:
- return self.price
- else:
- return None
- @property
- def isinstock(self):
- if self.control_stock == True:
- if self.stock >=1:
- return True
- else:
- return False
- else:
- return None
- class Images(models.Model):
- product = models.ForeignKey(Product)
- image = models.FileField(upload_to = 'images/', default = 'images/no-img.png', help_text="Nice images of product for detail page. Size XX x XXpx please. Default image will appear if none supplied.")
- image_featured = models.BooleanField(default = False, help_text="Do you want this image to be the image on the home page if the product is a featured product?")
- def __unicode__(self):
- return self.image
- class Video(models.Model):
- product = models.OneToOneField(Product)
- video_url_embed = models.TextField(blank=True, null=True, help_text="The main focus. Get video embed code from share buttons on YouTube or Vimeo")
- def __unicode__(self):
- return self.video_url_embed
- class Country(models.Model):
- name = models.CharField(max_length=200, help_text="Country E.g. Spain")
- writeup = models.TextField(blank=True, null=True, help_text="Blurb About the Country")
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- class Region(models.Model):
- country = models.ForeignKey(Country)
- name = models.CharField(max_length=200, help_text="Region E.g. Rioja")
- writeup = models.TextField(blank=True, null=True, help_text="Blurb About the Region")
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- class Producer(models.Model):
- name = models.CharField(max_length=200, help_text="Producer E.g. La Rioja Alta")
- writeup = models.TextField(help_text="Blurb About the Producer")
- location_map_url_embed = models.TextField(blank=True, null=True, help_text="Optional. A link to pinpoint where in the world the producer is. Get embed code from google maps or open street map.")
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- class GrapeVariety(models.Model):
- name = models.CharField(max_length=200, help_text="Grape Variety E.g. Tempranillo")
- writeup = models.TextField(blank=True, null=True, help_text="Blurb About the Grape Variety")
- def __unicode__(self): # Python 3: def __str__(self):
- return self.name
- class Wine(Product):
- SIZE_OF_BOTTLE = [
- (375,375),
- (500,500),
- (750,750),
- (1500,1500),
- (3000,3000),
- ]
- ORGANIC_BIO = [
- ("Conventional","Conventional"),
- ("Organic Uncertified","Organic Uncertified"),
- ("Organic Certified","Organic Certified"),
- ("Biodynamic Uncertified","Biodynamic Uncertified"),
- ("Biodynamic Certified","Biodynamic Certified"),
- ]
- WINE_COLOUR = [
- ("White","White"),
- ("Red","Red"),
- ("Rose","Rose"),
- ]
- WINE_STYLE = [
- ("Still","Still"),
- ("Sparkling","Sparkling"),
- ("Fortified","Fortified"),
- ("Dessert","Dessert"),
- ]
- style = models.CharField(max_length=15, choices=WINE_STYLE, default = "Still", help_text="Wine Style")
- colour = models.CharField(max_length=5, choices=WINE_COLOUR, help_text="Wine Colour")
- region = models.ForeignKey(Region)
- producer = models.ForeignKey(Producer)
- year = models.IntegerField(max_length=4, help_text="YYYY. E.g. 1985")
- grapes = models.ManyToManyField(GrapeVariety)
- bottle_size = models.IntegerField(max_length=4, choices=SIZE_OF_BOTTLE, default = '750', help_text="Size of bottle in ml")
- organicbio = models.CharField(max_length=50, choices=ORGANIC_BIO, default = 'Conventional', help_text="Is this beauty organic/bio/conventional?")
- lowyields = models.BooleanField(default=False, help_text="Is this beauty from low-yielding vines?")
- lowsulphur = models.BooleanField(default=False, help_text="Is this beauty a low-sulphur wine?")
- oldvines = models.BooleanField(default=False, help_text="Is this beauty from old vines?")
- class Case(Product):
- BOTTLES_IN_THE_CASE = [
- (1,1),
- (3,3),
- (6,6),
- (12,12),
- (24,24),
- ]
- wine = models.ForeignKey(Wine)
- bottles_in_case = models.IntegerField(max_length=2, choices=BOTTLES_IN_THE_CASE, default = '6', help_text="Number of bottles in the case")
- class Tasting(Product):
- FOOD_AT_TASTING = [
- ('Wine Only','Wine Only'),
- ('Beer Only','Beer Only'),
- ('Nibbles','Nibbles'),
- ('Cheese Pairing','Cheese Pairing'),
- ('Food Pairing','Food Pairing'),
- ('Light Meal','Light Meal'),
- ('Full Meal','Full Meal'),
- ('Dinner','Dinner'),
- ]
- address_1 = models.CharField(max_length=200, default = 'Wine Store at No. 4', help_text="Address Line One")
- address_2 = models.CharField(max_length=200, default = '4 Beulah Road', help_text="Address Line Two")
- address_3 = models.CharField(max_length=200, default = 'Rhiwbina', help_text="Address Line Three")
- address_4 = models.CharField(max_length=200, default = 'Cardiff', help_text="Address Line Four")
- postcode = models.CharField(max_length=200, default = 'CF14 6LX', help_text="Postcode")
- telephone = models.CharField(max_length=200, default = '029 2061 1139', help_text="Telephone")
- date_of_tasting = models.DateField(help_text="Date of the Tasting")
- time_of_tasting = models.TimeField(help_text="Time of the Tasting")
- menu_pdf = models.FileField(null=True, upload_to = 'static/tastings/menus/', help_text="If you have a pdf menu, upload it here")
- ticket_pdf = models.FileField(null=True, upload_to = 'static/tastings/tickets/', help_text="If you have a pdf of the ticket, upload it here")
- tasting_food = models.CharField(max_length=40, choices=FOOD_AT_TASTING, default = 'Wine Only', help_text="Type of food at tasting,")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement