Explorar el Código

Merge branch 'dropapp-command'

master
David Winterbottom hace 15 años
padre
commit
fcac900578

+ 0
- 0
oscar/management/__init__.py Ver fichero


+ 0
- 0
oscar/management/commands/__init__.py Ver fichero


+ 12
- 0
oscar/management/commands/dropapp.py Ver fichero

1
+from django.core.management.base import BaseCommand, CommandError
2
+from django.core.management.commands.sqlclear import Command as SqlClearCommand
3
+
4
+class Command(BaseCommand):
5
+    args = '<app_name app_name ...>'
6
+    help = 'Drops the db tables for the given apps'
7
+
8
+    def handle(self, *args, **kwargs):
9
+        com = SqlClearCommand()
10
+        self.stdout.write("SET FOREIGN_KEY_CHECKS=0;\n")
11
+        for app_name in args:
12
+            self.stdout.write(com.handle(app_name))

+ 8
- 0
oscar/offer/models.py Ver fichero

2
 from django.db import models
2
 from django.db import models
3
 from django.utils.translation import ugettext as _
3
 from django.utils.translation import ugettext as _
4
 
4
 
5
+
5
 class ConditionalOffer(models.Model):
6
 class ConditionalOffer(models.Model):
6
     name = models.CharField(max_length=128)
7
     name = models.CharField(max_length=128)
7
     description = models.TextField(blank=True)
8
     description = models.TextField(blank=True)
13
     priority = models.IntegerField()
14
     priority = models.IntegerField()
14
     created_date = models.DateTimeField(auto_now_add=True)
15
     created_date = models.DateTimeField(auto_now_add=True)
15
 
16
 
17
+
16
 class Condition(models.Model):
18
 class Condition(models.Model):
17
     COUNT, VALUE = ("Count", "Value")
19
     COUNT, VALUE = ("Count", "Value")
