Selaa lähdekoodia

Added payment models

master
David Winterbottom 15 vuotta sitten
commit
af3ddaa046
14 muutettua tiedostoa jossa 214 lisäystä ja 0 poistoa
  1. 8
    0
      .gitignore
  2. 0
    0
      __init__.py
  3. 0
    0
      core/__init__.py
  4. 3
    0
      core/models.py
  5. 23
    0
      core/tests.py
  6. 1
    0
      core/views.py
  7. 11
    0
      manage.py
  8. 0
    0
      payment/__init__.py
  9. 26
    0
      payment/models.py
  10. 23
    0
      payment/tests.py
  11. 1
    0
      payment/views.py
  12. 6
    0
      requirements.txt
  13. 96
    0
      settings.py
  14. 16
    0
      urls.py

+ 8
- 0
.gitignore Näytä tiedosto

@@ -0,0 +1,8 @@
1
+*.pyc
2
+local_settings.py
3
+fixtures/*
4
+assets/designs/*
5
+*.swp
6
+.project
7
+.pydevproject
8
+.settings

+ 0
- 0
__init__.py Näytä tiedosto


+ 0
- 0
core/__init__.py Näytä tiedosto


+ 3
- 0
core/models.py Näytä tiedosto

@@ -0,0 +1,3 @@
1
+from django.db import models
2
+
3
+# Create your models here.

+ 23
- 0
core/tests.py Näytä tiedosto

@@ -0,0 +1,23 @@
1
+"""
2
+This file demonstrates two different styles of tests (one doctest and one
3
+unittest). These will both pass when you run "manage.py test".
4
+
5
+Replace these with more appropriate tests for your application.
6
+"""
7
+
8
+from django.test import TestCase
9
+
10
+class SimpleTest(TestCase):
11
+    def test_basic_addition(self):
12
+        """
13
+        Tests that 1 + 1 always equals 2.
14
+        """
15
+        self.failUnlessEqual(1 + 1, 2)
16
+
17
+__test__ = {"doctest": """
18
+Another way to test that 1 + 1 is equal to 2.
19
+
20
+>>> 1 + 1 == 2
21
+True
22
+"""}
23
+

+ 1
- 0
core/views.py Näytä tiedosto

@@ -0,0 +1 @@
1
+# Create your views here.

+ 11
- 0
manage.py Näytä tiedosto

@@ -0,0 +1,11 @@
1
+#!/usr/bin/env python
2
+from django.core.management import execute_manager
3
+try:
4
+    import settings # Assumed to be in the same directory.
5
+except ImportError:
6
+    import sys
7
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
8
+    sys.exit(1)
9
+
10
+if __name__ == "__main__":
11
+    execute_manager(settings)

+ 0
- 0
payment/__init__.py Näytä tiedosto


+ 26
- 0
payment/models.py Näytä tiedosto

@@ -0,0 +1,26 @@
1
+from django.db import models
2
+
3
+
4
+class PaymentSource(models.Model):
5
+    order = models.ForeignKey('core.Order', related_name='payment_sources')
6
+    type = models.CharField(max_length=128)
7
+    initial_amount = models.IntegerField()
8
+    balance = models.IntegerField()
9
+    reference = models.CharField(max_length=128, blank=True, null=True)
10
+    
11
+    def __unicode__(self):
12
+        description = "Payment of %.2f from %s" % (self.initial_amount, self.type)
13
+        if self.reference:
14
+            description += " (reference: %s)" % self.reference
15
+        return description
16
+    
17
+    
18
+class PaymentSourceTransaction(models.Model):
19
+    source = models.ForeignKey('payment.PaymentSource', related_name='transactions')
20
+    type = models.CharField(max_length=128, blank=True)
21
+    delta_amount = models.FloatField()
22
+    reference = models.CharField(max_length=128)
23
+    transaction_date = models.DateField()
24
+    
25
+    def __unicode__(self):
26
+        return "Transaction of %.2f" % self.delta_amount

+ 23
- 0
payment/tests.py Näytä tiedosto

@@ -0,0 +1,23 @@
1
+"""
2
+This file demonstrates two different styles of tests (one doctest and one
3
+unittest). These will both pass when you run "manage.py test".
4
+
5
+Replace these with more appropriate tests for your application.
6
+"""
7
+
8
+from django.test import TestCase
9
+
10
+class SimpleTest(TestCase):
11
+    def test_basic_addition(self):
12
+        """
13
+        Tests that 1 + 1 always equals 2.
14
+        """
15
+        self.failUnlessEqual(1 + 1, 2)
16
+
17
+__test__ = {"doctest": """
18
+Another way to test that 1 + 1 is equal to 2.
19
+
20
+>>> 1 + 1 == 2
21
+True
22
+"""}
23
+

+ 1
- 0
payment/views.py Näytä tiedosto

@@ -0,0 +1 @@
1
+# Create your views here.

+ 6
- 0
requirements.txt Näytä tiedosto

@@ -0,0 +1,6 @@
1
+Django==1.2.3
2
+MySQL-python==1.2.3
3
+South==0.7.3
4
+wsgiref==0.1.2
5
+yolk==0.4.1
6
+django_extensions==0.5

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

@@ -0,0 +1,96 @@
1
+# Django settings for peterson project.
2
+
3
+DEBUG = True
4
+TEMPLATE_DEBUG = DEBUG
5
+
6
+ADMINS = (
7
+    # ('Your Name', 'your_email@domain.com'),
8
+)
9
+
10
+MANAGERS = ADMINS
11
+
12
+DATABASES = {
13
+    'default': {
14
+        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
15
+        'NAME': '',                      # Or path to database file if using sqlite3.
16
+        'USER': '',                      # Not used with sqlite3.
17
+        'PASSWORD': '',                  # Not used with sqlite3.
18
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
19
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
20
+    }
21
+}
22
+
23
+# Local time zone for this installation. Choices can be found here:
24
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
25
+# although not all choices may be available on all operating systems.
26
+# On Unix systems, a value of None will cause Django to use the same
27
+# timezone as the operating system.
28
+# If running in a Windows environment this must be set to the same as your
29
+# system time zone.
30
+TIME_ZONE = 'America/Chicago'
31
+
32
+# Language code for this installation. All choices can be found here:
33
+# http://www.i18nguy.com/unicode/language-identifiers.html
34
+LANGUAGE_CODE = 'en-us'
35
+
36
+SITE_ID = 1
37
+
38
+# If you set this to False, Django will make some optimizations so as not
39
+# to load the internationalization machinery.
40
+USE_I18N = True
41
+
42
+# If you set this to False, Django will not format dates, numbers and
43
+# calendars according to the current locale
44
+USE_L10N = True
45
+
46
+# Absolute path to the directory that holds media.
47
+# Example: "/home/media/media.lawrence.com/"
48
+MEDIA_ROOT = ''
49
+
50
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
51
+# trailing slash if there is a path component (optional in other cases).
52
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
53
+MEDIA_URL = ''
54
+
55
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
56
+# trailing slash.
57
+# Examples: "http://foo.com/media/", "/media/".
58
+ADMIN_MEDIA_PREFIX = '/media/'
59
+
60
+# Make this unique, and don't share it with anybody.
61
+SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
62
+
63
+# List of callables that know how to import templates from various sources.
64
+TEMPLATE_LOADERS = (
65
+    'django.template.loaders.filesystem.Loader',
66
+    'django.template.loaders.app_directories.Loader',
67
+#     'django.template.loaders.eggs.Loader',
68
+)
69
+
70
+MIDDLEWARE_CLASSES = (
71
+    'django.middleware.common.CommonMiddleware',
72
+    'django.contrib.sessions.middleware.SessionMiddleware',
73
+    'django.middleware.csrf.CsrfViewMiddleware',
74
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
75
+    'django.contrib.messages.middleware.MessageMiddleware',
76
+)
77
+
78
+ROOT_URLCONF = 'peterson.urls'
79
+
80
+TEMPLATE_DIRS = (
81
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
82
+    # Always use forward slashes, even on Windows.
83
+    # Don't forget to use absolute paths, not relative paths.
84
+)
85
+
86
+INSTALLED_APPS = (
87
+    'django.contrib.auth',
88
+    'django.contrib.contenttypes',
89
+    'django.contrib.sessions',
90
+    'django.contrib.sites',
91
+    'django.contrib.messages',
92
+    # Uncomment the next line to enable the admin:
93
+    # 'django.contrib.admin',
94
+    # Uncomment the next line to enable admin documentation:
95
+    # 'django.contrib.admindocs',
96
+)

+ 16
- 0
urls.py Näytä tiedosto

@@ -0,0 +1,16 @@
1
+from django.conf.urls.defaults import *
2
+
3
+# Uncomment the next two lines to enable the admin:
4
+# from django.contrib import admin
5
+# admin.autodiscover()
6
+
7
+urlpatterns = patterns('',
8
+    # Example:
9
+    # (r'^peterson/', include('peterson.foo.urls')),
10
+
11
+    # Uncomment the admin/doc line below to enable admin documentation:
12
+    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
13
+
14
+    # Uncomment the next line to enable the admin:
15
+    # (r'^admin/', include(admin.site.urls)),
16
+)

Loading…
Peruuta
Tallenna