Просмотр исходного кода

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

master
David Winterbottom 15 лет назад
Родитель
Сommit
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,4 +4,8 @@ Fields to write:
4 4
 - Country field for addresses
5 5
 
6 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,7 +2,6 @@ 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
-
6 5
 class AbstractSource(models.Model):
7 6
     """
8 7
     A source of payment for an order.  
@@ -13,9 +12,9 @@ class AbstractSource(models.Model):
13 12
     entry.
14 13
     """
15 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 18
     reference = models.CharField(max_length=128, blank=True, null=True)
20 19
     
21 20
     class Meta:
@@ -27,6 +26,18 @@ class AbstractSource(models.Model):
27 26
             description += " (reference: %s)" % self.reference
28 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 41
 class AbstractTransaction(models.Model):
31 42
     """
32 43
     A transaction for payment sources which need a secondary 'transaction' to actually take the money

+ 4
- 1
oscar/payment/models.py Просмотреть файл

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

Загрузка…
Отмена
Сохранить