trex-model 1.5.14__tar.gz → 1.5.16__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.14 → trex-model-1.5.16}/PKG-INFO +1 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/setup.py +1 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/trex_model.egg-info/PKG-INFO +1 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/customer_models.py +16 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/helper/reward_transaction_helper.py +9 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/redeem_models.py +37 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/reward_models.py +31 -10
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/voucher_models.py +8 -1
- {trex-model-1.5.14 → trex-model-1.5.16}/LICENSE +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/MANIFEST.in +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/README.md +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/setup.cfg +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/conf.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/helper/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/import_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/merchant_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/message_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/ndb_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/product_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/program_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/system_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/task_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/test_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/user_models.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/merchant_helpers.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/program_conf.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -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
|
|
@@ -24,7 +24,9 @@ from trexanalytics.bigquery_upstream_data_config import create_merchant_customer
|
|
|
24
24
|
create_merchant_customer_redemption_upstream_for_merchant,\
|
|
25
25
|
create_merchant_customer_prepaid_upstream_for_merchant,\
|
|
26
26
|
create_merchant_customer_redemption_reverted_upstream_for_merchant,\
|
|
27
|
-
create_revert_entitled_customer_voucher_upstream_for_merchant
|
|
27
|
+
create_revert_entitled_customer_voucher_upstream_for_merchant,\
|
|
28
|
+
create_entitled_customer_voucher_upstream_for_merchant,\
|
|
29
|
+
create_redeemed_customer_voucher_to_upstream_for_merchant
|
|
28
30
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership
|
|
29
31
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction,\
|
|
30
32
|
SalesTransaction
|
|
@@ -695,6 +697,12 @@ def redeem_reward_transaction(customer, redeem_outlet=None, reward_format=None,
|
|
|
695
697
|
if customer_redemption:
|
|
696
698
|
create_redemption_message(customer_redemption)
|
|
697
699
|
create_merchant_customer_redemption_upstream_for_merchant(customer_redemption, streamed_datetime=redeemed_datetime)
|
|
700
|
+
if reward_format == program_conf.REWARD_FORMAT_VOUCHER:
|
|
701
|
+
for voucher_key in redeemed_voucher_keys_list:
|
|
702
|
+
customer_voucher = CustomerEntitledVoucher.fetch(voucher_key)
|
|
703
|
+
if customer_voucher:
|
|
704
|
+
create_redeemed_customer_voucher_to_upstream_for_merchant(customer_voucher)
|
|
705
|
+
|
|
698
706
|
|
|
699
707
|
return customer_redemption
|
|
700
708
|
|
|
@@ -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
|
|
|
@@ -344,7 +344,8 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
344
344
|
|
|
345
345
|
@property
|
|
346
346
|
def redeemed_by_outlet_key(self):
|
|
347
|
-
|
|
347
|
+
if self.redeemed_by_outlet:
|
|
348
|
+
return self.redeemed_by_outlet.urlsafe().decode('utf-8')
|
|
348
349
|
|
|
349
350
|
|
|
350
351
|
|
|
@@ -390,7 +391,7 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
390
391
|
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
391
392
|
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
392
393
|
CustomerEntitledVoucher.rewarded_datetime>=datetime_ranage_start,
|
|
393
|
-
CustomerEntitledVoucher.
|
|
394
|
+
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
394
395
|
)).count(limit=conf.MAX_FETCH_RECORD)
|
|
395
396
|
else:
|
|
396
397
|
result = CustomerEntitledVoucher.query(ndb.AND(
|
|
@@ -401,11 +402,26 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
401
402
|
return result
|
|
402
403
|
|
|
403
404
|
@staticmethod
|
|
404
|
-
def
|
|
405
|
-
if is_not_empty(
|
|
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):
|
|
406
407
|
query = CustomerEntitledVoucher.query(ndb.AND(
|
|
407
408
|
CustomerEntitledVoucher.merchant_acct==merchant_acct.create_ndb_key(),
|
|
408
|
-
CustomerEntitledVoucher.rewarded_datetime>=
|
|
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,
|
|
409
425
|
CustomerEntitledVoucher.rewarded_datetime<datetime_range_end,
|
|
410
426
|
))
|
|
411
427
|
else:
|
|
@@ -437,7 +453,7 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
437
453
|
self.put()
|
|
438
454
|
|
|
439
455
|
|
|
440
|
-
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):
|
|
441
457
|
self.status = program_conf.REWARD_STATUS_REDEEMED
|
|
442
458
|
|
|
443
459
|
if redeemed_datetime is None:
|
|
@@ -447,9 +463,11 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
447
463
|
if redeemed_by:
|
|
448
464
|
redeemed_by_username = redeemed_by.username
|
|
449
465
|
|
|
450
|
-
self.redeemed_datetime
|
|
451
|
-
self.redeemed_by
|
|
452
|
-
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
|
|
453
471
|
self.put()
|
|
454
472
|
|
|
455
473
|
def remove(self, removed_by=None, removed_datetime=None):
|
|
@@ -542,7 +560,9 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
542
560
|
def create(merchant_voucher, customer_acct, transact_outlet=None,
|
|
543
561
|
effective_date=None, expiry_date=None,
|
|
544
562
|
transaction_id=None, invoice_id=None,
|
|
545
|
-
rewarded_by=None, rewarded_datetime=None
|
|
563
|
+
rewarded_by=None, rewarded_datetime=None,
|
|
564
|
+
program_key=None
|
|
565
|
+
):
|
|
546
566
|
|
|
547
567
|
redeem_code = random_string(program_conf.REDEEM_CODE_LENGTH, is_human_mistake_safe=True)
|
|
548
568
|
|
|
@@ -569,6 +589,7 @@ class CustomerEntitledVoucher(CustomerEntitledReward):
|
|
|
569
589
|
rewarded_datetime = rewarded_datetime,
|
|
570
590
|
|
|
571
591
|
user_acct = customer_acct.registered_user_acct.create_ndb_key(),
|
|
592
|
+
reward_program = string_to_key_property(program_key),
|
|
572
593
|
)
|
|
573
594
|
|
|
574
595
|
customer_entiteld_voucher.put()
|
|
@@ -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.14 → trex-model-1.5.16}/trexmodel/models/datastore/customer_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.14 → trex-model-1.5.16}/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
|
|
File without changes
|
{trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
{trex-model-1.5.14 → trex-model-1.5.16}/trexmodel/models/datastore/referral_program_model.py
RENAMED
|
File without changes
|
{trex-model-1.5.14 → trex-model-1.5.16}/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
|