# Path: src/products/models.py
# class Variation(models.Model):
# 	product = models.ForeignKey(Product)
# 	title = models.CharField(max_length=120)
# 	price = models.DecimalField(decimal_places=2, max_digits=20)
# 	sale_price = models.DecimalField(decimal_places=2, max_digits=20, null=True, blank=True)
# 	active = models.BooleanField(default=True)
# 	inventory = models.IntegerField(null=True, blank=True) #refer none == unlimited amount
# 
# 	def __unicode__(self):
# 		return self.title
# 
# 	def get_price(self):
# 		if self.sale_price is not None:
# 			return self.sale_price
# 		else:
# 			return self.price
# 
# 	def get_html_price(self):
# 		if self.sale_price is not None:
# 			html_text = "<span class='sale-price'>%s</span> <span class='og-price'>%s</span>" %(self.sale_price, self.price)
# 		else:
# 			html_text = "<span class='price'>%s</span>" %(self.price)
# 		return mark_safe(html_text)
# 
# 	def get_absolute_url(self):
# 		return self.product.get_absolute_url()
# 
# 	def add_to_cart(self):
# 		return "%s?item=%s&qty=1" %(reverse("cart"), self.id)
# 
# 	def remove_from_cart(self):
# 		return "%s?item=%s&qty=1&delete=True" %(reverse("cart"), self.id)
# 
# 	def get_title(self):
# 		return "%s - %s" %(self.product.title, self.title)
# 
# class Category(models.Model):
# 	title = models.CharField(max_length=120, unique=True)
# 	slug = models.SlugField(unique=True)
# 	description = models.TextField(null=True, blank=True)
# 	active = models.BooleanField(default=True)
# 	timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
# 
# 	def __unicode__(self):
# 		return self.title
# 
# 
# 	def get_absolute_url(self):
# 		return reverse("category_detail", kwargs={"slug": self.slug })


from django import forms
from django.forms.models import modelformset_factory
from .models import Variation, Category





CAT_CHOICES = (
	('electronics', 'Electronics'),
	('accessories', 'Accessories'),
)

class ProductFilterForm(forms.Form):
	q = forms.CharField(label='Search', required=False)
	category_id = forms.ModelMultipleChoiceField(
		label='Category',

# Path: src/products/models.py
# class Variation(models.Model):
# 	product = models.ForeignKey(Product)
# 	title = models.CharField(max_length=120)
# 	price = models.DecimalField(decimal_places=2, max_digits=20)
# 	sale_price = models.DecimalField(decimal_places=2, max_digits=20, null=True, blank=True)
# 	active = models.BooleanField(default=True)
# 	inventory = models.IntegerField(null=True, blank=True) #refer none == unlimited amount
# 
# 	def __unicode__(self):
# 		return self.title
# 
# 	def get_price(self):
# 		if self.sale_price is not None:
# 			return self.sale_price
# 		else:
# 			return self.price
# 
# 	def get_html_price(self):
# 		if self.sale_price is not None:
# 			html_text = "<span class='sale-price'>%s</span> <span class='og-price'>%s</span>" %(self.sale_price, self.price)
# 		else:
# 			html_text = "<span class='price'>%s</span>" %(self.price)
# 		return mark_safe(html_text)
# 
# 	def get_absolute_url(self):
# 		return self.product.get_absolute_url()
# 
# 	def add_to_cart(self):
# 		return "%s?item=%s&qty=1" %(reverse("cart"), self.id)
# 
# 	def remove_from_cart(self):
# 		return "%s?item=%s&qty=1&delete=True" %(reverse("cart"), self.id)
# 
# 	def get_title(self):
# 		return "%s - %s" %(self.product.title, self.title)
# 
# class Category(models.Model):
# 	title = models.CharField(max_length=120, unique=True)
# 	slug = models.SlugField(unique=True)
# 	description = models.TextField(null=True, blank=True)
# 	active = models.BooleanField(default=True)
# 	timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
# 
# 	def __unicode__(self):
# 		return self.title
# 
# 
# 	def get_absolute_url(self):
# 		return reverse("category_detail", kwargs={"slug": self.slug })


# Path: src/products/forms.py
from django import forms
from django.forms.models import modelformset_factory
from .models import Variation, Category






CAT_CHOICES = (
	('electronics', 'Electronics'),
	('accessories', 'Accessories'),
)

class ProductFilterForm(forms.Form):
	q = forms.CharField(label='Search', required=False)
	category_id = forms.ModelMultipleChoiceField(
		label='Category',

		queryset=Category.objects.all(), 