trex-model 1.3.6__tar.gz → 1.4.0__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.6 → trex-model-1.4.0}/PKG-INFO +10 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/setup.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trex_model.egg-info/PKG-INFO +10 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trex_model.egg-info/SOURCES.txt +2 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/admin_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/analytic_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/coporate_models.py +0 -10
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/customer_models.py +7 -2
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/fb_subsriber_models.py +0 -7
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/import_models.py +1 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/inventory_model.py +3 -11
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/loyalty_models.py +3 -3
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/lucky_draw_models.py +8 -4
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/marketing_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/membership_models.py +2 -3
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/merchant_models.py +237 -11
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/message_model_helper.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/message_models.py +1 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/ndb_models.py +5 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/pos_models.py +2 -2
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/prepaid_models.py +41 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/product_models.py +2 -5
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/program_models.py +11 -12
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/rating_models.py +1 -1
- trex-model-1.4.0/trexmodel/models/datastore/recruit_models.py +45 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/redeem_models.py +1 -2
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/redemption_catalogue_models.py +3 -4
- trex-model-1.4.0/trexmodel/models/datastore/referral_program_model.py +367 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/reward_model_helpers.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/reward_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/system_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/task_models.py +1 -2
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/test_models.py +1 -11
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/transaction_models.py +9 -2
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/user_models.py +30 -11
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/voucher_models.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/merchant_helpers.py +17 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/program_conf.py +57 -4
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/utils/model/model_util.py +1 -1
- {trex-model-1.3.6 → trex-model-1.4.0}/LICENSE +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/MANIFEST.in +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/README.md +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/setup.cfg +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/__init__.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/conf.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.3.6 → trex-model-1.4.0}/trexmodel/utils/model/__init__.py +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: This is database modelusing google datastore mode module
|
|
10
|
-
|
|
11
|
-
Platform: UNKNOWN
|
|
12
8
|
Classifier: Programming Language :: Python :: 3
|
|
13
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
10
|
Classifier: Operating System :: OS Independent
|
|
15
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: google-cloud-firestore
|
|
14
|
+
Requires-Dist: google_cloud_datastore
|
|
15
|
+
Requires-Dist: google-cloud-ndb
|
|
16
|
+
Requires-Dist: six
|
|
17
|
+
Requires-Dist: trex-lib
|
|
18
|
+
Requires-Dist: flask-login==0.6.2
|
|
19
|
+
|
|
20
|
+
This is database modelusing google datastore mode module
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: This is database modelusing google datastore mode module
|
|
10
|
-
|
|
11
|
-
Platform: UNKNOWN
|
|
12
8
|
Classifier: Programming Language :: Python :: 3
|
|
13
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
10
|
Classifier: Operating System :: OS Independent
|
|
15
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: google-cloud-firestore
|
|
14
|
+
Requires-Dist: google_cloud_datastore
|
|
15
|
+
Requires-Dist: google-cloud-ndb
|
|
16
|
+
Requires-Dist: six
|
|
17
|
+
Requires-Dist: trex-lib
|
|
18
|
+
Requires-Dist: flask-login==0.6.2
|
|
19
|
+
|
|
20
|
+
This is database modelusing google datastore mode module
|
|
@@ -40,8 +40,10 @@ trexmodel/models/datastore/prepaid_models.py
|
|
|
40
40
|
trexmodel/models/datastore/product_models.py
|
|
41
41
|
trexmodel/models/datastore/program_models.py
|
|
42
42
|
trexmodel/models/datastore/rating_models.py
|
|
43
|
+
trexmodel/models/datastore/recruit_models.py
|
|
43
44
|
trexmodel/models/datastore/redeem_models.py
|
|
44
45
|
trexmodel/models/datastore/redemption_catalogue_models.py
|
|
46
|
+
trexmodel/models/datastore/referral_program_model.py
|
|
45
47
|
trexmodel/models/datastore/reward_model_helpers.py
|
|
46
48
|
trexmodel/models/datastore/reward_models.py
|
|
47
49
|
trexmodel/models/datastore/spending_base_program_model.py
|
|
@@ -9,7 +9,7 @@ from trexlib.utils.security_util import generate_user_id, hash_password
|
|
|
9
9
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
10
10
|
from trexlib.utils.string_util import random_string
|
|
11
11
|
from trexlib.utils.common.common_util import logger
|
|
12
|
-
from
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class SuperUser(UserMin):
|
|
@@ -3,7 +3,7 @@ Created on 25 Jan 2021
|
|
|
3
3
|
|
|
4
4
|
@author: jacklok
|
|
5
5
|
'''
|
|
6
|
-
from
|
|
6
|
+
from trexconf import conf as model_conf
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from datetime import timedelta
|
|
@@ -5,17 +5,7 @@ Created on 19 Feb 2021
|
|
|
5
5
|
'''
|
|
6
6
|
from google.cloud import ndb
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel, FullTextSearchable
|
|
8
|
-
from trexmodel.models.datastore.system_models import SentEmail
|
|
9
|
-
from trexmodel.models.datastore.user_models import UserMin
|
|
10
|
-
import trexmodel.conf as model_conf
|
|
11
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
12
|
-
from trexlib.utils.string_util import random_number
|
|
13
8
|
import logging
|
|
14
|
-
from datetime import datetime, timedelta
|
|
15
|
-
from trexlib.utils.common.date_util import parse_datetime
|
|
16
|
-
from trexmodel import conf
|
|
17
|
-
from google.auth._default import default
|
|
18
|
-
from trexmodel.models.datastore.system_models import Tagging
|
|
19
9
|
|
|
20
10
|
|
|
21
11
|
logger = logging.getLogger('model')
|
|
@@ -13,7 +13,7 @@ from trexlib.utils.string_util import is_not_empty, is_empty
|
|
|
13
13
|
import logging
|
|
14
14
|
from trexlib.utils.common.date_util import convert_date_to_datetime,\
|
|
15
15
|
to_day_of_year
|
|
16
|
-
from
|
|
16
|
+
from trexconf import conf, program_conf
|
|
17
17
|
from six import string_types
|
|
18
18
|
from datetime import datetime, timedelta
|
|
19
19
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership,\
|
|
@@ -46,6 +46,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
46
46
|
birth_day_in_year = ndb.IntegerProperty(required=False)
|
|
47
47
|
gender = ndb.StringProperty(required=False)
|
|
48
48
|
reference_code = ndb.StringProperty(required=True)
|
|
49
|
+
referral_code = ndb.StringProperty(required=False)
|
|
49
50
|
|
|
50
51
|
mobile_app_installed = ndb.BooleanProperty(required=False, default=False)
|
|
51
52
|
|
|
@@ -68,6 +69,8 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
68
69
|
entitled_membership_reward_summary = ndb.JsonProperty()
|
|
69
70
|
entitled_lucky_draw_ticket_summary = ndb.JsonProperty(required=False)
|
|
70
71
|
|
|
72
|
+
referrer_code = ndb.StringProperty(required=False)
|
|
73
|
+
|
|
71
74
|
kpi_summary = ndb.JsonProperty()
|
|
72
75
|
|
|
73
76
|
device_details = ndb.JsonProperty()
|
|
@@ -79,7 +82,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
79
82
|
'reward_summary', 'entitled_voucher_summary', 'prepaid_summary', 'kpi_summary', 'entitled_lucky_draw_ticket_summary',
|
|
80
83
|
'entitled_birthday_reward_summary', 'tier_membership_key',
|
|
81
84
|
'registered_outlet_key', 'registered_merchant_acct_key', 'registered_datetime', 'modified_datetime',
|
|
82
|
-
'registered_user_acct',
|
|
85
|
+
'registered_user_acct','referral_code',
|
|
83
86
|
|
|
84
87
|
]
|
|
85
88
|
|
|
@@ -267,6 +270,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
267
270
|
for ticket in tickets_list:
|
|
268
271
|
ticket.patch_prize_image_base_url()
|
|
269
272
|
Customer.update_ticket_into_lucky_draw_ticket_summary(customer_acct, ticket.to_configuration())
|
|
273
|
+
|
|
270
274
|
@classmethod
|
|
271
275
|
def get_by_reference_code(cls, reference_code, merchant_acct):
|
|
272
276
|
return cls.query(ndb.AND(cls.reference_code==reference_code, cls.merchant_acct==merchant_acct.create_ndb_key())).get()
|
|
@@ -353,6 +357,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
353
357
|
mobile_phone = user_acct.mobile_phone,
|
|
354
358
|
gender = user_acct.gender,
|
|
355
359
|
reference_code = user_acct.reference_code,
|
|
360
|
+
referral_code = user_acct.referral_code,
|
|
356
361
|
birth_date = user_acct.birth_date,
|
|
357
362
|
birth_date_date_str = user_acct.birth_date_date_str,
|
|
358
363
|
birth_day_in_year = user_acct.birth_day_in_year,
|
|
@@ -7,13 +7,6 @@ Created on 23 Oct 2020
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
|
|
10
|
-
import logging
|
|
11
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
12
|
-
|
|
13
|
-
from trexlib import conf as lib_conf
|
|
14
|
-
from trexmodel import conf as model_conf
|
|
15
|
-
import json
|
|
16
|
-
from json import JSONEncoder
|
|
17
10
|
from datetime import datetime
|
|
18
11
|
|
|
19
12
|
class FacebookSubscriber(BaseNModel, DictModel):
|
|
@@ -5,17 +5,13 @@ Created on 26 Sep 2023
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
|
-
from trexmodel.models.datastore.user_models import UserMin
|
|
9
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
10
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
11
9
|
from trexlib.utils.string_util import random_string
|
|
12
|
-
from trexlib.utils.common.common_util import logger
|
|
13
|
-
from trexlib import conf
|
|
14
10
|
from trexmodel.models.datastore.merchant_models import MerchantAcct
|
|
15
11
|
import logging
|
|
16
12
|
import csv, io
|
|
17
13
|
|
|
18
|
-
from
|
|
14
|
+
from trexconf import program_conf
|
|
19
15
|
|
|
20
16
|
logger = logging.getLogger('model')
|
|
21
17
|
|
|
@@ -5,17 +5,9 @@ Created on 19 Aug 2021
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
|
-
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
-
from trexmodel.models.datastore.
|
|
10
|
-
|
|
11
|
-
from trexlib.utils.string_util import is_empty, is_not_empty
|
|
12
|
-
import logging, json
|
|
13
|
-
from trexmodel import conf, program_conf
|
|
14
|
-
from trexlib.utils.string_util import random_string
|
|
15
|
-
from datetime import datetime, timedelta
|
|
16
|
-
from trexmodel.models.datastore.customer_models import Customer
|
|
17
|
-
import trexmodel.conf as model_conf
|
|
18
|
-
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
8
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
+
from trexmodel.models.datastore.merchant_models import MerchantUser
|
|
10
|
+
import logging
|
|
19
11
|
|
|
20
12
|
logger = logging.getLogger('model')
|
|
21
13
|
|
|
@@ -8,10 +8,10 @@ from google.cloud import ndb
|
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from trexmodel.models.datastore.merchant_models import Outlet
|
|
10
10
|
from trexlib.utils.string_util import random_number
|
|
11
|
-
import logging
|
|
12
|
-
from
|
|
11
|
+
import logging
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
from datetime import datetime
|
|
14
|
-
from google.api_core.operations_v1.operations_client_config import config
|
|
14
|
+
#from google.api_core.operations_v1.operations_client_config import config
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger('debug')
|
|
17
17
|
|
|
@@ -4,7 +4,7 @@ Created on 12 May 2023
|
|
|
4
4
|
@author: jacklok
|
|
5
5
|
'''
|
|
6
6
|
import logging
|
|
7
|
-
from
|
|
7
|
+
from trexconf import program_conf
|
|
8
8
|
import trexmodel.conf as model_conf
|
|
9
9
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
10
10
|
from google.cloud import ndb
|
|
@@ -58,9 +58,9 @@ class LuckyDrawProgram(LuckyDrawBase):
|
|
|
58
58
|
'created_datetime', 'modified_datetime','archived_datetime', 'completed_status',
|
|
59
59
|
'condition_settings', 'exclusivity_settings', 'prize_settings',
|
|
60
60
|
'exclusive_tags_list', 'exclusive_memberships_list', 'exclusive_tier_memberships_list',
|
|
61
|
-
'created_by_username', 'modified_by_username', '
|
|
61
|
+
'created_by_username', 'modified_by_username', 'completed_progress_in_percentage',
|
|
62
62
|
'is_published', 'is_enabled','is_disabled', 'totalPrizePossibility',
|
|
63
|
-
'image_storage_filename', 'image_public_url', 'test_result',
|
|
63
|
+
'image_storage_filename', 'image_public_url', 'test_result', 'is_expired',
|
|
64
64
|
]
|
|
65
65
|
|
|
66
66
|
|
|
@@ -95,6 +95,10 @@ class LuckyDrawProgram(LuckyDrawBase):
|
|
|
95
95
|
def is_disabled(self):
|
|
96
96
|
return self.enabled==False
|
|
97
97
|
|
|
98
|
+
@property
|
|
99
|
+
def is_expired(self):
|
|
100
|
+
return self.end_date<datetime.now().date()
|
|
101
|
+
|
|
98
102
|
@property
|
|
99
103
|
def is_archived(self):
|
|
100
104
|
return self.archived
|
|
@@ -119,7 +123,7 @@ class LuckyDrawProgram(LuckyDrawBase):
|
|
|
119
123
|
return ','.join(self.exclusivity_settings.get('tier_memberships')) or ''
|
|
120
124
|
|
|
121
125
|
@property
|
|
122
|
-
def
|
|
126
|
+
def completed_progress_in_percentage(self):
|
|
123
127
|
return program_conf.lucky_draw_program_completed_progress_percentage(self.completed_status)
|
|
124
128
|
|
|
125
129
|
@property
|
|
@@ -9,7 +9,7 @@ from trexmodel.models.datastore.merchant_models import MerchantUser,\
|
|
|
9
9
|
MerchantAcct
|
|
10
10
|
from trexlib.utils.string_util import is_not_empty, random_string
|
|
11
11
|
from datetime import datetime
|
|
12
|
-
from
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
import trexmodel.conf as model_conf
|
|
14
14
|
import logging
|
|
15
15
|
|
|
@@ -9,13 +9,12 @@ from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
|
9
9
|
import trexmodel.conf as model_conf
|
|
10
10
|
from trexlib.utils.string_util import is_not_empty, random_string
|
|
11
11
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, \
|
|
12
|
-
MerchantUser
|
|
12
|
+
MerchantUser
|
|
13
13
|
import logging
|
|
14
14
|
from dateutil.relativedelta import relativedelta
|
|
15
|
-
from datetime import timedelta
|
|
16
15
|
|
|
17
16
|
from datetime import datetime
|
|
18
|
-
from
|
|
17
|
+
from trexconf import program_conf
|
|
19
18
|
|
|
20
19
|
logger = logging.getLogger('model')
|
|
21
20
|
|
|
@@ -14,10 +14,9 @@ from trexlib.utils.string_util import random_number, is_empty, is_not_empty,\
|
|
|
14
14
|
split_by_length, random_string
|
|
15
15
|
import logging
|
|
16
16
|
from datetime import datetime, timedelta
|
|
17
|
-
from
|
|
17
|
+
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
|
-
from trexlib.utils.common.common_util import sort_dict_list
|
|
21
20
|
from trexmodel.program_conf import LOYALTY_PACKAGE_LITE, LOYALTY_PRODUCT
|
|
22
21
|
|
|
23
22
|
logger = logging.getLogger('model')
|
|
@@ -67,30 +66,32 @@ class MerchantAcct(MerchantMin):
|
|
|
67
66
|
outlet_count = ndb.IntegerProperty(default=0)
|
|
68
67
|
|
|
69
68
|
published_program_configuration = ndb.JsonProperty()
|
|
69
|
+
published_referral_program_configuration = ndb.JsonProperty()
|
|
70
70
|
published_voucher_configuration = ndb.JsonProperty()
|
|
71
71
|
published_redemption_catalogue_configuration = ndb.JsonProperty()
|
|
72
72
|
|
|
73
73
|
membership_configuration = ndb.JsonProperty()
|
|
74
74
|
tier_membership_configuration = ndb.JsonProperty()
|
|
75
75
|
|
|
76
|
-
reward_naming_configuration
|
|
76
|
+
reward_naming_configuration = ndb.JsonProperty()
|
|
77
77
|
|
|
78
|
-
prepaid_configuration
|
|
78
|
+
prepaid_configuration = ndb.JsonProperty()
|
|
79
79
|
|
|
80
|
-
lucky_draw_configuration
|
|
80
|
+
lucky_draw_configuration = ndb.JsonProperty(required=False)
|
|
81
81
|
|
|
82
|
-
product_modifier_configuration
|
|
82
|
+
product_modifier_configuration = ndb.JsonProperty()
|
|
83
83
|
|
|
84
|
-
program_settings
|
|
84
|
+
program_settings = ndb.JsonProperty()
|
|
85
85
|
|
|
86
|
-
stat_figure_update_interval_in_minutes
|
|
87
|
-
stat_figure_update_datetime_format
|
|
86
|
+
stat_figure_update_interval_in_minutes = conf.MERCHANT_STAT_FIGURE_UPDATE_INTERVAL_IN_MINUTES
|
|
87
|
+
stat_figure_update_datetime_format = '%d-%m-%Y %H:%M:%S'
|
|
88
88
|
|
|
89
89
|
dict_properties = ['company_name', 'brand_name', 'contact_name', 'business_reg_no', 'mobile_phone',
|
|
90
90
|
'office_phone', 'fax_phone', 'email', 'account_code', 'country',
|
|
91
91
|
'registered_datetime', 'modified_datetime', 'plan_start_date', 'plan_end_date', 'currency_code',
|
|
92
|
-
'timezone',
|
|
93
|
-
'published_program_configuration', '
|
|
92
|
+
'timezone', 'effective_referral_program_count',
|
|
93
|
+
'published_program_configuration', 'published_referral_program_configuration',
|
|
94
|
+
'published_voucher_configuration', 'membership_configuration',
|
|
94
95
|
'tier_membership_configuration', 'prepaid_configuration', 'lucky_draw_configuration', 'product_modifier_configuration',
|
|
95
96
|
'dashboard_stat_figure', 'program_settings', 'is_tier_membership_configured', 'website',
|
|
96
97
|
'product_package', 'loyalty_package','account_plan','outlet_count', 'outlet_limit',
|
|
@@ -123,6 +124,31 @@ class MerchantAcct(MerchantMin):
|
|
|
123
124
|
|
|
124
125
|
return LOYALTY_PACKAGE_LITE
|
|
125
126
|
|
|
127
|
+
@property
|
|
128
|
+
def effective_referral_program_count(self):
|
|
129
|
+
if self.published_referral_program_configuration:
|
|
130
|
+
program_count = self.published_referral_program_configuration.get('count',0)
|
|
131
|
+
if program_count>0:
|
|
132
|
+
check_effective_count = 0
|
|
133
|
+
program_list = self.published_referral_program_configuration.get('programs');
|
|
134
|
+
today_date = datetime.today()
|
|
135
|
+
for program_details in program_list:
|
|
136
|
+
start_date_str = program_details.get('start_date')
|
|
137
|
+
start_date = datetime.strptime(start_date_str, '%d-%m-%Y')
|
|
138
|
+
|
|
139
|
+
end_date_str = program_details.get('end_date')
|
|
140
|
+
end_date = datetime.strptime(end_date_str, '%d-%m-%Y')
|
|
141
|
+
|
|
142
|
+
if start_date<=today_date and today_date<=end_date:
|
|
143
|
+
check_effective_count+=1
|
|
144
|
+
|
|
145
|
+
return check_effective_count
|
|
146
|
+
|
|
147
|
+
else:
|
|
148
|
+
return program_count
|
|
149
|
+
|
|
150
|
+
return 0
|
|
151
|
+
|
|
126
152
|
@property
|
|
127
153
|
def outlet_limit(self):
|
|
128
154
|
if self.account_plan:
|
|
@@ -213,6 +239,47 @@ class MerchantAcct(MerchantMin):
|
|
|
213
239
|
if self.lucky_draw_configuration.get('settings'):
|
|
214
240
|
return self.lucky_draw_configuration['settings']['ticket_image_url']
|
|
215
241
|
|
|
242
|
+
@property
|
|
243
|
+
def referrer_promote_title(self):
|
|
244
|
+
if is_not_empty(self.program_settings):
|
|
245
|
+
if self.program_settings.get('referral_program'):
|
|
246
|
+
return self.program_settings.get('referral_program').get('referrer_promote_title', '')
|
|
247
|
+
return ''
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def referee_promote_title(self):
|
|
251
|
+
if is_not_empty(self.program_settings):
|
|
252
|
+
if self.program_settings.get('referral_program'):
|
|
253
|
+
return self.program_settings.get('referral_program').get('referee_promote_title', '')
|
|
254
|
+
return ''
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def referrer_promote_desc(self):
|
|
258
|
+
if is_not_empty(self.program_settings):
|
|
259
|
+
if self.program_settings.get('referral_program'):
|
|
260
|
+
return self.program_settings.get('referral_program').get('referrer_promote_desc', '')
|
|
261
|
+
return ''
|
|
262
|
+
|
|
263
|
+
@property
|
|
264
|
+
def referee_promote_desc(self):
|
|
265
|
+
if is_not_empty(self.program_settings):
|
|
266
|
+
if self.program_settings.get('referral_program'):
|
|
267
|
+
return self.program_settings.get('referral_program').get('referee_promote_desc', '')
|
|
268
|
+
return ''
|
|
269
|
+
|
|
270
|
+
@property
|
|
271
|
+
def referrer_promote_image(self):
|
|
272
|
+
if is_not_empty(self.program_settings):
|
|
273
|
+
if self.program_settings.get('referral_program'):
|
|
274
|
+
return self.program_settings.get('referral_program').get('referrer_promote_image')
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def referee_promote_image(self):
|
|
278
|
+
if is_not_empty(self.program_settings):
|
|
279
|
+
if self.program_settings.get('referral_program'):
|
|
280
|
+
return self.program_settings.get('referral_program').get('referee_promote_image')
|
|
281
|
+
|
|
282
|
+
|
|
216
283
|
@staticmethod
|
|
217
284
|
def default_program_settings():
|
|
218
285
|
return {
|
|
@@ -222,7 +289,104 @@ class MerchantAcct(MerchantMin):
|
|
|
222
289
|
'membership_renew_late_day' : 30,
|
|
223
290
|
|
|
224
291
|
}
|
|
292
|
+
|
|
293
|
+
def update_referrer_program_promote_text(self,
|
|
294
|
+
promote_title=None,
|
|
295
|
+
promote_desc=None,
|
|
296
|
+
modified_by=None):
|
|
297
|
+
modified_by_username = None
|
|
298
|
+
|
|
299
|
+
if is_not_empty(modified_by):
|
|
300
|
+
if isinstance(modified_by, MerchantUser):
|
|
301
|
+
modified_by_username = modified_by.username
|
|
302
|
+
|
|
303
|
+
if is_empty(self.program_settings):
|
|
304
|
+
self.program_settings = {
|
|
305
|
+
'referral_program':{}
|
|
306
|
+
}
|
|
307
|
+
else:
|
|
308
|
+
if is_empty(self.program_settings.get('referral_program')):
|
|
309
|
+
self.program_settings['referral_program'] = {}
|
|
225
310
|
|
|
311
|
+
self.modified_by = modified_by.create_ndb_key()
|
|
312
|
+
self.modified_by_username = modified_by_username
|
|
313
|
+
|
|
314
|
+
self.program_settings['referral_program']['referrer_promote_title'] = promote_title
|
|
315
|
+
self.program_settings['referral_program']['referrer_promote_desc'] = promote_desc
|
|
316
|
+
self.put()
|
|
317
|
+
|
|
318
|
+
def update_referee_program_promote_text(self,
|
|
319
|
+
promote_title=None,
|
|
320
|
+
promote_desc=None,
|
|
321
|
+
modified_by=None):
|
|
322
|
+
modified_by_username = None
|
|
323
|
+
|
|
324
|
+
if is_not_empty(modified_by):
|
|
325
|
+
if isinstance(modified_by, MerchantUser):
|
|
326
|
+
modified_by_username = modified_by.username
|
|
327
|
+
|
|
328
|
+
if is_empty(self.program_settings):
|
|
329
|
+
self.program_settings = {
|
|
330
|
+
'referral_program':{}
|
|
331
|
+
}
|
|
332
|
+
else:
|
|
333
|
+
if is_empty(self.program_settings.get('referral_program')):
|
|
334
|
+
self.program_settings['referral_program'] = {}
|
|
335
|
+
|
|
336
|
+
self.modified_by = modified_by.create_ndb_key()
|
|
337
|
+
self.modified_by_username = modified_by_username
|
|
338
|
+
|
|
339
|
+
self.program_settings['referral_program']['referee_promote_title'] = promote_title
|
|
340
|
+
self.program_settings['referral_program']['referee_promote_desc'] = promote_desc
|
|
341
|
+
self.put()
|
|
342
|
+
|
|
343
|
+
def upload_referrer_program_promote_image(self, image_public_url=None, image_storage_filename=None, modified_by=None):
|
|
344
|
+
|
|
345
|
+
modified_by_username = None
|
|
346
|
+
|
|
347
|
+
if is_not_empty(modified_by):
|
|
348
|
+
if isinstance(modified_by, MerchantUser):
|
|
349
|
+
modified_by_username = modified_by.username
|
|
350
|
+
|
|
351
|
+
if is_empty(self.program_settings):
|
|
352
|
+
self.program_settings = {
|
|
353
|
+
'referral_program':{}
|
|
354
|
+
}
|
|
355
|
+
else:
|
|
356
|
+
if is_empty(self.program_settings.get('referral_program')):
|
|
357
|
+
self.program_settings['referral_program'] = {}
|
|
358
|
+
|
|
359
|
+
self.program_settings['referral_program']['referrer_promote_image'] = image_public_url
|
|
360
|
+
self.program_settings['referral_program']['referrer_promote_image_filename'] = image_storage_filename
|
|
361
|
+
|
|
362
|
+
self.modified_by = modified_by.create_ndb_key()
|
|
363
|
+
self.modified_by_username = modified_by_username
|
|
364
|
+
|
|
365
|
+
self.put()
|
|
366
|
+
|
|
367
|
+
def upload_referee_program_promote_image(self, image_public_url=None, image_storage_filename=None, modified_by=None):
|
|
368
|
+
|
|
369
|
+
modified_by_username = None
|
|
370
|
+
|
|
371
|
+
if is_not_empty(modified_by):
|
|
372
|
+
if isinstance(modified_by, MerchantUser):
|
|
373
|
+
modified_by_username = modified_by.username
|
|
374
|
+
|
|
375
|
+
if is_empty(self.program_settings):
|
|
376
|
+
self.program_settings = {
|
|
377
|
+
'referral_program':{}
|
|
378
|
+
}
|
|
379
|
+
else:
|
|
380
|
+
if is_empty(self.program_settings.get('referral_program')):
|
|
381
|
+
self.program_settings['referral_program'] = {}
|
|
382
|
+
|
|
383
|
+
self.program_settings['referral_program']['referee_promote_image'] = image_public_url
|
|
384
|
+
self.program_settings['referral_program']['referee_promote_image_filename'] = image_storage_filename
|
|
385
|
+
|
|
386
|
+
self.modified_by = modified_by.create_ndb_key()
|
|
387
|
+
self.modified_by_username = modified_by_username
|
|
388
|
+
|
|
389
|
+
self.put()
|
|
226
390
|
|
|
227
391
|
@staticmethod
|
|
228
392
|
def update_details(merchant_acct, company_name=None, brand_name=None, business_reg_no=None, contact_name=None,
|
|
@@ -408,6 +572,32 @@ class MerchantAcct(MerchantMin):
|
|
|
408
572
|
|
|
409
573
|
self.put()
|
|
410
574
|
|
|
575
|
+
def update_published_referral_program(self, program_configuration):
|
|
576
|
+
if is_empty(self.published_referral_program_configuration):
|
|
577
|
+
self.published_referral_program_configuration = {
|
|
578
|
+
'programs' :[program_configuration],
|
|
579
|
+
'count' : 1,
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
else:
|
|
583
|
+
self.flush_dirty_program_configuration()
|
|
584
|
+
existing_programs_list = self.published_referral_program_configuration.get('programs')
|
|
585
|
+
|
|
586
|
+
program_key = program_configuration.get('program_key')
|
|
587
|
+
index = 0
|
|
588
|
+
for p in existing_programs_list:
|
|
589
|
+
if p.get('program_key') == program_key:
|
|
590
|
+
existing_programs_list.pop(index)
|
|
591
|
+
|
|
592
|
+
index = index+1
|
|
593
|
+
|
|
594
|
+
existing_programs_list.append(program_configuration)
|
|
595
|
+
|
|
596
|
+
self.published_referral_program_configuration['programs'] = existing_programs_list
|
|
597
|
+
self.published_referral_program_configuration['count'] = len(existing_programs_list)
|
|
598
|
+
|
|
599
|
+
self.put()
|
|
600
|
+
|
|
411
601
|
def add_voucher(self, voucher_configuration):
|
|
412
602
|
if is_empty(self.published_voucher_configuration):
|
|
413
603
|
self.published_voucher_configuration = {
|
|
@@ -678,6 +868,42 @@ class MerchantAcct(MerchantMin):
|
|
|
678
868
|
|
|
679
869
|
self.put()
|
|
680
870
|
|
|
871
|
+
def remove_program_from_published_referral_program_configuration(self, program_key_to_remove):
|
|
872
|
+
|
|
873
|
+
logger.debug('remove_program_from_published_referral_program_configuration: program_key_to_remove=%s', program_key_to_remove)
|
|
874
|
+
|
|
875
|
+
#self.flush_dirty_program_configuration()
|
|
876
|
+
existing_programs_list = self.published_referral_program_configuration['programs']
|
|
877
|
+
program_count = len(existing_programs_list)
|
|
878
|
+
|
|
879
|
+
logger.debug('program_count before remove=%s', program_count)
|
|
880
|
+
|
|
881
|
+
index = 0
|
|
882
|
+
|
|
883
|
+
for program in existing_programs_list:
|
|
884
|
+
|
|
885
|
+
logger.debug('program_key=%s', program.get('program_key'))
|
|
886
|
+
|
|
887
|
+
is_same_program_key = program.get('program_key') == program_key_to_remove
|
|
888
|
+
|
|
889
|
+
logger.debug('is_same_program_key=%s', is_same_program_key)
|
|
890
|
+
|
|
891
|
+
if is_same_program_key:
|
|
892
|
+
existing_programs_list.pop(index)
|
|
893
|
+
|
|
894
|
+
logger.debug('Found program to be remove')
|
|
895
|
+
|
|
896
|
+
index = index+1
|
|
897
|
+
|
|
898
|
+
program_count = len(existing_programs_list)
|
|
899
|
+
|
|
900
|
+
logger.debug('program_count after remove=%s', program_count)
|
|
901
|
+
|
|
902
|
+
self.published_referral_program_configuration['programs'] = existing_programs_list
|
|
903
|
+
self.published_referral_program_configuration['count'] = program_count
|
|
904
|
+
|
|
905
|
+
self.put()
|
|
906
|
+
|
|
681
907
|
|
|
682
908
|
|
|
683
909
|
def remove_redeption_catalogue(self, catalogue_key):
|
|
@@ -7,7 +7,7 @@ from trexmodel.program_conf import REWARD_FORMAT_MAP, REWARD_FORMAT_PREPAID
|
|
|
7
7
|
from trexmodel.models.datastore.message_models import Message
|
|
8
8
|
from trexmodel.conf import MESSAGE_CATEGORY_REWARD, MESSAGE_STATUS_NEW,\
|
|
9
9
|
MESSAGE_CATEGORY_REDEEM
|
|
10
|
-
from
|
|
10
|
+
from trexconf import program_conf
|
|
11
11
|
from babel.numbers import format_currency
|
|
12
12
|
import logging
|
|
13
13
|
|
|
@@ -7,13 +7,9 @@ Created on 9 Nov 2023
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from trexmodel.models.datastore.user_models import User
|
|
10
|
-
|
|
10
|
+
from datetime import datetime
|
|
11
11
|
import logging
|
|
12
|
-
from datetime import datetime, timedelta
|
|
13
|
-
from trexlib.utils.common.date_util import parse_datetime
|
|
14
12
|
from trexmodel import conf
|
|
15
|
-
from google.auth._default import default
|
|
16
|
-
from trexmodel.models.datastore.system_models import Tagging
|
|
17
13
|
from trexmodel.conf import MESSAGE_STATUS_SET, MESSAGE_STATUS_NEW, MESSAGE_CATEGORY_SYSTEM,\
|
|
18
14
|
MESSAGE_STATUS_READ, MESSAGE_CATEGORIES, MESSAGE_CATEGORY_ANNOUNCEMENT
|
|
19
15
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction
|