|
|
@@ -9,14 +9,10 @@ from django.contrib.contenttypes.models import ContentType
|
|
9
|
9
|
|
|
10
|
10
|
from oscar.forms.fields import ExtendedURLField
|
|
11
|
11
|
|
|
12
|
|
-# Settings-controlled stuff
|
|
13
|
|
-BANNER_FOLDER = settings.OSCAR_BANNER_FOLDER
|
|
14
|
|
-POD_FOLDER = settings.OSCAR_POD_FOLDER
|
|
15
|
|
-
|
|
16
|
12
|
# Different model types for each type of promotion
|
|
17
|
13
|
|
|
18
|
14
|
|
|
19
|
|
-class Promotion(models.Model):
|
|
|
15
|
+class AbstractPromotion(models.Model):
|
|
20
|
16
|
"""
|
|
21
|
17
|
Abstract base promotion that defines the interface
|
|
22
|
18
|
that subclasses must implement.
|
|
|
@@ -40,36 +36,50 @@ class Promotion(models.Model):
|
|
40
|
36
|
return {}
|
|
41
|
37
|
|
|
42
|
38
|
|
|
43
|
|
-class Banner(Promotion):
|
|
|
39
|
+class RawHTML(AbstractPromotion):
|
|
|
40
|
+ """
|
|
|
41
|
+ Simple promotion - just raw HTML
|
|
|
42
|
+ """
|
|
|
43
|
+ name = models.CharField(_("Name"), max_length=128)
|
|
|
44
|
+ body = models.TextField(_("HTML"))
|
|
|
45
|
+ date_created = models.DateTimeField(auto_now_add=True)
|
|
|
46
|
+
|
|
|
47
|
+
|
|
|
48
|
+class Image(AbstractPromotion):
|
|
|
49
|
+ """
|
|
|
50
|
+ An image promotion is simply a named image which has an optional
|
|
|
51
|
+ link to another part of the site (or another site).
|
|
44
|
52
|
|
|
|
53
|
+ This can be used to model both banners and pods.
|
|
|
54
|
+ """
|
|
45
|
55
|
name = models.CharField(_("Name"), max_length=128)
|
|
46
|
56
|
link_url = ExtendedURLField(blank=True, null=True, help_text="""This is
|
|
47
|
57
|
where this promotion links to""")
|
|
48
|
|
- image = models.ImageField(upload_to=BANNER_FOLDER, blank=True, null=True)
|
|
|
58
|
+ image = models.ImageField(upload_to=settings.OSCAR_PROMOTION_FOLDER, blank=True, null=True)
|
|
49
|
59
|
date_created = models.DateTimeField(auto_now_add=True)
|
|
50
|
60
|
|
|
51
|
61
|
def __unicode__(self):
|
|
52
|
62
|
return self.name
|
|
53
|
63
|
|
|
54
|
|
-
|
|
55
|
|
-class Pod(Promotion):
|
|
56
|
64
|
|
|
|
65
|
+class MultiImage(AbstractPromotion):
|
|
|
66
|
+ """
|
|
|
67
|
+ A multi-image promotion is simply a collection of image promotions
|
|
|
68
|
+ that are rendered in a specific way. This models things like
|
|
|
69
|
+ rotating banners.
|
|
|
70
|
+ """
|
|
57
|
71
|
name = models.CharField(_("Name"), max_length=128)
|
|
58
|
|
- link_url = ExtendedURLField(blank=True, null=True, help_text="""This is
|
|
59
|
|
- where this promotion links to""")
|
|
60
|
|
- image = models.ImageField(upload_to=BANNER_FOLDER, blank=True, null=True)
|
|
61
|
|
- date_created = models.DateTimeField(auto_now_add=True)
|
|
|
72
|
+ tabs = models.ManyToManyField('promotions.Image', null=True, blank=True)
|
|
62
|
73
|
|
|
63
|
74
|
def __unicode__(self):
|
|
64
|
75
|
return self.name
|
|
65
|
76
|
|
|
66
|
77
|
|
|
67
|
|
-class AbstractProductList(Promotion):
|
|
|
78
|
+class AbstractProductList(AbstractPromotion):
|
|
68
|
79
|
"""
|
|
69
|
80
|
Abstract superclass for promotions which are essentially a list
|
|
70
|
81
|
of products.
|
|
71
|
82
|
"""
|
|
72
|
|
-
|
|
73
|
83
|
name = models.CharField(_("Title"), max_length=255)
|
|
74
|
84
|
description = models.TextField(null=True, blank=True)
|
|
75
|
85
|
link_url = ExtendedURLField(blank=True, null=True)
|
|
|
@@ -83,7 +93,10 @@ class AbstractProductList(Promotion):
|
|
83
|
93
|
|
|
84
|
94
|
|
|
85
|
95
|
class HandPickedProductList(AbstractProductList):
|
|
86
|
|
-
|
|
|
96
|
+ """
|
|
|
97
|
+ A hand-picked product list is a list of manually selected
|
|
|
98
|
+ products.
|
|
|
99
|
+ """
|
|
87
|
100
|
products = models.ManyToManyField('product.Item', through='OrderedProduct', blank=True, null=True)
|
|
88
|
101
|
|
|
89
|
102
|
|
|
|
@@ -118,7 +131,7 @@ class OrderedProductList(models.Model):
|
|
118
|
131
|
ordering = ('display_order',)
|
|
119
|
132
|
|
|
120
|
133
|
|
|
121
|
|
-class TabbedBlock(Promotion):
|
|
|
134
|
+class TabbedBlock(AbstractPromotion):
|
|
122
|
135
|
|
|
123
|
136
|
tabs = models.ManyToManyField('promotions.HandPickedProductList', through='OrderedProductList', null=True, blank=True)
|
|
124
|
137
|
date_created = models.DateTimeField(auto_now_add=True)
|
|
|
@@ -126,13 +139,6 @@ class TabbedBlock(Promotion):
|
|
126
|
139
|
|
|
127
|
140
|
# Linking models
|
|
128
|
141
|
|
|
129
|
|
-TOP, LEFT, RIGHT = ('Top', 'Left', 'Right')
|
|
130
|
|
-POSITION_CHOICES = (
|
|
131
|
|
- (TOP, _("Top of page")),
|
|
132
|
|
- (LEFT, _("Left-hand sidebar")),
|
|
133
|
|
- (RIGHT, _("Right-hand sidebar")),
|
|
134
|
|
-)
|
|
135
|
|
-
|
|
136
|
142
|
|
|
137
|
143
|
class LinkedPromotion(models.Model):
|
|
138
|
144
|
|
|
|
@@ -141,7 +147,7 @@ class LinkedPromotion(models.Model):
|
|
141
|
147
|
object_id = models.PositiveIntegerField()
|
|
142
|
148
|
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
|
143
|
149
|
|
|
144
|
|
- position = models.CharField(_("Position"), max_length=100, help_text="Position on page", choices=POSITION_CHOICES)
|
|
|
150
|
+ position = models.CharField(_("Position"), max_length=100, help_text="Position on page")
|
|
145
|
151
|
display_order = models.PositiveIntegerField(default=0)
|
|
146
|
152
|
clicks = models.PositiveIntegerField(default=0)
|
|
147
|
153
|
date_created = models.DateTimeField(auto_now_add=True)
|