trex-model 1.3.0__tar.gz → 1.3.2__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.3.0 → trex-model-1.3.2}/PKG-INFO +1 -1
- {trex-model-1.3.0 → trex-model-1.3.2}/setup.py +1 -1
- {trex-model-1.3.0 → trex-model-1.3.2}/trex_model.egg-info/PKG-INFO +1 -1
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/lucky_draw_models.py +5 -2
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/membership_models.py +75 -10
- {trex-model-1.3.0 → trex-model-1.3.2}/LICENSE +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/MANIFEST.in +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/README.md +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/setup.cfg +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/conf.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/admin_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/analytic_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/coporate_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/customer_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/import_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/inventory_model.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/loyalty_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/marketing_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/merchant_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/message_model_helper.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/message_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/ndb_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/pos_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/prepaid_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/product_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/program_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/rating_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/redeem_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/reward_model_helpers.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/reward_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/system_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/task_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/test_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/transaction_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/user_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/voucher_models.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/merchant_helpers.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/program_conf.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-1.3.0 → trex-model-1.3.2}/trexmodel/utils/model/model_util.py +0 -0
|
@@ -635,8 +635,11 @@ class LuckyDrawTicket(BaseNModel, DictModel):
|
|
|
635
635
|
won_prize['image_url'] = won_prize.get('image_url')[index:]
|
|
636
636
|
|
|
637
637
|
|
|
638
|
-
|
|
639
|
-
|
|
638
|
+
logger.info('drawed_details=%s', drawed_details)
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
if '/static'in drawed_details.get('ticket_image_url'):
|
|
642
|
+
index = drawed_details.get('ticket_image_url').index('/static')
|
|
640
643
|
drawed_details['ticket_image_url'] = drawed_details['ticket_image_url'][index:]
|
|
641
644
|
|
|
642
645
|
#drawed_details['won_prize'] = won_prize
|
|
@@ -7,7 +7,7 @@ Created on 7 Apr 2021
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
import trexmodel.conf as model_conf
|
|
10
|
-
from trexlib.utils.string_util import is_not_empty
|
|
10
|
+
from trexlib.utils.string_util import is_not_empty, random_string
|
|
11
11
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, \
|
|
12
12
|
MerchantUser, Outlet
|
|
13
13
|
import logging
|
|
@@ -34,6 +34,11 @@ class MembershipBase(BaseNModel, DictModel):
|
|
|
34
34
|
|
|
35
35
|
archived = ndb.BooleanProperty(default=False)
|
|
36
36
|
|
|
37
|
+
discount_rate = ndb.IntegerProperty(default=0)
|
|
38
|
+
|
|
39
|
+
image_storage_filename = ndb.StringProperty(required=False)
|
|
40
|
+
image_public_url = ndb.StringProperty(required=False)
|
|
41
|
+
|
|
37
42
|
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
38
43
|
modified_datetime = ndb.DateTimeProperty(required=True, auto_now=True)
|
|
39
44
|
archived_datetime = ndb.DateTimeProperty(required=False)
|
|
@@ -44,12 +49,21 @@ class MembershipBase(BaseNModel, DictModel):
|
|
|
44
49
|
modified_by = ndb.KeyProperty(name="modified_by", kind=MerchantUser)
|
|
45
50
|
modified_by_username = ndb.StringProperty(required=False)
|
|
46
51
|
|
|
47
|
-
dict_properties = ['label', 'desc', 'terms_and_conditions', 'expiration_type',
|
|
52
|
+
dict_properties = ['label', 'desc', 'terms_and_conditions', 'expiration_type',
|
|
53
|
+
'expiration_value', 'created_datetime', 'modified_datetime',
|
|
54
|
+
'discount_rate', 'image_public_url',]
|
|
48
55
|
|
|
49
56
|
@property
|
|
50
57
|
def merchant_acct(self):
|
|
51
58
|
return MerchantAcct.fetch(self.key.parent().urlsafe())
|
|
52
59
|
|
|
60
|
+
@property
|
|
61
|
+
def membership_card_image(self):
|
|
62
|
+
if self.image_public_url:
|
|
63
|
+
return self.image_public_url
|
|
64
|
+
else:
|
|
65
|
+
return self.merchant_acct.logo_public_url
|
|
66
|
+
|
|
53
67
|
@classmethod
|
|
54
68
|
def list_by_merchant_acct(cls, merchant_acct, is_archived=False):
|
|
55
69
|
return cls.query(ndb.AND(MerchantMembership.archived == is_archived), ancestor=merchant_acct.create_ndb_key()).fetch(limit=model_conf.MAX_FETCH_RECORD)
|
|
@@ -76,8 +90,44 @@ class MembershipBase(BaseNModel, DictModel):
|
|
|
76
90
|
|
|
77
91
|
else:
|
|
78
92
|
#for no expiration
|
|
79
|
-
return datetime.max
|
|
80
|
-
|
|
93
|
+
return datetime.max
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def upload_membership_card_image(cls, membership, uploading_file, merchant_acct, bucket, modified_by=None):
|
|
97
|
+
file_prefix = random_string(8)
|
|
98
|
+
image_storage_filename = 'merchant/'+merchant_acct.key_in_str+'/membership/'+file_prefix+'-'+uploading_file.filename
|
|
99
|
+
blob = bucket.blob(image_storage_filename)
|
|
100
|
+
|
|
101
|
+
logger.debug('image_storage_filename=%s', image_storage_filename)
|
|
102
|
+
|
|
103
|
+
blob.upload_from_string(
|
|
104
|
+
uploading_file.read(),
|
|
105
|
+
content_type=uploading_file.content_type
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
image_public_url = blob.public_url
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
modified_by_username = None
|
|
112
|
+
|
|
113
|
+
if is_not_empty(modified_by):
|
|
114
|
+
if isinstance(modified_by, MerchantUser):
|
|
115
|
+
modified_by_username = modified_by.username
|
|
116
|
+
|
|
117
|
+
if is_not_empty(membership.image_storage_filename):
|
|
118
|
+
old_image_blob = bucket.get_blob(membership.image_storage_filename)
|
|
119
|
+
if old_image_blob:
|
|
120
|
+
old_image_blob.delete()
|
|
121
|
+
|
|
122
|
+
membership.image_public_url = image_public_url
|
|
123
|
+
membership.image_storage_filename = image_storage_filename
|
|
124
|
+
|
|
125
|
+
membership.modified_by = modified_by.create_ndb_key()
|
|
126
|
+
membership.modified_by_username = modified_by_username
|
|
127
|
+
|
|
128
|
+
membership.put()
|
|
129
|
+
|
|
130
|
+
|
|
81
131
|
class MerchantMembership(MembershipBase):
|
|
82
132
|
|
|
83
133
|
|
|
@@ -87,6 +137,8 @@ class MerchantMembership(MembershipBase):
|
|
|
87
137
|
'label' : self.label,
|
|
88
138
|
'expiration_type' : self.expiration_type,
|
|
89
139
|
'expiration_value' : self.expiration_value,
|
|
140
|
+
'card_image' : self.membership_card_image,
|
|
141
|
+
'is_tier' : False,
|
|
90
142
|
}
|
|
91
143
|
|
|
92
144
|
return membership_configuration
|
|
@@ -94,7 +146,7 @@ class MerchantMembership(MembershipBase):
|
|
|
94
146
|
|
|
95
147
|
@staticmethod
|
|
96
148
|
def create(merchant_acct, label, desc=None, expiration_type=None, expiration_value=None,
|
|
97
|
-
created_by=None):
|
|
149
|
+
created_by=None, discount_rate=0, terms_and_conditions=None):
|
|
98
150
|
|
|
99
151
|
created_by_username = None
|
|
100
152
|
if is_not_empty(created_by):
|
|
@@ -105,10 +157,12 @@ class MerchantMembership(MembershipBase):
|
|
|
105
157
|
parent = merchant_acct.create_ndb_key(),
|
|
106
158
|
label = label,
|
|
107
159
|
desc = desc,
|
|
160
|
+
discount_rate = discount_rate,
|
|
108
161
|
expiration_type = expiration_type,
|
|
109
162
|
expiration_value = expiration_value,
|
|
110
163
|
created_by = created_by.create_ndb_key(),
|
|
111
164
|
created_by_username = created_by_username,
|
|
165
|
+
terms_and_conditions = terms_and_conditions,
|
|
112
166
|
)
|
|
113
167
|
|
|
114
168
|
merchant_membership.put()
|
|
@@ -119,7 +173,7 @@ class MerchantMembership(MembershipBase):
|
|
|
119
173
|
|
|
120
174
|
@staticmethod
|
|
121
175
|
def update(merchant_membership, label, desc=None, expiration_type=None, expiration_value=None,
|
|
122
|
-
modified_by=None):
|
|
176
|
+
modified_by=None, discount_rate=0, terms_and_conditions=None):
|
|
123
177
|
modified_by_username = None
|
|
124
178
|
if is_not_empty(modified_by):
|
|
125
179
|
if isinstance(modified_by, MerchantUser):
|
|
@@ -131,6 +185,9 @@ class MerchantMembership(MembershipBase):
|
|
|
131
185
|
merchant_membership.expiration_value = expiration_value
|
|
132
186
|
merchant_membership.modified_by = modified_by.create_ndb_key()
|
|
133
187
|
merchant_membership.modified_by_username = modified_by_username
|
|
188
|
+
merchant_membership.discount_rate = discount_rate
|
|
189
|
+
merchant_membership.terms_and_conditions = terms_and_conditions
|
|
190
|
+
|
|
134
191
|
|
|
135
192
|
merchant_membership.put()
|
|
136
193
|
|
|
@@ -153,8 +210,9 @@ class MerchantTierMembership(MembershipBase):
|
|
|
153
210
|
entitle_qualification_value = ndb.FloatProperty(required=False)
|
|
154
211
|
upgrade_expiry_type = ndb.StringProperty(required=True)
|
|
155
212
|
|
|
156
|
-
dict_properties = ['label', 'desc', 'expiration_type', 'expiration_value', 'entitle_qualification_type',
|
|
157
|
-
'entitle_qualification_value', 'upgrade_expiry_type', 'created_datetime', 'modified_datetime'
|
|
213
|
+
dict_properties = ['label', 'desc', 'terms_and_conditions', 'expiration_type', 'expiration_value', 'entitle_qualification_type',
|
|
214
|
+
'entitle_qualification_value', 'upgrade_expiry_type', 'created_datetime', 'modified_datetime',
|
|
215
|
+
'discount_rate', 'image_public_url',
|
|
158
216
|
]
|
|
159
217
|
|
|
160
218
|
|
|
@@ -167,6 +225,8 @@ class MerchantTierMembership(MembershipBase):
|
|
|
167
225
|
'entitle_qualification_type' : self.entitle_qualification_type,
|
|
168
226
|
'entitle_qualification_value' : self.entitle_qualification_value,
|
|
169
227
|
'upgrade_expiry_type' : self.upgrade_expiry_type,
|
|
228
|
+
'card_image' : self.membership_card_image,
|
|
229
|
+
'is_tier' : True,
|
|
170
230
|
}
|
|
171
231
|
|
|
172
232
|
return membership_configuration
|
|
@@ -174,7 +234,7 @@ class MerchantTierMembership(MembershipBase):
|
|
|
174
234
|
@staticmethod
|
|
175
235
|
def create(merchant_acct, label=None, desc=None, expiration_type=None, expiration_value=None,
|
|
176
236
|
entitle_qualification_type=None, entitle_qualification_value=None, upgrade_expiry_type=None,
|
|
177
|
-
created_by=None):
|
|
237
|
+
created_by=None, discount_rate=0, terms_and_conditions=None):
|
|
178
238
|
|
|
179
239
|
created_by_username = None
|
|
180
240
|
if is_not_empty(created_by):
|
|
@@ -192,6 +252,8 @@ class MerchantTierMembership(MembershipBase):
|
|
|
192
252
|
upgrade_expiry_type = upgrade_expiry_type,
|
|
193
253
|
created_by = created_by.create_ndb_key(),
|
|
194
254
|
created_by_username = created_by_username,
|
|
255
|
+
discount_rate = discount_rate,
|
|
256
|
+
terms_and_conditions = terms_and_conditions,
|
|
195
257
|
)
|
|
196
258
|
|
|
197
259
|
merchant_membership.put()
|
|
@@ -207,7 +269,7 @@ class MerchantTierMembership(MembershipBase):
|
|
|
207
269
|
@staticmethod
|
|
208
270
|
def update(merchant_membership, label=None, desc=None, expiration_type=None, expiration_value=None,
|
|
209
271
|
entitle_qualification_type=None, entitle_qualification_value=None, upgrade_expiry_type=None,
|
|
210
|
-
modified_by=None):
|
|
272
|
+
modified_by=None, discount_rate=0, terms_and_conditions=None):
|
|
211
273
|
|
|
212
274
|
modified_by_username = None
|
|
213
275
|
if is_not_empty(modified_by):
|
|
@@ -224,6 +286,9 @@ class MerchantTierMembership(MembershipBase):
|
|
|
224
286
|
merchant_membership.upgrade_expiry_type = upgrade_expiry_type
|
|
225
287
|
merchant_membership.modified_by_username = modified_by_username
|
|
226
288
|
|
|
289
|
+
merchant_membership.discount_rate = discount_rate
|
|
290
|
+
merchant_membership.terms_and_conditions = terms_and_conditions
|
|
291
|
+
|
|
227
292
|
merchant_membership.put()
|
|
228
293
|
|
|
229
294
|
merchant_acct = merchant_membership.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
|
|
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.3.0 → trex-model-1.3.2}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.3.0 → trex-model-1.3.2}/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
|