瀏覽代碼

Added some fixture data and updated payment models to make the payment source a model itself

master
David Winterbottom 15 年之前
父節點
當前提交
050aed5c9b
共有 4 個文件被更改,包括 25 次插入6 次删除
  1. 5
    1
      TODO
  2. 1
    0
      oscar/fixtures/sample-product-and-orders.json
  3. 15
    4
      oscar/payment/abstract_models.py
  4. 4
    1
      oscar/payment/models.py

+ 5
- 1
TODO 查看文件

4
 - Country field for addresses
4
 - Country field for addresses
5
 
5
 
6
 Sample shop:
6
 Sample shop:
7
-- How to have the admin site reflect your local models
7
+- How to have the admin site reflect your local models
8
+- Allow admin to be customised for your local project - can we inherit from oscar admin and add stuff?
9
+
10
+Products:
11
+- How to temporarily disable products so they aren't visible

+ 1
- 0
oscar/fixtures/sample-product-and-orders.json
文件差異過大導致無法顯示
查看文件


+ 15
- 4
oscar/payment/abstract_models.py 查看文件

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
-
6
 class AbstractSource(models.Model):
5
 class AbstractSource(models.Model):
7
     """
6
     """
8
     A source of payment for an order.  
7
     A source of payment for an order.  
13
     entry.
12
     entry.
14
     """
13
     """
15
     order = models.ForeignKey('order.Order', related_name='sources')
14
     order = models.ForeignKey('order.Order', related_name='sources')
16
-    type = models.CharField(max_length=128)
17
-    initial_amount = models.IntegerField()
18
-    balance = models.IntegerField()
15
+    type = models.ForeignKey('payment.SourceType')
16
+    initial_amount = models.DecimalField(decimal_places=2, max_digits=12)
17
+    balance = models.DecimalField(decimal_places=2, max_digits=12)
19
     reference = models.CharField(max_length=128, blank=True, null=True)
18
     reference = models.CharField(max_length=128, blank=True, null=True)
20
     
19
     
21
     class Meta:
20
     class Meta:
27
             description += " (reference: %s)" % self.reference
26
             description += " (reference: %s)" % self.reference
28
         return description
27
         return description
29
     
28
     
29
+class AbstractSourceType(models.Model):
30
+    """
31
+    A type of payment source (eg Bankcard, Business account, Gift card)
32
+    """
33
+    name = models.CharField(max_length=128)
34
+
35
+    class Meta:
36
+        abstract = True
37
+
38
+    def __unicode__(self):
39
+        return self.name
40
+
30
 class AbstractTransaction(models.Model):
41
 class AbstractTransaction(models.Model):
31
     """
42
     """
32
     A transaction for payment sources which need a secondary 'transaction' to actually take the money
43
     A transaction for payment sources which need a secondary 'transaction' to actually take the money

+ 4
- 1
oscar/payment/models.py 查看文件

1
-from oscar.payment.abstract_models import AbstractSource, AbstractTransaction
1
+from oscar.payment.abstract_models import *
2
 
2
 
3
 class Source(AbstractSource):
3
 class Source(AbstractSource):
4
     pass
4
     pass
5
 
5
 
6
+class SourceType(AbstractSourceType):
7
+    pass
8
+
6
 class Transaction(AbstractTransaction):
9
 class Transaction(AbstractTransaction):
7
     pass
10
     pass
8
 
11
 

Loading…
取消
儲存