trex-model 1.6.8__tar.gz → 1.6.10__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.8 → trex_model-1.6.10}/PKG-INFO +1 -1
- {trex_model-1.6.8 → trex_model-1.6.10}/setup.py +1 -1
- {trex_model-1.6.8 → trex_model-1.6.10}/trex_model.egg-info/PKG-INFO +1 -1
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/customer_model_helpers.py +26 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/customer_models.py +6 -1
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/marketing_models.py +8 -5
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/merchant_models.py +29 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/ndb_models.py +9 -3
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/rating_models.py +28 -2
- {trex_model-1.6.8 → trex_model-1.6.10}/LICENSE +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/MANIFEST.in +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/README.md +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/setup.cfg +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trex_model.egg-info/requires.txt +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trex_model.egg-info/top_level.txt +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/conf.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/app_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/helper/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/helper/reward_model_helpers.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/helper/reward_transaction_helper.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/helper/sales_transaction_helpers.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/import_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/membership_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/merchant_promotion_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/message_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/partnership_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/product_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/program_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/recruit_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/redeem_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/referral_program_model.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/reward_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/system_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/task_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/test_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/user_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/voucher_models.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/merchant_helpers.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/model_decorator.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/pos_conf.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/program_conf.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/utils/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/utils/model/__init__.py +0 -0
- {trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -399,6 +399,32 @@ def update_customer_entiteld_voucher_summary_after_removed_voucher(customer_enti
|
|
|
399
399
|
customer_entitled_voucher_summary[merchant_voucher_key]['amount'] = len(new_redeem_info_list)
|
|
400
400
|
|
|
401
401
|
return customer_entitled_voucher_summary
|
|
402
|
+
|
|
403
|
+
def update_customer_entiteld_voucher_summary_after_removed_voucher_by_redeem_code(customer_entitled_voucher_summary, redeem_code):
|
|
404
|
+
'''
|
|
405
|
+
removed entitled voucher from customer entitled voucher summary
|
|
406
|
+
'''
|
|
407
|
+
logger.debug('redeem_code=%s', redeem_code)
|
|
408
|
+
|
|
409
|
+
new_customer_entitled_voucher_summary = {}
|
|
410
|
+
|
|
411
|
+
if customer_entitled_voucher_summary:
|
|
412
|
+
|
|
413
|
+
for merchant_voucher_key, voucher_summary in customer_entitled_voucher_summary.items():
|
|
414
|
+
new_redeem_info_list = []
|
|
415
|
+
redeem_info_list = voucher_summary.get('redeem_info_list')
|
|
416
|
+
for redeem_info in redeem_info_list:
|
|
417
|
+
if redeem_info.get('redeem_code')!=redeem_code:
|
|
418
|
+
new_redeem_info_list.append(redeem_info)
|
|
419
|
+
|
|
420
|
+
new_customer_entitled_voucher_summary[merchant_voucher_key] = {}
|
|
421
|
+
new_customer_entitled_voucher_summary[merchant_voucher_key]['redeem_info_list'] = new_redeem_info_list
|
|
422
|
+
new_customer_entitled_voucher_summary[merchant_voucher_key]['count'] = len(new_redeem_info_list)
|
|
423
|
+
new_customer_entitled_voucher_summary[merchant_voucher_key]['amount'] = len(new_redeem_info_list)
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
return new_customer_entitled_voucher_summary
|
|
402
428
|
|
|
403
429
|
|
|
404
430
|
def update_customer_entiteld_voucher_summary_after_reverted_voucher(entitled_voucher_summary, reverted_customer_voucher):
|
|
@@ -19,7 +19,8 @@ from datetime import datetime, timedelta
|
|
|
19
19
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership,\
|
|
20
20
|
MerchantMembership
|
|
21
21
|
from trexmodel.models.datastore.customer_model_helpers import update_customer_entiteld_voucher_summary_after_removed_voucher,\
|
|
22
|
-
update_customer_entiteld_voucher_summary_with_customer_new_voucher
|
|
22
|
+
update_customer_entiteld_voucher_summary_with_customer_new_voucher,\
|
|
23
|
+
update_customer_entiteld_voucher_summary_after_removed_voucher_by_redeem_code
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
logger = logging.getLogger('model')
|
|
@@ -758,6 +759,10 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
758
759
|
update_customer_entiteld_voucher_summary_after_removed_voucher(entitled_voucher_summary, removed_voucher)
|
|
759
760
|
self.put()
|
|
760
761
|
|
|
762
|
+
def update_after_removed_voucher_by_redeem_code(self, redeem_code):
|
|
763
|
+
self.entitled_voucher_summary = update_customer_entiteld_voucher_summary_after_removed_voucher_by_redeem_code(self.entitled_voucher_summary, redeem_code)
|
|
764
|
+
self.put()
|
|
765
|
+
|
|
761
766
|
def update_after_added_voucher(self, added_voucher):
|
|
762
767
|
entitled_voucher_summary = self.entitled_voucher_summary
|
|
763
768
|
update_customer_entiteld_voucher_summary_with_customer_new_voucher(entitled_voucher_summary, added_voucher)
|
|
@@ -15,6 +15,7 @@ import logging
|
|
|
15
15
|
from _datetime import timedelta
|
|
16
16
|
from trexconf.program_conf import MERCHANT_NEWS_STATUS_PUBLISH
|
|
17
17
|
from trexconf.conf import MERCHANT_NEWS_BASE_URL
|
|
18
|
+
from trexlib.utils.common.common_util import sort_list
|
|
18
19
|
|
|
19
20
|
logger = logging.getLogger('model')
|
|
20
21
|
|
|
@@ -182,17 +183,19 @@ class MarketingImage(BaseNModel, DictModel):
|
|
|
182
183
|
'''
|
|
183
184
|
Merchant Account as ancestor
|
|
184
185
|
'''
|
|
185
|
-
image_label
|
|
186
|
-
image_file_type
|
|
187
|
-
image_file_public_url
|
|
188
|
-
image_file_storage_filename
|
|
186
|
+
image_label = ndb.StringProperty(required=True)
|
|
187
|
+
image_file_type = ndb.StringProperty(required=True)
|
|
188
|
+
image_file_public_url = ndb.StringProperty(required=True)
|
|
189
|
+
image_file_storage_filename = ndb.StringProperty(required=True)
|
|
190
|
+
created_datetime = ndb.DateTimeProperty(required=False, auto_now=True, default=datetime.min)
|
|
189
191
|
|
|
190
192
|
dict_properties = ['image_label', 'image_file_public_url', 'image_file_storage_filename', 'image_file_type']
|
|
191
193
|
|
|
192
194
|
@staticmethod
|
|
193
195
|
def list_by_merchant_acct(merchant_acct):
|
|
194
196
|
result = MarketingImage.query(ancestor=merchant_acct.create_ndb_key()).fetch(limit=conf.MAX_FETCH_RECORD)
|
|
195
|
-
|
|
197
|
+
sorted_result = sort_list(result,'created_datetime', reverse_order=True, default_value=datetime.min)
|
|
198
|
+
return sorted_result
|
|
196
199
|
|
|
197
200
|
@staticmethod
|
|
198
201
|
def upload_file(uploading_file, image_label, merchant_acct, bucket, image_file_type=None):
|
|
@@ -130,6 +130,33 @@ class MerchantAcct(MerchantMin):
|
|
|
130
130
|
return timezone.utcoffset(now).total_seconds() / 3600
|
|
131
131
|
return conf.DEFAULT_GMT_HOURS
|
|
132
132
|
|
|
133
|
+
def upload_logo(self, uploading_file, bucket, logo_file_type=None):
|
|
134
|
+
file_prefix = random_string(8)
|
|
135
|
+
logo_file_storage_filename = 'merchant/'+self.key_in_str+'/logo/'+file_prefix+'-'+uploading_file.filename
|
|
136
|
+
blob = bucket.blob(logo_file_storage_filename)
|
|
137
|
+
|
|
138
|
+
logger.debug('logo_file_storage_filename=%s', logo_file_storage_filename)
|
|
139
|
+
|
|
140
|
+
blob.upload_from_string(
|
|
141
|
+
uploading_file.read(),
|
|
142
|
+
content_type=uploading_file.content_type
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
uploaded_url = blob.public_url
|
|
146
|
+
|
|
147
|
+
logger.debug('uploaded_url=%s', uploaded_url)
|
|
148
|
+
logger.debug('logo_file_type=%s', logo_file_type)
|
|
149
|
+
|
|
150
|
+
if is_not_empty(self.logo_storage_filename):
|
|
151
|
+
old_logo_blob = bucket.get_blob(self.logo_storage_filename)
|
|
152
|
+
if old_logo_blob:
|
|
153
|
+
old_logo_blob.delete()
|
|
154
|
+
|
|
155
|
+
self.logo_public_url = uploaded_url
|
|
156
|
+
self.logo_storage_filename = logo_file_storage_filename
|
|
157
|
+
self.put()
|
|
158
|
+
deleteFromCache(self.key_in_str)
|
|
159
|
+
|
|
133
160
|
def update_setup_progress(self, setup_step):
|
|
134
161
|
if self.setup_progress is None:
|
|
135
162
|
self.setup_progress = {
|
|
@@ -144,6 +171,8 @@ class MerchantAcct(MerchantMin):
|
|
|
144
171
|
'currency_code' : self.currency_code,
|
|
145
172
|
'country' : self.country,
|
|
146
173
|
'account_plan' : self.account_plan,
|
|
174
|
+
'gmt_hour' : self.gmt_hour,
|
|
175
|
+
'account_plan' : self.account_plan,
|
|
147
176
|
}
|
|
148
177
|
|
|
149
178
|
@property
|
|
@@ -139,8 +139,13 @@ class DictObject(object):
|
|
|
139
139
|
def properties(self):
|
|
140
140
|
return self.__dict__
|
|
141
141
|
|
|
142
|
-
def to_dict(self, full=True, show_key=True, dict_properties=None,
|
|
143
|
-
|
|
142
|
+
def to_dict(self, full=True, show_key=True, dict_properties=None,
|
|
143
|
+
excluded_dict_properties=None,
|
|
144
|
+
#gmt=lib_conf.DEFAULT_GMT,
|
|
145
|
+
gmt=0,
|
|
146
|
+
datetime_format=lib_conf.DEFAULT_DATETIME_FORMAT,
|
|
147
|
+
date_format=lib_conf.DEFAULT_DATE_FORMAT,
|
|
148
|
+
time_format=lib_conf.DEFAULT_TIME_FORMAT,
|
|
144
149
|
deep_level=99,
|
|
145
150
|
):
|
|
146
151
|
logger.info('calling DictObject.to_dict')
|
|
@@ -183,7 +188,8 @@ class DictModel(ndb.Model):
|
|
|
183
188
|
def __str__(self):
|
|
184
189
|
return '%s' % self.to_dict(deep_level=1)
|
|
185
190
|
|
|
186
|
-
def to_dict(self, full=False, show_key=True, dict_properties=None, excluded_dict_properties=None,
|
|
191
|
+
def to_dict(self, full=False, show_key=True, dict_properties=None, excluded_dict_properties=None,
|
|
192
|
+
gmt=0,
|
|
187
193
|
datetime_format=lib_conf.DEFAULT_DATETIME_FORMAT,
|
|
188
194
|
date_format=lib_conf.DEFAULT_DATE_FORMAT,time_format=lib_conf.DEFAULT_TIME_FORMAT,
|
|
189
195
|
deep_level=99,
|
|
@@ -12,6 +12,7 @@ from datetime import datetime, timedelta
|
|
|
12
12
|
import logging
|
|
13
13
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction
|
|
14
14
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
15
|
+
from trexlib.utils.common.date_util import convert_date_to_datetime
|
|
15
16
|
|
|
16
17
|
#logger = logging.getLogger('model')
|
|
17
18
|
logger = logging.getLogger('target_debug')
|
|
@@ -34,13 +35,34 @@ class TransactionRating(RatingBase):
|
|
|
34
35
|
|
|
35
36
|
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
36
37
|
|
|
37
|
-
dict_properties = ['transaction_id','rating_result', 'remarks', 'industry', 'score',
|
|
38
|
+
dict_properties = ['transaction_id','rating_result', 'remarks', 'industry', 'score', 'created_datetime',
|
|
38
39
|
]
|
|
39
40
|
|
|
40
41
|
@property
|
|
41
42
|
def merchant_acct_entity(self):
|
|
42
43
|
return self.merchant_acct.get()
|
|
43
44
|
|
|
45
|
+
@property
|
|
46
|
+
def user_acct_key(self):
|
|
47
|
+
return self.user_acct.urlsafe().decode('utf-8')
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def list_transaction_by_date(enquiry_date, outlet=None, offset=0, limit=conf.PAGINATION_SIZE, return_with_cursor=False, start_cursor=None):
|
|
51
|
+
start_datetime = convert_date_to_datetime(enquiry_date)
|
|
52
|
+
end_datetime = start_datetime + timedelta(days=1)
|
|
53
|
+
query = TransactionRating.query(
|
|
54
|
+
ndb.AND(
|
|
55
|
+
TransactionRating.outlet==outlet.create_ndb_key(),
|
|
56
|
+
TransactionRating.created_datetime>=start_datetime,
|
|
57
|
+
TransactionRating.created_datetime<end_datetime,
|
|
58
|
+
))
|
|
59
|
+
if return_with_cursor:
|
|
60
|
+
(result, next_cursor) = TransactionRating.list_all_with_condition_query(query, order_by=TransactionRating.created_datetime, start_cursor=start_cursor, return_with_cursor=True, limit=limit)
|
|
61
|
+
|
|
62
|
+
return (result, next_cursor)
|
|
63
|
+
else:
|
|
64
|
+
return query.order(TransactionRating.created_datetime).fetch(offset=offset, limit=limit)
|
|
65
|
+
|
|
44
66
|
@staticmethod
|
|
45
67
|
@model_transactional(desc="update rating changes")
|
|
46
68
|
def create(user_acct, transaction_id, rating_result={},
|
|
@@ -321,7 +343,11 @@ class OutletRatingResult(RatingResult):
|
|
|
321
343
|
outlet = ndb.KeyProperty(name="outlet", kind=Outlet)
|
|
322
344
|
|
|
323
345
|
|
|
324
|
-
dict_properties = ['total_rating_count', 'rating_result', 'previous_rating_result', 'modified_datetime',]
|
|
346
|
+
dict_properties = ['total_rating_count', 'rating_result', 'previous_rating_result', 'modified_datetime', 'outlet_key']
|
|
347
|
+
|
|
348
|
+
@property
|
|
349
|
+
def outlet_key(self):
|
|
350
|
+
return self.outlet.urlsafe().decode('utf-8')
|
|
325
351
|
|
|
326
352
|
@staticmethod
|
|
327
353
|
def get_by_outlet(outlet):
|
|
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.6.8 → trex_model-1.6.10}/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
|
{trex_model-1.6.8 → trex_model-1.6.10}/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
|
{trex_model-1.6.8 → trex_model-1.6.10}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex_model-1.6.8 → trex_model-1.6.10}/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
|