trex-model 1.5.13__tar.gz → 1.5.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of trex-model might be problematic. Click here for more details.
- {trex-model-1.5.13/trex_model.egg-info → trex-model-1.5.15}/PKG-INFO +5 -10
- {trex-model-1.5.13 → trex-model-1.5.15}/setup.py +1 -1
- {trex-model-1.5.13 → trex-model-1.5.15/trex_model.egg-info}/PKG-INFO +5 -10
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/customer_models.py +16 -1
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/helper/reward_transaction_helper.py +4 -1
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/lucky_draw_models.py +14 -1
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/redeem_models.py +37 -1
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/reward_models.py +76 -5
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/voucher_models.py +8 -1
- {trex-model-1.5.13 → trex-model-1.5.15}/LICENSE +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/MANIFEST.in +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/README.md +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/setup.cfg +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/helper/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/import_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/merchant_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/message_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/ndb_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/product_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/program_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/system_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/task_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/test_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/user_models.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/merchant_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/program_conf.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.15
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Description: This is database modelusing google datastore mode module
|
|
10
|
+
|
|
11
|
+
Platform: UNKNOWN
|
|
8
12
|
Classifier: Programming Language :: Python :: 3
|
|
9
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
14
|
Classifier: Operating System :: OS Independent
|
|
11
15
|
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: google-cloud-firestore
|
|
14
|
-
Requires-Dist: google_cloud_datastore
|
|
15
|
-
Requires-Dist: google-cloud-ndb
|
|
16
|
-
Requires-Dist: six
|
|
17
|
-
Requires-Dist: trex-lib
|
|
18
|
-
Requires-Dist: flask-login==0.6.2
|
|
19
|
-
|
|
20
|
-
This is database modelusing google datastore mode module
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.15
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Description: This is database modelusing google datastore mode module
|
|
10
|
+
|
|
11
|
+
Platform: UNKNOWN
|
|
8
12
|
Classifier: Programming Language :: Python :: 3
|
|
9
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
14
|
Classifier: Operating System :: OS Independent
|
|
11
15
|
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: google-cloud-firestore
|
|
14
|
-
Requires-Dist: google_cloud_datastore
|
|
15
|
-
Requires-Dist: google-cloud-ndb
|
|
16
|
-
Requires-Dist: six
|
|
17
|
-
Requires-Dist: trex-lib
|
|
18
|
-
Requires-Dist: flask-login==0.6.2
|
|
19
|
-
|
|
20
|
-
This is database modelusing google datastore mode module
|
|
@@ -775,9 +775,14 @@ class CustomerMembership(BaseNModel, DictModel):
|
|
|
775
775
|
def merchant_membership_key(self):
|
|
776
776
|
return self.merchant_membership.urlsafe().decode('utf-8')
|
|
777
777
|
|
|
778
|
+
@property
|
|
779
|
+
def customer_key(self):
|
|
780
|
+
return self.key.parent().urlsafe().decode('utf-8')
|
|
781
|
+
|
|
778
782
|
@property
|
|
779
783
|
def merchant_acct_entity(self):
|
|
780
|
-
|
|
784
|
+
if self.merchant_acct:
|
|
785
|
+
return MerchantAcct.fetch(self.merchant_acct.urlsafe())
|
|
781
786
|
|
|
782
787
|
@property
|
|
783
788
|
def merchant_membership_entity(self):
|
|
@@ -855,6 +860,16 @@ class CustomerMembership(BaseNModel, DictModel):
|
|
|
855
860
|
valid_memberships_list.append(m)
|
|
856
861
|
|
|
857
862
|
|
|
863
|
+
return valid_memberships_list
|
|
864
|
+
|
|
865
|
+
@staticmethod
|
|
866
|
+
def list_by_customer(customer):
|
|
867
|
+
memberships_list = CustomerMembership.list_all_by_customer(customer)
|
|
868
|
+
valid_memberships_list = []
|
|
869
|
+
for m in memberships_list:
|
|
870
|
+
valid_memberships_list.append(m)
|
|
871
|
+
|
|
872
|
+
|
|
858
873
|
return valid_memberships_list
|
|
859
874
|
|
|
860
875
|
@staticmethod
|
|
@@ -23,7 +23,8 @@ from trexanalytics.bigquery_upstream_data_config import create_merchant_customer
|
|
|
23
23
|
create_merchant_customer_transaction_upstream_for_merchant,\
|
|
24
24
|
create_merchant_customer_redemption_upstream_for_merchant,\
|
|
25
25
|
create_merchant_customer_prepaid_upstream_for_merchant,\
|
|
26
|
-
create_merchant_customer_redemption_reverted_upstream_for_merchant
|
|
26
|
+
create_merchant_customer_redemption_reverted_upstream_for_merchant,\
|
|
27
|
+
create_revert_entitled_customer_voucher_upstream_for_merchant
|
|
27
28
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership
|
|
28
29
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction,\
|
|
29
30
|
SalesTransaction
|
|
@@ -920,6 +921,8 @@ def revert_transaction(transaction_details, reverted_by, reverted_datetime=None,
|
|
|
920
921
|
p.reverted_by_username = reverted_by.username
|
|
921
922
|
p.put()
|
|
922
923
|
|
|
924
|
+
create_revert_entitled_customer_voucher_upstream_for_merchant(p)
|
|
925
|
+
|
|
923
926
|
entitled_voucher_summary = update_customer_entiteld_voucher_summary_after_reverted_voucher(entitled_voucher_summary, p)
|
|
924
927
|
|
|
925
928
|
voucher_key = p.entitled_voucher_key
|
|
@@ -496,6 +496,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
496
496
|
merchant_acct = ndb.KeyProperty(name="merchant_acct", kind=MerchantAcct)
|
|
497
497
|
transact_outlet = ndb.KeyProperty(name="transact_outlet", kind=Outlet)
|
|
498
498
|
ticket_key = ndb.StringProperty(required=True)
|
|
499
|
+
program_key = ndb.StringProperty(required=False)
|
|
499
500
|
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
500
501
|
used_datetime = ndb.DateTimeProperty(required=False)
|
|
501
502
|
expiry_date = ndb.DateProperty(required=True)
|
|
@@ -563,6 +564,17 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
563
564
|
def count_entiteld_by_customer_acct_by_date_range(customer_acct, start_datetime=None, end_datetime=None):
|
|
564
565
|
return LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.created_datetime>=start_datetime, LuckyDrawTicket.created_datetime<end_datetime), ancestor=customer_acct.create_ndb_key()).count(limit=model_conf.MAX_FETCH_RECORD)
|
|
565
566
|
|
|
567
|
+
@staticmethod
|
|
568
|
+
def count_by_merchant_acct(merchant_acct):
|
|
569
|
+
return LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.merchant_acct==merchant_acct.create_ndb_key())).count(limit=model_conf.MAX_FETCH_RECORD)
|
|
570
|
+
|
|
571
|
+
@staticmethod
|
|
572
|
+
def list_by_merchant_acct_with_cursor(merchant_acct, offset=0, limit=50, start_cursor=None):
|
|
573
|
+
query = LuckyDrawTicket.query(ndb.AND(LuckyDrawTicket.merchant_acct==merchant_acct.create_ndb_key(),))
|
|
574
|
+
(result, next_cursor) = LuckyDrawTicket.list_all_with_condition_query(query, start_cursor=start_cursor, return_with_cursor=True, offset=offset, limit=limit)
|
|
575
|
+
|
|
576
|
+
return (result, next_cursor)
|
|
577
|
+
|
|
566
578
|
@staticmethod
|
|
567
579
|
def create_for_customer_from_sales_amount(customer_acct, sales_amount=None, merchant_acct=None, transact_outlet=None):
|
|
568
580
|
number_of_ticket = 0
|
|
@@ -665,6 +677,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
665
677
|
|
|
666
678
|
program = LuckyDrawTicket.__get_lucky_draw_program(merchant_acct.lucky_draw_configuration, customer_acct=customer_acct)
|
|
667
679
|
if program:
|
|
680
|
+
program_key = program.get('program_key')
|
|
668
681
|
prize_details_list = program.get('program_settings').get('prize_settings').get('prizes')
|
|
669
682
|
ticket_image_url = program.get('program_settings').get('ticket_image_url')
|
|
670
683
|
|
|
@@ -688,7 +701,7 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
688
701
|
expiry_date = expiry_date.date(),
|
|
689
702
|
ticket_key = random_string(16),
|
|
690
703
|
drawed_details = drawed_details,
|
|
691
|
-
|
|
704
|
+
program_key = program_key,
|
|
692
705
|
#created_by = created_by.create_ndb_key(),
|
|
693
706
|
#created_by_username = created_by_username,
|
|
694
707
|
)
|
|
@@ -227,6 +227,38 @@ class CustomerRedemption(BaseNModel, DictModel):
|
|
|
227
227
|
|
|
228
228
|
return CustomerRedemption.list_all_with_condition_query(query, offset=offset, limit=limit, start_cursor=start_cursor, return_with_cursor=return_with_cursor)
|
|
229
229
|
|
|
230
|
+
@staticmethod
|
|
231
|
+
def count_by_merchant_acct(merchant_acct, datetime_ranage_start=None, datetime_range_end=None):
|
|
232
|
+
if datetime_ranage_start and datetime_range_end:
|
|
233
|
+
result = CustomerRedemption.query(ndb.AND(
|
|
234
|
+
CustomerRedemption.merchant_acct==merchant_acct.create_ndb_key(),
|
|
235
|
+
CustomerRedemption.redeemed_datetime>=datetime_ranage_start,
|
|
236
|
+
CustomerRedemption.redeemed_datetime<datetime_range_end,
|
|
237
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
238
|
+
else:
|
|
239
|
+
result = CustomerRedemption.query(ndb.AND(
|
|
240
|
+
CustomerRedemption.merchant_acct==merchant_acct.create_ndb_key(),
|
|
241
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
return result
|
|
245
|
+
|
|
246
|
+
@staticmethod
|
|
247
|
+
def list_by_merchant_acct_with_cursor(merchant_acct, datetime_ranage_start=None, datetime_range_end=None, offset=0, limit=50, start_cursor=None):
|
|
248
|
+
if is_not_empty(datetime_ranage_start) and is_not_empty(datetime_range_end):
|
|
249
|
+
query = CustomerRedemption.query(ndb.AND(
|
|
250
|
+
CustomerRedemption.merchant_acct==merchant_acct.create_ndb_key(),
|
|
251
|
+
CustomerRedemption.redeemed_datetime>=datetime_ranage_start,
|
|
252
|
+
CustomerRedemption.redeemed_datetime<datetime_range_end,
|
|
253
|
+
))
|
|
254
|
+
else:
|
|
255
|
+
query = CustomerRedemption.query(ndb.AND(
|
|
256
|
+
CustomerRedemption.merchant_acct==merchant_acct.create_ndb_key(),
|
|
257
|
+
))
|
|
258
|
+
(result, next_cursor) = CustomerRedemption.list_all_with_condition_query(query, start_cursor=start_cursor, return_with_cursor=True, offset=offset, limit=limit)
|
|
259
|
+
|
|
260
|
+
return (result, next_cursor)
|
|
261
|
+
|
|
230
262
|
@staticmethod
|
|
231
263
|
def list_merchant_transaction(merchant_acct, offset=0, limit=conf.PAGINATION_SIZE, start_cursor=None, return_with_cursor=False, reverse_order=True):
|
|
232
264
|
if reverse_order:
|
|
@@ -507,7 +539,11 @@ class CustomerRedemption(BaseNModel, DictModel):
|
|
|
507
539
|
}
|
|
508
540
|
|
|
509
541
|
|
|
510
|
-
customer_entitled_voucher.redeem(redeemed_by,
|
|
542
|
+
customer_entitled_voucher.redeem(redeemed_by,
|
|
543
|
+
redeemed_datetime=redeemed_datetime,
|
|
544
|
+
redeemed_outlet=redeemed_outlet,
|
|
545
|
+
transaction_id=transaction_id,
|
|
546
|
+
)
|
|
511
547
|
|
|
512
548
|
transaction_id_list.append(customer_entitled_voucher.transaction_id)
|
|
513
549
|
|
|
@@ -60,6 +60,10 @@ class RewardEntitlement(BaseNModel, DictModel):
|
|
|
60
60
|
def is_removed(self):
|
|
61
61
|
return self.status == program_conf.REWARD_STATUS_REMOVED
|
|
62
62
|
|
|
63
|
+
@property
|
|
64
|
+
def is_reverted(self):
|
|
65
|
+
return self.status == program_conf.REWARD_STATUS_REVERTED
|
|
66
|
+
|
|
63
67
|
|
|
64
68
|
|
|
65
69
|
class CustomerEntitledReward(RewardEntitlement):
|
|
@@ -76,13 +80,24 @@ class CustomerEntitledReward(RewardEntitlement):
|
|
|
76
80
|
def entitled_customer_key(self):
|
|
77
81
|
return self.key.parent().urlsafe().decode('utf-8')
|
|
78
82
|
|
|
83
|
+
@property
|
|
84
|
+
def entitled_user_key(self):
|
|
85
|
+
return self.user_acct.urlsafe().decode('utf-8')
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def merchant_acct_key(self):
|
|
89
|
+
return self.merchant_acct.urlsafe().decode('utf-8')
|
|
90
|
+
|
|
79
91
|
@property
|
|
80
92
|
def entitled_customer_acct(self):
|
|
81
93
|
return Customer.fetch(self.key.parent().urlsafe())
|
|
82
94
|
|
|
83
95
|
@property
|
|
84
96
|
def reward_program_key(self):
|
|
85
|
-
|
|
97
|
+
if self.reward_program:
|
|
98
|
+
return self.reward_program.urlsafe().decode('utf-8')
|
|
99
|
+
else:
|
|
100
|
+
return ''
|
|
86
101
|
|
|
87
102
|
@property
|
|
88
103
|
def rewarded_by_merchant_acct_entity(self):
|
|
@@ -327,6 +342,13 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
327
342
|
'status', 'is_reverted', 'is_used',
|
|
328
343
|
]
|
|
329
344
|
|
|
345
|
+
@property
|
|
346
|
+
def redeemed_by_outlet_key(self):
|
|
347
|
+
if self.redeemed_by_outlet:
|
|
348
|
+
return self.redeemed_by_outlet.urlsafe().decode('utf-8')
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
330
352
|
@staticmethod
|
|
331
353
|
def list_by_transaction_id(transaction_id):
|
|
332
354
|
return CustomerEntitledVoucher.query(CustomerEntitledVoucher.transaction_id==transaction_id).fetch(limit=conf.MAX_FETCH_RECORD)
|
|
@@ -363,6 +385,53 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
363
385
|
|
|
364
386
|
return result
|
|
365
387
|
|
|
388
|
+
@staticmethod
|
|
389
|
+
def count_by_merchant_acct(merchant_acct, datetime_ranage_start=None, datetime_range_end=None):
|
|
390
|
+
if datetime_ranage_start and datetime_range_end:
|
|
391
|
+
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
392
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
393
|
+
CustomerEntitledVoucher.rewarded_datetime>=datetime_ranage_start,
|
|
394
|
+
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
395
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
396
|
+
else:
|
|
397
|
+
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
398
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
399
|
+
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
return result
|
|
403
|
+
|
|
404
|
+
@staticmethod
|
|
405
|
+
def list_by_merchant_acct(merchant_acct, datetime_range_start=None, datetime_range_end=None, offset=0, limit=50,):
|
|
406
|
+
if is_not_empty(datetime_range_start) and is_not_empty(datetime_range_end):
|
|
407
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
408
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
409
|
+
CustomerEntitledVoucher.rewarded_datetime>=datetime_range_start,
|
|
410
|
+
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
411
|
+
))
|
|
412
|
+
else:
|
|
413
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
414
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
415
|
+
))
|
|
416
|
+
return CustomerEntitledVoucher.list_all_with_condition_query(query, offset=offset, limit=limit)
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
@staticmethod
|
|
420
|
+
def list_by_merchant_acct_with_cursor(merchant_acct, datetime_range_start=None, datetime_range_end=None, offset=0, limit=50, start_cursor=None):
|
|
421
|
+
if is_not_empty(datetime_range_start) and is_not_empty(datetime_range_end):
|
|
422
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
423
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
424
|
+
CustomerEntitledVoucher.rewarded_datetime>=datetime_range_start,
|
|
425
|
+
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
426
|
+
))
|
|
427
|
+
else:
|
|
428
|
+
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
429
|
+
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
430
|
+
))
|
|
431
|
+
(result, next_cursor) = CustomerEntitledVoucher.list_all_with_condition_query(query, start_cursor=start_cursor, return_with_cursor=True, offset=offset, limit=limit)
|
|
432
|
+
|
|
433
|
+
return (result, next_cursor)
|
|
434
|
+
|
|
366
435
|
@staticmethod
|
|
367
436
|
def count_redeemed_by_merchant_voucher_and_passed_redeemed_datetime(customer, merchant_voucher, passed_redeemed_datetime):
|
|
368
437
|
|
|
@@ -384,7 +453,7 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
384
453
|
self.put()
|
|
385
454
|
|
|
386
455
|
|
|
387
|
-
def redeem(self, redeemed_by=None, redeemed_datetime=None):
|
|
456
|
+
def redeem(self, redeemed_by=None, redeemed_datetime=None, redeemed_outlet=None, transaction_id=None):
|
|
388
457
|
self.status = program_conf.REWARD_STATUS_REDEEMED
|
|
389
458
|
|
|
390
459
|
if redeemed_datetime is None:
|
|
@@ -394,9 +463,11 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
394
463
|
if redeemed_by:
|
|
395
464
|
redeemed_by_username = redeemed_by.username
|
|
396
465
|
|
|
397
|
-
self.redeemed_datetime
|
|
398
|
-
self.redeemed_by
|
|
399
|
-
self.redeemed_by_username
|
|
466
|
+
self.redeemed_datetime = redeemed_datetime
|
|
467
|
+
self.redeemed_by = redeemed_by.create_ndb_key()
|
|
468
|
+
self.redeemed_by_username = redeemed_by_username
|
|
469
|
+
self.redeemed_outlet = redeemed_outlet.create_ndb_key()
|
|
470
|
+
self.redeemed_transaction_id = transaction_id
|
|
400
471
|
self.put()
|
|
401
472
|
|
|
402
473
|
def remove(self, removed_by=None, removed_datetime=None):
|
|
@@ -363,7 +363,14 @@ class MerchantVoucher(VoucherBase):
|
|
|
363
363
|
|
|
364
364
|
merchant_acct = voucher.merchant_acct
|
|
365
365
|
merchant_acct.add_voucher(voucher.to_voucher_configuration())
|
|
366
|
-
|
|
366
|
+
|
|
367
|
+
@staticmethod
|
|
368
|
+
def list_by_voucher_key_list(voucher_key_list):
|
|
369
|
+
ndb_keys_list = []
|
|
370
|
+
for k in voucher_key_list:
|
|
371
|
+
ndb_keys_list.append(ndb.Key(urlsafe=k))
|
|
372
|
+
|
|
373
|
+
return MerchantVoucher.fetch_multi(ndb_keys_list)
|
|
367
374
|
|
|
368
375
|
@staticmethod
|
|
369
376
|
def list_all_by_merchant_account(merchant_acct):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/customer_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/helper/reward_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/referral_program_model.py
RENAMED
|
File without changes
|
{trex-model-1.5.13 → trex-model-1.5.15}/trexmodel/models/datastore/spending_base_program_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|