Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
709692eb
Commit
709692eb
authored
Apr 25, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71 from edx/order-history
Tracking Order and Line History in Database
parents
493a2148
5803ffc3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
17 deletions
+106
-17
ecommerce/extensions/order/migrations/0007_create_history_tables.py
+92
-0
ecommerce/extensions/order/models.py
+7
-1
ecommerce/settings/base.py
+6
-16
requirements/base.txt
+1
-0
No files found.
ecommerce/extensions/order/migrations/0007_create_history_tables.py
0 → 100644
View file @
709692eb
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
import
oscar.core.utils
import
django.db.models.deletion
from
django.conf
import
settings
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'partner'
,
'0003_auto_20150223_1130'
),
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'basket'
,
'0004_auto_20141007_2032'
),
(
'sites'
,
'0001_initial'
),
(
'catalogue'
,
'0002_auto_20150223_1052'
),
(
'order'
,
'0006_paymentevent_processor_name'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'HistoricalLine'
,
fields
=
[
(
'id'
,
models
.
IntegerField
(
verbose_name
=
'ID'
,
db_index
=
True
,
auto_created
=
True
,
blank
=
True
)),
(
'partner_name'
,
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'Partner name'
,
blank
=
True
)),
(
'partner_sku'
,
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'Partner SKU'
)),
(
'partner_line_reference'
,
models
.
CharField
(
help_text
=
'This is the item number that the partner uses within their system'
,
max_length
=
128
,
verbose_name
=
'Partner reference'
,
blank
=
True
)),
(
'partner_line_notes'
,
models
.
TextField
(
verbose_name
=
'Partner Notes'
,
blank
=
True
)),
(
'title'
,
models
.
CharField
(
max_length
=
255
,
verbose_name
=
'Title'
)),
(
'upc'
,
models
.
CharField
(
max_length
=
128
,
null
=
True
,
verbose_name
=
'UPC'
,
blank
=
True
)),
(
'quantity'
,
models
.
PositiveIntegerField
(
default
=
1
,
verbose_name
=
'Quantity'
)),
(
'line_price_incl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Price (inc. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'line_price_excl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Price (excl. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'line_price_before_discounts_incl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Price before discounts (inc. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'line_price_before_discounts_excl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Price before discounts (excl. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'unit_cost_price'
,
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'Unit Cost Price'
,
max_digits
=
12
,
decimal_places
=
2
,
blank
=
True
)),
(
'unit_price_incl_tax'
,
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'Unit Price (inc. tax)'
,
max_digits
=
12
,
decimal_places
=
2
,
blank
=
True
)),
(
'unit_price_excl_tax'
,
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'Unit Price (excl. tax)'
,
max_digits
=
12
,
decimal_places
=
2
,
blank
=
True
)),
(
'unit_retail_price'
,
models
.
DecimalField
(
null
=
True
,
verbose_name
=
'Unit Retail Price'
,
max_digits
=
12
,
decimal_places
=
2
,
blank
=
True
)),
(
'status'
,
models
.
CharField
(
max_length
=
255
,
verbose_name
=
'Status'
,
blank
=
True
)),
(
'est_dispatch_date'
,
models
.
DateField
(
null
=
True
,
verbose_name
=
'Estimated Dispatch Date'
,
blank
=
True
)),
(
'history_id'
,
models
.
AutoField
(
serialize
=
False
,
primary_key
=
True
)),
(
'history_date'
,
models
.
DateTimeField
()),
(
'history_type'
,
models
.
CharField
(
max_length
=
1
,
choices
=
[(
'+'
,
'Created'
),
(
'~'
,
'Changed'
),
(
'-'
,
'Deleted'
)])),
(
'history_user'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
settings
.
AUTH_USER_MODEL
,
null
=
True
)),
(
'order'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'order.Order'
,
null
=
True
)),
(
'partner'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'partner.Partner'
,
null
=
True
)),
(
'product'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'catalogue.Product'
,
null
=
True
)),
(
'stockrecord'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'partner.StockRecord'
,
null
=
True
)),
],
options
=
{
'ordering'
:
(
'-history_date'
,
'-history_id'
),
'get_latest_by'
:
'history_date'
,
'verbose_name'
:
'historical Order Line'
,
},
bases
=
(
models
.
Model
,),
),
migrations
.
CreateModel
(
name
=
'HistoricalOrder'
,
fields
=
[
(
'id'
,
models
.
IntegerField
(
verbose_name
=
'ID'
,
db_index
=
True
,
auto_created
=
True
,
blank
=
True
)),
(
'number'
,
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'Order number'
,
db_index
=
True
)),
(
'currency'
,
models
.
CharField
(
default
=
oscar
.
core
.
utils
.
get_default_currency
,
max_length
=
12
,
verbose_name
=
'Currency'
)),
(
'total_incl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Order total (inc. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'total_excl_tax'
,
models
.
DecimalField
(
verbose_name
=
'Order total (excl. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'shipping_incl_tax'
,
models
.
DecimalField
(
default
=
0
,
verbose_name
=
'Shipping charge (inc. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'shipping_excl_tax'
,
models
.
DecimalField
(
default
=
0
,
verbose_name
=
'Shipping charge (excl. tax)'
,
max_digits
=
12
,
decimal_places
=
2
)),
(
'shipping_method'
,
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'Shipping method'
,
blank
=
True
)),
(
'shipping_code'
,
models
.
CharField
(
default
=
b
''
,
max_length
=
128
,
blank
=
True
)),
(
'status'
,
models
.
CharField
(
max_length
=
100
,
verbose_name
=
'Status'
,
blank
=
True
)),
(
'guest_email'
,
models
.
EmailField
(
max_length
=
75
,
verbose_name
=
'Guest email address'
,
blank
=
True
)),
(
'date_placed'
,
models
.
DateTimeField
(
db_index
=
True
,
editable
=
False
,
blank
=
True
)),
(
'payment_processor'
,
models
.
CharField
(
max_length
=
32
,
null
=
True
,
verbose_name
=
'Payment Processor'
,
blank
=
True
)),
(
'history_id'
,
models
.
AutoField
(
serialize
=
False
,
primary_key
=
True
)),
(
'history_date'
,
models
.
DateTimeField
()),
(
'history_type'
,
models
.
CharField
(
max_length
=
1
,
choices
=
[(
'+'
,
'Created'
),
(
'~'
,
'Changed'
),
(
'-'
,
'Deleted'
)])),
(
'basket'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'basket.Basket'
,
null
=
True
)),
(
'billing_address'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'order.BillingAddress'
,
null
=
True
)),
(
'history_user'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
settings
.
AUTH_USER_MODEL
,
null
=
True
)),
(
'shipping_address'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'order.ShippingAddress'
,
null
=
True
)),
(
'site'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
'sites.Site'
,
null
=
True
)),
(
'user'
,
models
.
ForeignKey
(
related_name
=
'+'
,
on_delete
=
django
.
db
.
models
.
deletion
.
DO_NOTHING
,
db_constraint
=
False
,
blank
=
True
,
to
=
settings
.
AUTH_USER_MODEL
,
null
=
True
)),
],
options
=
{
'ordering'
:
(
'-history_date'
,
'-history_id'
),
'get_latest_by'
:
'history_date'
,
'verbose_name'
:
'historical Order'
,
},
bases
=
(
models
.
Model
,),
),
]
ecommerce/extensions/order/models.py
View file @
709692eb
# noinspection PyUnresolvedReferences
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
oscar.apps.order.abstract_models
import
AbstractOrder
,
AbstractPaymentEvent
from
oscar.apps.order.abstract_models
import
AbstractOrder
,
AbstractPaymentEvent
,
AbstractLine
from
simple_history.models
import
HistoricalRecords
from
ecommerce.extensions.fulfillment.status
import
ORDER
class
Order
(
AbstractOrder
):
payment_processor
=
models
.
CharField
(
_
(
"Payment Processor"
),
max_length
=
32
,
blank
=
True
,
null
=
True
)
history
=
HistoricalRecords
()
@property
def
can_retry_fulfillment
(
self
):
...
...
@@ -46,6 +48,10 @@ class Order(AbstractOrder):
class
PaymentEvent
(
AbstractPaymentEvent
):
processor_name
=
models
.
CharField
(
_
(
"Payment Processor"
),
max_length
=
32
,
blank
=
True
,
null
=
True
)
class
Line
(
AbstractLine
):
history
=
HistoricalRecords
()
# If two models with the same name are declared within an app, Django will only use the first one.
# noinspection PyUnresolvedReferences
from
oscar.apps.order.models
import
*
# noqa pylint: disable=wildcard-import,unused-wildcard-import
ecommerce/settings/base.py
View file @
709692eb
...
...
@@ -193,6 +193,7 @@ MIDDLEWARE_CLASSES = (
'oscar.apps.basket.middleware.BasketMiddleware'
,
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
,
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware'
,
'simple_history.middleware.HistoryRequestMiddleware'
,
)
# END MIDDLEWARE CONFIGURATION
...
...
@@ -223,29 +224,18 @@ OAUTH2_PROVIDER_URL = None
# APP CONFIGURATION
DJANGO_APPS
=
[
# Default Django apps
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.flatpages'
,
'django.contrib.humanize'
,
'django.contrib.sessions'
,
'django.contrib.sites'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.flatpages'
,
# Useful template tags
'django.contrib.humanize'
,
# Django REST framework
'compressor'
,
'rest_framework'
,
# Admin panel and documentation
'django.contrib.admin'
,
# Feature gating
'simple_history'
,
'waffle'
,
# Static file compression
'compressor'
,
]
# Apps specific to this project go here.
...
...
requirements/base.txt
View file @
709692eb
...
...
@@ -4,6 +4,7 @@ django-appconf==0.6
django_compressor==1.4
django-libsass==0.2
django-model-utils==1.5.0
django_simple_history==1.6.1
django-waffle==0.10
djangorestframework==3.1.0
djangorestframework-jwt==1.4.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment