3
3
from graphene_django import DjangoObjectType
4
4
from graphene import relay
5
5
from nxtbn .core .models import SiteSettings
6
- from nxtbn .order .models import Address , Order , OrderLineItem
6
+ from nxtbn .order .models import Address , Order , OrderDeviceMeta , OrderLineItem
7
7
8
8
from nxtbn .order .admin_filters import OrderFilter
9
9
@@ -25,12 +25,78 @@ class Meta:
25
25
)
26
26
27
27
28
+ class OrderLineItemsType (DjangoObjectType ):
29
+ db_id = graphene .Int (source = 'id' )
30
+ humanize_total_price = graphene .String ()
31
+ humanize_price_per_unit = graphene .String ()
32
+
33
+ def resolve_humanize_total_price (self , info ):
34
+ return self .humanize_total_price ()
35
+
36
+ def resolve_humanize_price_per_unit (self , info ):
37
+ return self .humanize_price_per_unit ()
38
+ class Meta :
39
+ model = OrderLineItem
40
+ fields = (
41
+ 'id' ,
42
+ 'quantity' ,
43
+ 'variant' ,
44
+ 'total_price' ,
45
+ 'price_per_unit' ,
46
+ )
47
+
28
48
class OrderType (DjangoObjectType ):
29
49
db_id = graphene .Int (source = 'id' )
30
50
humanize_total_price = graphene .String ()
51
+ line_items = graphene .List (OrderLineItemsType )
52
+ overcharged_amount = graphene .String ()
53
+ is_overdue = graphene .Boolean ()
54
+ payment_method = graphene .String ()
55
+ humanize_total_price = graphene .String ()
56
+ humanize_total_shipping_cost = graphene .String ()
57
+ humanize_total_discounted_amount = graphene .String ()
58
+ humanize_total_tax = graphene .String ()
59
+ humanize_total_paid_amount = graphene .String ()
60
+ due = graphene .String ()
61
+ total_price_without_symbol = graphene .String ()
62
+
63
+ def resolve_total_price_without_symbol (self , info ):
64
+ return self .humanize_total_price (locale = '' )
31
65
32
66
def resolve_humanize_total_price (self , info ):
33
67
return self .humanize_total_price ()
68
+
69
+ def resolve_line_items (self , info ):
70
+ return self .line_items .all ()
71
+
72
+ def resolve_overcharged_amount (self , info ):
73
+ return self .get_overcharged_amount ()
74
+
75
+ def resolve_is_overdue (self , info ):
76
+ return self .is_overdue ()
77
+
78
+ def resolve_payment_method (self , info ):
79
+ return self .get_payment_method ()
80
+
81
+ def resolve_humanize_total_price (self , info ):
82
+ return self .humanize_total_price ()
83
+
84
+ def resolve_humanize_total_shipping_cost (self , info ):
85
+ return self .humanize_total_shipping_cost ()
86
+
87
+ def resolve_humanize_total_discounted_amount (self , info ):
88
+ return self .humanize_total_discounted_amount ()
89
+
90
+ def resolve_humanize_total_tax (self , info ):
91
+ return self .humanize_total_tax ()
92
+
93
+ def resolve_humanize_total_paid_amount (self , info ):
94
+ return self .humanize_total_paid_amount ()
95
+
96
+ def resolve_due (self , info ):
97
+ return self .get_due ()
98
+
99
+
34
100
class Meta :
35
101
model = Order
36
102
fields = (
@@ -58,6 +124,8 @@ class Meta:
58
124
'reservation_status' ,
59
125
'note' ,
60
126
'comment' ,
127
+ 'user' ,
128
+ 'due'
61
129
)
62
130
interfaces = (relay .Node ,)
63
131
filterset_class = OrderFilter
@@ -131,4 +199,24 @@ class Meta:
131
199
'preferred_payment_method' ,
132
200
'reservation_status' ,
133
201
'note' ,
202
+ )
203
+
204
+
205
+ class OrderDeviceMetaType (DjangoObjectType ):
206
+ db_id = graphene .Int (source = 'id' )
207
+ class Meta :
208
+ model = OrderDeviceMeta
209
+ fields = (
210
+ 'id' ,
211
+ 'order' ,
212
+ 'ip_address' ,
213
+ 'user_agent' ,
214
+ 'browser' ,
215
+ 'browser_version' ,
216
+ 'operating_system' ,
217
+ 'device_type' ,
218
+ )
219
+ interfaces = (relay .Node ,)
220
+ filter_fields = (
221
+ 'order__alias' ,
134
222
)
0 commit comments