Pārlūkot izejas kodu

Added models for offers

master
David Winterbottom 15 gadus atpakaļ
vecāks
revīzija
9b7d465c32
3 mainītis faili ar 42 papildinājumiem un 0 dzēšanām
  1. 38
    0
      oscar/offer/models.py
  2. 2
    0
      oscar/product/models.py
  3. 2
    0
      settings.py

+ 38
- 0
oscar/offer/models.py Parādīt failu

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
+class ConditionalOffer(models.Model):
6
+    name = models.CharField(max_length=128)
7
+    description = models.TextField(blank=True)
8
+    condition = models.ForeignKey('offer.Condition')
9
+    benefit = models.ForeignKey('offer.Benefit')
10
+    start_date = models.DateField()
11
+    # Offers can be open-ended
12
+    end_date = models.DateField(blank=True)
13
+    priority = models.IntegerField()
14
+    created_date = models.DateTimeField(auto_now_add=True)
15
+
16
+class Condition(models.Model):
17
+    COUNT, VALUE = ("Count", "Value")
18
+    TYPE_CHOICES = (
19
+        (COUNT, _("Depends on number of items in basket that are in condition range")),
20
+        (VALUE, _("Depends on value of items in basket that are in condition range")),
21
+    )
22
+    range = models.ForeignKey('offer.Range')
23
+    type = models.CharField(max_length=128, choices=TYPE_CHOICES)
24
+    value = models.FloatField()
25
+
26
+class Benefit(models.Model):
27
+    PERCENTAGE, FIXED = ("Percentage", "Absolute")
28
+    TYPE_CHOICES = (
29
+        (PERCENTAGE, _("Discount is a % of the product's value")),
30
+        (FIXED, _("Discount is a fixed amount off the product's value")),
31
+    )
32
+    range = models.ForeignKey('offer.Range')
33
+    type = models.CharField(max_length=128, choices=TYPE_CHOICES)
34
+    value = models.FloatField()
35
+
36
+class Range(models.Model):
37
+    name = models.CharField(max_length=128)
38
+
5
 class Voucher(models.Model):
39
 class Voucher(models.Model):
40
+    """
41
+    A voucher
42
+    """
6
     code = models.CharField(max_length=128)
43
     code = models.CharField(max_length=128)
7
     start_date = models.DateField()
44
     start_date = models.DateField()
8
     end_date = models.DateField()
45
     end_date = models.DateField()
46
+    offers = models.ManyToManyField('offer.ConditionalOffer')
9
     created_date = models.DateTimeField(auto_now_add=True)
47
     created_date = models.DateTimeField(auto_now_add=True)

+ 2
- 0
oscar/product/models.py Parādīt failu

16
     def __unicode__(self):
16
     def __unicode__(self):
17
         return self.name
17
         return self.name
18
 
18
 
19
+
19
 class AttributeTypeMembership(models.Model):
20
 class AttributeTypeMembership(models.Model):
20
     RELATIONSHIP_CHOICES = (
21
     RELATIONSHIP_CHOICES = (
21
         ('optional', 'optional'),
22
         ('optional', 'optional'),
61
 
62
 
62
         return 0 == len(required_attribute_names)
63
         return 0 == len(required_attribute_names)
63
 
64
 
65
+
64
 class Attribute(models.Model):
66
 class Attribute(models.Model):
65
     """An individual product attribute"""
67
     """An individual product attribute"""
66
     attribute_type = models.ForeignKey('product.AttributeType')
68
     attribute_type = models.ForeignKey('product.AttributeType')

+ 2
- 0
settings.py Parādīt failu

95
     'oscar.payment',
95
     'oscar.payment',
96
     'oscar.order',
96
     'oscar.order',
97
     'oscar.product',
97
     'oscar.product',
98
+    'oscar.basket',
99
+    'oscar.offer',
98
 )
100
 )
99
 
101
 
100
 # Local overrides
102
 # Local overrides

Notiek ielāde…
Atcelt
Saglabāt