Skip to content

Instantly share code, notes, and snippets.

@alexcabrera
Created January 12, 2011 02:51
Show Gist options
  • Select an option

  • Save alexcabrera/775610 to your computer and use it in GitHub Desktop.

Select an option

Save alexcabrera/775610 to your computer and use it in GitHub Desktop.
class StockItemAttribute(models.Model):
name = models.CharField(max_length=80)
slug = models.SlugField(unique=True)
help_text = models.TextField(null=True, blank=True)
def __unicode__(self):
return _(self.name)
class StockItemAttributeValue(models.Model):
stock_item = models.ForeignKey('StockItem', related_name='attribute_values')
attribute = models.ForeignKey('StockItemAttribute')
value = models.CharField(max_length=255)
unit = models.CharField(max_length=8, choices=ATTRIBUTE_VALUE_UNITS, null=True, blank=True)
def __unicode__(self):
return "%s %s" % (self.value, self.unit)
def display_value(self):
return "%s %s" % (self.value, self.unit)
class StockItem(models.Model):
package_title = models.CharField(max_length=60, blank=True, null=True, help_text='(ex. 3-pack of T-shirts)', default='Individual Item')
package_count = models.IntegerField(default=1)
inventory = models.IntegerField(default=0)
price = models.DecimalField(
max_digits=10,
decimal_places=2,
help_text='All prices in USD. Use this field to override the standard pricing of a product for this sepcific stock item.',
blank=True,
null=True,
)
on_sale = models.BooleanField(default=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment