Selaa lähdekoodia

Added models for offers

master
David Winterbottom 15 vuotta sitten
vanhempi
commit
9b7d465c32
3 muutettua tiedostoa jossa 42 lisäystä ja 0 poistoa
  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 Näytä tiedosto

@@ -2,8 +2,46 @@ from django.contrib.auth.models import User
2 2
 from django.db import models
3 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 39
 class Voucher(models.Model):
40
+    """
41
+    A voucher
42
+    """
6 43
     code = models.CharField(max_length=128)
7 44
     start_date = models.DateField()
8 45
     end_date = models.DateField()
46
+    offers = models.ManyToManyField('offer.ConditionalOffer')
9 47
     created_date = models.DateTimeField(auto_now_add=True)

+ 2
- 0
oscar/product/models.py Näytä tiedosto

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

+ 2
- 0
settings.py Näytä tiedosto

@@ -95,6 +95,8 @@ INSTALLED_APPS = (
95 95
     'oscar.payment',
96 96
     'oscar.order',
97 97
     'oscar.product',
98
+    'oscar.basket',
99
+    'oscar.offer',
98 100
 )
99 101
 
100 102
 # Local overrides

Loading…
Peruuta
Tallenna