trex-model 1.6.15__tar.gz → 1.6.17__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.6.15 → trex_model-1.6.17}/PKG-INFO +1 -1
- {trex_model-1.6.15 → trex_model-1.6.17}/setup.py +1 -1
- {trex_model-1.6.15 → trex_model-1.6.17}/trex_model.egg-info/PKG-INFO +1 -1
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/customer_models.py +29 -3
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/redemption_catalogue_models.py +1 -3
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/merchant_helpers.py +11 -6
- {trex_model-1.6.15 → trex_model-1.6.17}/LICENSE +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/MANIFEST.in +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/README.md +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/setup.cfg +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trex_model.egg-info/requires.txt +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trex_model.egg-info/top_level.txt +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/conf.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/app_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/helper/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/helper/reward_transaction_helper.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/helper/sales_transaction_helpers.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/import_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/merchant_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/merchant_promotion_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/message_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/ndb_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/partnership_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/product_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/program_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/redeem_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/reward_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/support_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/system_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/task_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/test_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/user_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/voucher_models.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/model_decorator.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/pos_conf.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/program_conf.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/utils/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/utils/model/__init__.py +0 -0
- {trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -9,7 +9,7 @@ from trexmodel.models.datastore.user_models import User
|
|
|
9
9
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet,\
|
|
10
10
|
MerchantUser
|
|
11
11
|
import trexmodel.conf as model_conf
|
|
12
|
-
from trexlib.utils.string_util import is_not_empty, is_empty
|
|
12
|
+
from trexlib.utils.string_util import is_not_empty, is_empty, random_string
|
|
13
13
|
import logging
|
|
14
14
|
from trexlib.utils.common.date_util import convert_date_to_datetime,\
|
|
15
15
|
to_day_of_year
|
|
@@ -71,6 +71,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
71
71
|
entitled_lucky_draw_ticket_summary = ndb.JsonProperty(required=False)
|
|
72
72
|
|
|
73
73
|
referrer_code = ndb.StringProperty(required=False)
|
|
74
|
+
invitation_code = ndb.StringProperty(required=False)
|
|
74
75
|
|
|
75
76
|
kpi_summary = ndb.JsonProperty()
|
|
76
77
|
|
|
@@ -84,7 +85,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
84
85
|
'entitled_birthday_reward_summary', 'tier_membership_key',
|
|
85
86
|
'registered_outlet_key', 'merchant_account_key',
|
|
86
87
|
'registered_datetime', 'modified_datetime',
|
|
87
|
-
'registered_user_acct','referral_code', 'is_referred_by_friend',
|
|
88
|
+
'registered_user_acct','referral_code', 'invitation_code','is_referred_by_friend',
|
|
88
89
|
|
|
89
90
|
]
|
|
90
91
|
|
|
@@ -162,6 +163,19 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
162
163
|
def is_referred_by_friend(self):
|
|
163
164
|
return self.referrer_code is not None and is_not_empty(self.referrer_code)
|
|
164
165
|
|
|
166
|
+
@classmethod
|
|
167
|
+
def get_by_invitation_code(cls, invitation_code):
|
|
168
|
+
return Customer.query(ndb.AND(Customer.invitation_code==invitation_code)).get()
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def _generate_invitation_code(cls):
|
|
172
|
+
invitation_code = random_string(8, is_human_mistake_safe=True)
|
|
173
|
+
checking_customer = cls.get_by_invitation_code(invitation_code)
|
|
174
|
+
while checking_customer is not None:
|
|
175
|
+
invitation_code = random_string(8, is_human_mistake_safe=True)
|
|
176
|
+
checking_customer = cls.get_by_invitation_code(invitation_code)
|
|
177
|
+
return invitation_code
|
|
178
|
+
|
|
165
179
|
@staticmethod
|
|
166
180
|
def update_KPI(customer_acct, tags_list=None, memberships_list=None, tier_membership_key=None):
|
|
167
181
|
if isinstance(tags_list, string_types):
|
|
@@ -299,6 +313,11 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
299
313
|
def get_by_reference_code(cls, reference_code, merchant_acct):
|
|
300
314
|
return cls.query(ndb.AND(cls.reference_code==reference_code, cls.merchant_acct==merchant_acct.create_ndb_key())).get()
|
|
301
315
|
|
|
316
|
+
@classmethod
|
|
317
|
+
def get_by_invitation_code(cls, invitation_code):
|
|
318
|
+
return cls.query(ndb.AND(cls.invitation_code==invitation_code)).get()
|
|
319
|
+
|
|
320
|
+
|
|
302
321
|
@classmethod
|
|
303
322
|
def get_by_merchant_reference_code(cls, merchant_reference_code, merchant_acct):
|
|
304
323
|
return cls.query(ndb.AND(cls.merchant_reference_code==merchant_reference_code, cls.merchant_acct==merchant_acct.create_ndb_key())).get()
|
|
@@ -346,11 +365,17 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
346
365
|
|
|
347
366
|
created_user.put()
|
|
348
367
|
created_customer = cls.create_from_user(outlet, created_user)
|
|
368
|
+
created_customer.invitation_code = cls._generate_invitation_code()
|
|
349
369
|
created_customer.merchant_reference_code = merchant_reference_code
|
|
350
370
|
created_customer.put()
|
|
351
371
|
|
|
352
372
|
return created_customer
|
|
353
373
|
|
|
374
|
+
@classmethod
|
|
375
|
+
def update_invitation_code(cls, customer):
|
|
376
|
+
customer.invitation_code = cls._generate_invitation_code()
|
|
377
|
+
customer.put()
|
|
378
|
+
|
|
354
379
|
@classmethod
|
|
355
380
|
def update(cls, customer=None, outlet=None, **kwargs):
|
|
356
381
|
if outlet:
|
|
@@ -401,7 +426,8 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
401
426
|
birth_day_in_year = user_acct.birth_day_in_year,
|
|
402
427
|
merchant_reference_code = merchant_reference_code,
|
|
403
428
|
referrer_code = referrer_code,
|
|
404
|
-
merchant_acct = registered_merchant_acct.create_ndb_key()
|
|
429
|
+
merchant_acct = registered_merchant_acct.create_ndb_key(),
|
|
430
|
+
invitation_code = cls._generate_invitation_code(),
|
|
405
431
|
)
|
|
406
432
|
|
|
407
433
|
created_customer.put()
|
{trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
@@ -12,10 +12,8 @@ from trexmodel.models.datastore.merchant_models import MerchantUser,\
|
|
|
12
12
|
MerchantAcct
|
|
13
13
|
from trexlib.utils.string_util import is_not_empty, is_empty
|
|
14
14
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
15
|
-
from trexconf.program_conf import
|
|
16
|
-
REDEMPTION_CATALOGUE_STATUS_NEW, REDEMPTION_CATALOGUE_STATUS_PUBLISH
|
|
15
|
+
from trexconf.program_conf import REDEMPTION_CATALOGUE_STATUS_NEW, REDEMPTION_CATALOGUE_STATUS_PUBLISH
|
|
17
16
|
from trexlib.utils.common.common_util import sort_list
|
|
18
|
-
from audioop import reverse
|
|
19
17
|
|
|
20
18
|
logger = logging.getLogger('model')
|
|
21
19
|
|
|
@@ -7,13 +7,13 @@ from trexconf import conf
|
|
|
7
7
|
from datetime import datetime
|
|
8
8
|
import logging
|
|
9
9
|
from trexlib.utils.crypto_util import aes_encrypt_json
|
|
10
|
-
from trexmodel.models.datastore.customer_models import CustomerTierMembership,\
|
|
10
|
+
from trexmodel.models.datastore.customer_models import Customer, CustomerTierMembership,\
|
|
11
11
|
CustomerMembership
|
|
12
12
|
from trexmodel.models.datastore.membership_models import MerchantMembership
|
|
13
13
|
|
|
14
14
|
logger = logging.getLogger('helper')
|
|
15
15
|
|
|
16
|
-
def construct_merchant_acct_info(merchant_acct,
|
|
16
|
+
def construct_merchant_acct_info(merchant_acct, customer=None, read_minimum=False):
|
|
17
17
|
account_settings = {
|
|
18
18
|
'account_code' : merchant_acct.account_code,
|
|
19
19
|
'currency' : merchant_acct.currency_code,
|
|
@@ -114,10 +114,12 @@ def construct_merchant_acct_info(merchant_acct, referrer_code=None, read_minimum
|
|
|
114
114
|
'partner_merchants' : partner_merchants_list,
|
|
115
115
|
'industry_type' : merchant_acct.industry,
|
|
116
116
|
}
|
|
117
|
-
if is_not_empty(referral_program_settings):
|
|
118
|
-
|
|
117
|
+
if is_not_empty(referral_program_settings) and customer is not None:
|
|
118
|
+
user_acct = customer.registered_user_acct
|
|
119
|
+
referrer_code = user_acct.referral_code
|
|
120
|
+
invitation_code = customer.invitation_code
|
|
119
121
|
refer_a_friend_url = '{base_url}/referral/program/merchant-acct-code/{merchant_code}/referrer-code/{referrer_code}/join'
|
|
120
|
-
refer_a_friend_message = 'Hi, \n\n{referee_promote_desc}. Please join {brand_name} via
|
|
122
|
+
refer_a_friend_message = 'Hi, \n\n{referee_promote_desc}. Please join {brand_name} via my invitation code - {invitation_code}'
|
|
121
123
|
referee_promote_desc = referral_program_settings.get('referee_promote_desc')
|
|
122
124
|
|
|
123
125
|
referrer_data = {
|
|
@@ -130,7 +132,7 @@ def construct_merchant_acct_info(merchant_acct, referrer_code=None, read_minimum
|
|
|
130
132
|
logger.debug('encrypted_referrer_data=%s', encrypted_referrer_data)
|
|
131
133
|
|
|
132
134
|
logger.debug('refer_a_friend_url before=%s', refer_a_friend_url)
|
|
133
|
-
|
|
135
|
+
|
|
134
136
|
refer_a_friend_url = refer_a_friend_url.format(
|
|
135
137
|
base_url = conf.REFER_BASE_URL,
|
|
136
138
|
merchant_code = merchant_acct.account_code,
|
|
@@ -157,9 +159,11 @@ def construct_merchant_acct_info(merchant_acct, referrer_code=None, read_minimum
|
|
|
157
159
|
referee_promote_desc = referee_promote_desc,
|
|
158
160
|
brand_name = merchant_acct.brand_name,
|
|
159
161
|
refer_a_friend_url = refer_a_friend_url,
|
|
162
|
+
invitation_code = invitation_code,
|
|
160
163
|
)
|
|
161
164
|
logger.debug('refer_a_friend_message=%s', refer_a_friend_message)
|
|
162
165
|
|
|
166
|
+
|
|
163
167
|
info['referral_program_settings'] = {
|
|
164
168
|
'program_count' : merchant_acct.effective_referral_program_count,
|
|
165
169
|
'referrer_promote_title' : referral_program_settings.get('referrer_promote_title'),
|
|
@@ -173,6 +177,7 @@ def construct_merchant_acct_info(merchant_acct, referrer_code=None, read_minimum
|
|
|
173
177
|
'refer_a_friend_deep_link' : refer_a_friend_deep_link,
|
|
174
178
|
'referrer_merchant_and_friend_code' : referrer_merchant_and_friend_code,
|
|
175
179
|
'referrer_code' : referrer_code,
|
|
180
|
+
'invitation_code' : invitation_code,
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
|
|
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.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/customer_model_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex_model-1.6.15 → trex_model-1.6.17}/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
|
{trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/merchant_promotion_models.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
|
{trex_model-1.6.15 → trex_model-1.6.17}/trexmodel/models/datastore/referral_program_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{trex_model-1.6.15 → trex_model-1.6.17}/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
|