trex-model 1.5.4__tar.gz → 1.5.6__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.4 → trex-model-1.5.6}/PKG-INFO +1 -1
- {trex-model-1.5.4 → trex-model-1.5.6}/setup.py +1 -1
- {trex-model-1.5.4 → trex-model-1.5.6}/trex_model.egg-info/PKG-INFO +1 -1
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/customer_models.py +49 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/merchant_models.py +19 -1
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/ndb_models.py +15 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/program_models.py +23 -3
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/redeem_models.py +2 -2
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/reward_models.py +6 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/LICENSE +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/MANIFEST.in +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/README.md +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/setup.cfg +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/conf.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/import_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/message_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/product_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/reward_model_helpers.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/system_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/task_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/test_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/user_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/datastore/voucher_models.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/merchant_helpers.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/program_conf.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-1.5.4 → trex-model-1.5.6}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -277,6 +277,14 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
277
277
|
ticket.patch_prize_image_base_url()
|
|
278
278
|
Customer.update_ticket_into_lucky_draw_ticket_summary(customer_acct, ticket.to_configuration())
|
|
279
279
|
|
|
280
|
+
@staticmethod
|
|
281
|
+
def list_by_customer_key_list(customer_keys_list):
|
|
282
|
+
ndb_keys_list = []
|
|
283
|
+
for k in customer_keys_list:
|
|
284
|
+
ndb_keys_list.append(ndb.Key(urlsafe=k))
|
|
285
|
+
|
|
286
|
+
return Customer.fetch_multi(ndb_keys_list)
|
|
287
|
+
|
|
280
288
|
@classmethod
|
|
281
289
|
def get_by_reference_code(cls, reference_code, merchant_acct):
|
|
282
290
|
return cls.query(ndb.AND(cls.reference_code==reference_code, cls.merchant_acct==merchant_acct.create_ndb_key())).get()
|
|
@@ -375,6 +383,29 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
375
383
|
|
|
376
384
|
return created_customer
|
|
377
385
|
|
|
386
|
+
@classmethod
|
|
387
|
+
def list_last_active_customer_by_range(cls, merchant_acct, last_active_date_since, last_active_date_end,
|
|
388
|
+
offset=0, limit=conf.MAX_FETCH_RECORD, start_cursor=None, return_with_cursor=False):
|
|
389
|
+
query = cls.query(ndb.AND(
|
|
390
|
+
cls.merchant_acct==merchant_acct.create_ndb_key(),
|
|
391
|
+
cls.last_transact_datetime>=last_active_date_since,
|
|
392
|
+
cls.last_transact_datetime<last_active_date_end,
|
|
393
|
+
|
|
394
|
+
)).order(-cls.last_transact_datetime)
|
|
395
|
+
|
|
396
|
+
return cls.list_all_with_condition_query(query, offset=offset, limit=limit, start_cursor=start_cursor, return_with_cursor=return_with_cursor)
|
|
397
|
+
|
|
398
|
+
@classmethod
|
|
399
|
+
def count_last_active_customer_by_range(cls, merchant_acct, last_active_date_since, last_active_date_end, limit=conf.MAX_FETCH_RECORD,):
|
|
400
|
+
query = cls.query(ndb.AND(
|
|
401
|
+
cls.merchant_acct==merchant_acct.create_ndb_key(),
|
|
402
|
+
cls.last_transact_datetime>=last_active_date_since,
|
|
403
|
+
cls.last_transact_datetime<=last_active_date_end,
|
|
404
|
+
|
|
405
|
+
))
|
|
406
|
+
|
|
407
|
+
return cls.count_with_condition_query(query)
|
|
408
|
+
|
|
378
409
|
@classmethod
|
|
379
410
|
def list(cls, offset=0, limit=conf.MAX_FETCH_RECORD, start_cursor=None, return_with_cursor=False, keys_only=False):
|
|
380
411
|
query = cls.query()
|
|
@@ -787,6 +818,24 @@ class CustomerMembership(BaseNModel, DictModel):
|
|
|
787
818
|
), ancestor=customer.create_ndb_key()).get()
|
|
788
819
|
|
|
789
820
|
|
|
821
|
+
@staticmethod
|
|
822
|
+
def count_merchant_customer_membership(merchant_acct):
|
|
823
|
+
if merchant_acct:
|
|
824
|
+
query = CustomerMembership.query(ndb.AND(CustomerMembership.merchant_acct==merchant_acct.create_ndb_key()))
|
|
825
|
+
else:
|
|
826
|
+
query = CustomerMembership.query()
|
|
827
|
+
|
|
828
|
+
return CustomerMembership.count_with_condition_query(query)
|
|
829
|
+
|
|
830
|
+
@staticmethod
|
|
831
|
+
def list_merchant_customer_membership(merchant_acct, limit=conf.MAX_FETCH_RECORD, start_cursor=None, return_with_cursor=False):
|
|
832
|
+
if merchant_acct:
|
|
833
|
+
query = CustomerMembership.query(ndb.AND(CustomerMembership.merchant_acct==merchant_acct.create_ndb_key()))
|
|
834
|
+
else:
|
|
835
|
+
query = CustomerMembership.query()
|
|
836
|
+
|
|
837
|
+
return CustomerMembership.list_all_with_condition_query(query, limit=limit, start_cursor=start_cursor, return_with_cursor=return_with_cursor, keys_only=False)
|
|
838
|
+
|
|
790
839
|
@staticmethod
|
|
791
840
|
def list_all_by_customer(customer, limit = conf.MAX_FETCH_RECORD, offset=0, keys_only=False):
|
|
792
841
|
return CustomerMembership.query(ancestor=customer.create_ndb_key()).fetch(offset=offset, limit=limit, keys_only=keys_only)
|
|
@@ -18,6 +18,7 @@ from trexconf import conf, program_conf
|
|
|
18
18
|
from trexmodel.models.datastore.system_models import Tagging
|
|
19
19
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
20
20
|
from trexmodel.program_conf import LOYALTY_PACKAGE_LITE, LOYALTY_PRODUCT
|
|
21
|
+
import pytz
|
|
21
22
|
|
|
22
23
|
logger = logging.getLogger('model')
|
|
23
24
|
#logger = logging.getLogger('debug')
|
|
@@ -63,6 +64,7 @@ class MerchantAcct(MerchantMin):
|
|
|
63
64
|
api_key = ndb.StringProperty(required=False)
|
|
64
65
|
|
|
65
66
|
account_plan = ndb.JsonProperty()
|
|
67
|
+
setup_progress = ndb.JsonProperty()
|
|
66
68
|
outlet_count = ndb.IntegerProperty(default=0)
|
|
67
69
|
|
|
68
70
|
published_program_configuration = ndb.JsonProperty()
|
|
@@ -91,7 +93,7 @@ class MerchantAcct(MerchantMin):
|
|
|
91
93
|
dict_properties = ['company_name', 'brand_name', 'contact_name', 'business_reg_no', 'mobile_phone',
|
|
92
94
|
'office_phone', 'fax_phone', 'email', 'account_code', 'country',
|
|
93
95
|
'registered_datetime', 'modified_datetime', 'plan_start_date', 'plan_end_date', 'currency_code',
|
|
94
|
-
'timezone', 'effective_referral_program_count',
|
|
96
|
+
'timezone', 'effective_referral_program_count', 'gmt_hour',
|
|
95
97
|
'published_program_configuration', 'published_tier_program_configuration', 'published_referral_program_configuration',
|
|
96
98
|
'published_voucher_configuration', 'published_news_configuration', 'membership_configuration',
|
|
97
99
|
'tier_membership_configuration', 'prepaid_configuration', 'lucky_draw_configuration', 'product_modifier_configuration',
|
|
@@ -101,6 +103,22 @@ class MerchantAcct(MerchantMin):
|
|
|
101
103
|
]
|
|
102
104
|
|
|
103
105
|
|
|
106
|
+
@property
|
|
107
|
+
def gmt_hour(self):
|
|
108
|
+
if self.timezone:
|
|
109
|
+
now = datetime.utcnow()
|
|
110
|
+
timezone = pytz.timezone(self.timezone)
|
|
111
|
+
#timezone_time = now.astimezone(self.timezone)
|
|
112
|
+
return timezone.utcoffset(now).total_seconds() / 3600
|
|
113
|
+
return conf.DEFAULT_GMT_HOURS
|
|
114
|
+
|
|
115
|
+
def update_setup_progress(self, setup_step):
|
|
116
|
+
if self.setup_progress is None:
|
|
117
|
+
self.setup_progress = {
|
|
118
|
+
}
|
|
119
|
+
elif self.setup_progress.get(setup_step) is None:
|
|
120
|
+
self.setup_progress[setup_step] = True
|
|
121
|
+
|
|
104
122
|
def to_login_dict(self):
|
|
105
123
|
return {
|
|
106
124
|
'account_code' : self.account_code,
|
|
@@ -247,6 +247,10 @@ class BaseNModel(DictModel, NDBModel):
|
|
|
247
247
|
@property
|
|
248
248
|
def key_in_str(self):
|
|
249
249
|
return self.key.urlsafe().decode('utf-8')
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def key_in_urlsafe(self):
|
|
253
|
+
return self.key.urlsafe()
|
|
250
254
|
|
|
251
255
|
@property
|
|
252
256
|
def key_name(self):
|
|
@@ -278,6 +282,17 @@ class BaseNModel(DictModel, NDBModel):
|
|
|
278
282
|
|
|
279
283
|
return None
|
|
280
284
|
|
|
285
|
+
@classmethod
|
|
286
|
+
def fetch_multi(cls, model_keys_list):
|
|
287
|
+
try:
|
|
288
|
+
if model_keys_list:
|
|
289
|
+
return ndb.get_multi(model_keys_list)
|
|
290
|
+
|
|
291
|
+
except:
|
|
292
|
+
logger.error('Failed to fetch entity due to %s', get_tracelog())
|
|
293
|
+
|
|
294
|
+
return None
|
|
295
|
+
|
|
281
296
|
@classmethod
|
|
282
297
|
def count(cls, limit=model_conf.MAX_FETCH_RECORD):
|
|
283
298
|
query = cls.query()
|
|
@@ -13,6 +13,7 @@ from trexconf import conf, program_conf
|
|
|
13
13
|
from datetime import datetime
|
|
14
14
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
15
15
|
from trexlib.utils.common.common_util import sort_list, sort_dict_list
|
|
16
|
+
from _datetime import timedelta
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -127,6 +128,24 @@ class BaseProgram(BaseNModel, DictModel):
|
|
|
127
128
|
if self.program_settings and self.program_settings.get('scheme'):
|
|
128
129
|
return self.program_settings.get('scheme').get('is_recurring_scheme')
|
|
129
130
|
return False
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def limit_to_specific_day(self):
|
|
134
|
+
try:
|
|
135
|
+
if self.program_settings and self.program_settings.get('scheme'):
|
|
136
|
+
return self.program_settings.get('scheme').get('limit_to_specific_day')
|
|
137
|
+
except:
|
|
138
|
+
pass
|
|
139
|
+
return False
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def specified_days_list(self):
|
|
143
|
+
try:
|
|
144
|
+
if self.program_settings and self.program_settings.get('scheme'):
|
|
145
|
+
return self.program_settings.get('scheme').get('specified_days_list')
|
|
146
|
+
except:
|
|
147
|
+
pass
|
|
148
|
+
return []
|
|
130
149
|
|
|
131
150
|
@property
|
|
132
151
|
def giveaway_system_condition(self):
|
|
@@ -231,7 +250,6 @@ class BaseProgram(BaseNModel, DictModel):
|
|
|
231
250
|
|
|
232
251
|
remove_schedule_program(program)
|
|
233
252
|
|
|
234
|
-
|
|
235
253
|
@classmethod
|
|
236
254
|
@model_transactional(desc="enable program")
|
|
237
255
|
def enable(cls, program, modified_by=None):
|
|
@@ -582,7 +600,7 @@ class MerchantProgram(BasicRewardProgram):
|
|
|
582
600
|
'created_datetime', 'modified_datetime', 'enabled','completed_status','is_enabled', 'is_disabled', 'is_review_state',
|
|
583
601
|
'is_published', 'archived', 'is_reward_amount_required', 'completed_progress_in_percentage', 'completed_status_index',
|
|
584
602
|
'exclusive_tags_list', 'exclusive_memberships_list', 'exclusive_tier_memberships_list',
|
|
585
|
-
'is_recurring_scheme',
|
|
603
|
+
'is_recurring_scheme', 'limit_to_specific_day', 'specified_days_list',
|
|
586
604
|
'expiration_type', 'expiration_date', 'expiration_value', 'is_expiration_date_type',
|
|
587
605
|
'giveaway_reward_when', 'giveaway_reward_advance_in_day',
|
|
588
606
|
'giveaway_system_condition', 'giveaway_system_condition_memberships_list', 'giveaway_system_condition_tier_memberships_list',
|
|
@@ -630,7 +648,9 @@ class MerchantProgram(BasicRewardProgram):
|
|
|
630
648
|
program_settings = {
|
|
631
649
|
'exclusivity' : exclusivity_configuration,
|
|
632
650
|
'scheme' : {
|
|
633
|
-
'is_recurring_scheme': True,
|
|
651
|
+
'is_recurring_scheme' : True,
|
|
652
|
+
'limit_to_specific_day' : False,
|
|
653
|
+
'specified_days_list' : [],
|
|
634
654
|
}
|
|
635
655
|
}
|
|
636
656
|
|
|
@@ -365,7 +365,7 @@ class CustomerRedemption(BaseNModel, DictModel):
|
|
|
365
365
|
redeemed_summary = {
|
|
366
366
|
reward_format : {
|
|
367
367
|
|
|
368
|
-
'amount' : redeemed_amount,
|
|
368
|
+
'amount' : float(redeemed_amount),
|
|
369
369
|
'customer_point_rewards' : redeemed_reward_details_list
|
|
370
370
|
}
|
|
371
371
|
}
|
|
@@ -448,7 +448,7 @@ class CustomerRedemption(BaseNModel, DictModel):
|
|
|
448
448
|
redeemed_summary = {
|
|
449
449
|
program_conf.REWARD_FORMAT_PREPAID: {
|
|
450
450
|
|
|
451
|
-
'amount' : redeemed_amount,
|
|
451
|
+
'amount' : float(redeemed_amount),
|
|
452
452
|
'customer_prepaid_rewards' : redeemed_reward_details_list
|
|
453
453
|
}
|
|
454
454
|
}
|
|
@@ -653,6 +653,12 @@ class CustomerEntitledTierRewardSummary(BaseNModel, DictModel):
|
|
|
653
653
|
@staticmethod
|
|
654
654
|
def list_all_by_customer(customer, limit = conf.MAX_FETCH_RECORD, offset=0):
|
|
655
655
|
return CustomerEntitledTierRewardSummary.query(ancestor=customer.create_ndb_key()).fetch(offset=offset, limit=limit)
|
|
656
|
+
|
|
657
|
+
@staticmethod
|
|
658
|
+
def delete_all_by_customer(customer):
|
|
659
|
+
result = CustomerEntitledTierRewardSummary.query(ancestor=customer.create_ndb_key()).fetch(limit=conf.MAX_FETCH_RECORD)
|
|
660
|
+
for r in result:
|
|
661
|
+
r.delete()
|
|
656
662
|
|
|
657
663
|
@staticmethod
|
|
658
664
|
def list_tier_reward_summary_by_customer(customer_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
|
|
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.4 → trex-model-1.5.6}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.5.4 → trex-model-1.5.6}/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
|
|
File without changes
|