18
     TYPE_CHOICES = (
20
     TYPE_CHOICES = (
23
     type = models.CharField(max_length=128, choices=TYPE_CHOICES)
25
     type = models.CharField(max_length=128, choices=TYPE_CHOICES)
24
     value = models.FloatField()
26
     value = models.FloatField()
25
 
27
 
28
+
26
 class Benefit(models.Model):
29
 class Benefit(models.Model):
27
     PERCENTAGE, FIXED = ("Percentage", "Absolute")
30
     PERCENTAGE, FIXED = ("Percentage", "Absolute")
28
     TYPE_CHOICES = (
31
     TYPE_CHOICES = (
33
     type = models.CharField(max_length=128, choices=TYPE_CHOICES)
36
     type = models.CharField(max_length=128, choices=TYPE_CHOICES)
34
     value = models.FloatField()
37
     value = models.FloatField()
35
 
38
 
39
+
36
 class Range(models.Model):
40
 class Range(models.Model):
37
     name = models.CharField(max_length=128)
41
     name = models.CharField(max_length=128)
42
+    includes_all_products = models.BooleanField(default=False)
43
+    included_products = models.ManyToManyField('product.Item', related_name='includes')
44
+    excluded_products = models.ManyToManyField('product.Item', related_name='excludes')
45
+
38
 
46
 
39
 class Voucher(models.Model):
47
 class Voucher(models.Model):
40
     """
48
     """

+ 22
- 20
oscar/product/models.py Ver fichero

2
 
2
 
3
 class AttributeType(models.Model):
3
 class AttributeType(models.Model):
4
     """Defines a product attribute type"""
4
     """Defines a product attribute type"""
5
-    name = models.CharField(max_length = 128)
5
+    name=models.CharField(max_length=128)
6
 
6
 
7
     def __unicode__(self):
7
     def __unicode__(self):
8
         return self.name
8
         return self.name
10
 
10
 
11
 class Type(models.Model):
11
 class Type(models.Model):
12
     """Defines a product type"""
12
     """Defines a product type"""
13
-    name = models.CharField(max_length = 128)
14
-    attribute_types = models.ManyToManyField('product.AttributeType', through = 'product.AttributeTypeMembership')
13
+    name=models.CharField(max_length=128)
14
+    attribute_types=models.ManyToManyField('product.AttributeType', through='product.AttributeTypeMembership')
15
 
15
 
16
     def __unicode__(self):
16
     def __unicode__(self):
17
         return self.name
17
         return self.name
18
 
18
 
19
 
19
 
20
 class AttributeTypeMembership(models.Model):
20
 class AttributeTypeMembership(models.Model):
21
-    RELATIONSHIP_CHOICES = (
21
+    RELATIONSHIP_CHOICES=(
22
         ('optional', 'optional'),
22
         ('optional', 'optional'),
23
         ('required', 'required'),
23
         ('required', 'required'),
24
         ('required_basket', 'required for purchase'),
24
         ('required_basket', 'required for purchase'),
25
     )
25
     )
26
-    type = models.ForeignKey('product.Type')
27
-    attribute_type = models.ForeignKey('product.AttributeType')
28
-    relation_type = models.CharField(max_length = 16, choices = RELATIONSHIP_CHOICES, default = 'optional')
26
+    type=models.ForeignKey('product.Type')
27
+    # Some attributes like clothes sizes need to be displayed in a set order (eg: S,M,L,XL)
28
+    display_order=models.IntegerField(default=0)
29
+    attribute_type=models.ForeignKey('product.AttributeType')
30
+    relation_type=models.CharField(max_length=16, choices=RELATIONSHIP_CHOICES, default='optional')
29
     
31
     
30
     def __unicode__(self):
32
     def __unicode__(self):
31
         return "%s -> %s (%s)" % (self.type.name, self.attribute_type.name, self.relation_type)
33
         return "%s -> %s (%s)" % (self.type.name, self.attribute_type.name, self.relation_type)
33
 
35
 
34
 class Item(models.Model):
36
 class Item(models.Model):
35
     """The base product object"""
37
     """The base product object"""
36
-    name = models.CharField(max_length = 128)
37
-    partner_id = models.CharField(max_length = 32)
38
-    type = models.ForeignKey('product.Type')
39
-    date_available = models.DateField()
40
-    date_created = models.DateTimeField()
38
+    name=models.CharField(max_length=128)
39
+    partner_id=models.CharField(max_length=32)
40
+    type=models.ForeignKey('product.Type')
41
+    date_available=models.DateField()
42
+    date_created=models.DateTimeField()
41
 
43
 
42
     def __unicode__(self):
44
     def __unicode__(self):
43
         return self.name
45
         return self.name
52
         Returns:
54
         Returns:
53
             A boolean if the product is valid
55
             A boolean if the product is valid
54
         """
56
         """
55
-        required_attribute_names = []
56
-        for attribute_type in self.type.attribute_types.filter(attributetypemembership__relation_type = 'required'):
57
+        required_attribute_names=[]
58
+        for attribute_type in self.type.attribute_types.filter(attributetypemembership__relation_type='required'):
57
             required_attribute_names.append(attribute_type.name)
59
             required_attribute_names.append(attribute_type.name)
58
 
60
 
59
         for attribute in self.attribute_set.all():
61
         for attribute in self.attribute_set.all():
65
 
67
 
66
 class Attribute(models.Model):
68
 class Attribute(models.Model):
67
     """An individual product attribute"""
69
     """An individual product attribute"""
68
-    attribute_type = models.ForeignKey('product.AttributeType')
69
-    product = models.ForeignKey('product.Item')
70
-    value = models.CharField(max_length = 256)
70
+    attribute_type=models.ForeignKey('product.AttributeType')
71
+    product=models.ForeignKey('product.Item')
72
+    value=models.CharField(max_length=256)
71
 
73
 
72
 
74
 
73
 class StockRecord(models.Model):
75
 class StockRecord(models.Model):
74
     """A stock keeping record"""
76
     """A stock keeping record"""
75
-    product = models.ForeignKey('product.Item')
76
-    price_excl_tax = models.FloatField()
77
-    tax = models.FloatField()
77
+    product=models.ForeignKey('product.Item')
78
+    price_excl_tax=models.FloatField()
79
+    tax=models.FloatField()

+ 1
- 0
settings.py Ver fichero

92
     'django.contrib.admin',
92
     'django.contrib.admin',
93
     'django_extensions',
93
     'django_extensions',
94
     'south',
94
     'south',
95
+    'oscar',
95
     'oscar.payment',
96
     'oscar.payment',
96
     'oscar.order',
97
     'oscar.order',
97
     'oscar.product',
98
     'oscar.product',

Loading…
Cancelar
Guardar