trex-model 0.1.47__tar.gz → 1.7.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.
- trex_model-1.7.2/LICENSE +19 -0
- trex_model-1.7.2/PKG-INFO +29 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/setup.py +6 -5
- trex_model-1.7.2/trex_model.egg-info/PKG-INFO +29 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trex_model.egg-info/SOURCES.txt +26 -0
- trex_model-1.7.2/trex_model.egg-info/requires.txt +6 -0
- trex_model-1.7.2/trexmodel/conf.py +69 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/admin_models.py +56 -0
- trex_model-1.7.2/trexmodel/models/datastore/analytic_models.py +81 -0
- trex_model-1.7.2/trexmodel/models/datastore/app_models.py +71 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/coporate_models.py +0 -10
- trex_model-1.7.2/trexmodel/models/datastore/customer_model_helpers.py +484 -0
- trex_model-1.7.2/trexmodel/models/datastore/customer_models.py +1541 -0
- trex_model-1.7.2/trexmodel/models/datastore/fan_club_models.py +168 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/fb_subsriber_models.py +0 -8
- trex_model-1.7.2/trexmodel/models/datastore/helper/membership_helpers.py +690 -0
- trex_model-1.7.2/trexmodel/models/datastore/helper/reward_model_helpers.py +162 -0
- trex_model-1.7.2/trexmodel/models/datastore/helper/reward_transaction_helper.py +1619 -0
- trex_model-1.7.2/trexmodel/models/datastore/helper/sales_transaction_helpers.py +33 -0
- trex_model-1.7.2/trexmodel/models/datastore/import_models.py +206 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/inventory_model.py +3 -11
- trex_model-1.7.2/trexmodel/models/datastore/loyalty_models.py +212 -0
- trex_model-1.7.2/trexmodel/models/datastore/lucky_draw_models.py +943 -0
- trex_model-1.7.2/trexmodel/models/datastore/marketing_models.py +545 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/membership_models.py +166 -32
- trex_model-1.7.2/trexmodel/models/datastore/merchant_models.py +2449 -0
- trex_model-1.7.2/trexmodel/models/datastore/merchant_promotion_models.py +105 -0
- trex_model-1.7.2/trexmodel/models/datastore/message_model_helper.py +566 -0
- trex_model-1.7.2/trexmodel/models/datastore/message_models.py +176 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/model_decorators.py +2 -2
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/ndb_models.py +196 -50
- trex_model-1.7.2/trexmodel/models/datastore/partnership_models.py +444 -0
- trex_model-1.7.2/trexmodel/models/datastore/pos_models.py +692 -0
- trex_model-1.7.2/trexmodel/models/datastore/prepaid_models.py +673 -0
- trex_model-1.7.2/trexmodel/models/datastore/product_models.py +890 -0
- trex_model-1.7.2/trexmodel/models/datastore/program_models.py +1241 -0
- trex_model-1.7.2/trexmodel/models/datastore/rating_models.py +973 -0
- trex_model-1.7.2/trexmodel/models/datastore/recruit_models.py +45 -0
- trex_model-1.7.2/trexmodel/models/datastore/redeem_models.py +803 -0
- trex_model-1.7.2/trexmodel/models/datastore/redemption_catalogue_models.py +460 -0
- trex_model-1.7.2/trexmodel/models/datastore/referral_program_model.py +372 -0
- trex_model-1.7.2/trexmodel/models/datastore/reward_models.py +967 -0
- trex_model-1.7.2/trexmodel/models/datastore/support_models.py +32 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/system_models.py +75 -3
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/task_models.py +1 -2
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/test_models.py +1 -11
- trex_model-1.7.2/trexmodel/models/datastore/transaction_models.py +748 -0
- trex_model-1.7.2/trexmodel/models/datastore/user_models.py +576 -0
- trex_model-1.7.2/trexmodel/models/datastore/voucher_models.py +409 -0
- trex_model-1.7.2/trexmodel/models/merchant_helpers.py +475 -0
- trex_model-1.7.2/trexmodel/models/prepaid_helpers.py +11 -0
- trex_model-1.7.2/trexmodel/pos_conf.py +10 -0
- trex_model-1.7.2/trexmodel/program_conf.py +619 -0
- trex_model-1.7.2/trexmodel/utils/model/__init__.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/utils/model/model_util.py +6 -2
- trex-model-0.1.47/PKG-INFO +0 -15
- trex-model-0.1.47/trex_model.egg-info/PKG-INFO +0 -15
- trex-model-0.1.47/trex_model.egg-info/requires.txt +0 -7
- trex-model-0.1.47/trexmodel/conf.py +0 -28
- trex-model-0.1.47/trexmodel/models/datastore/analytic_models.py +0 -44
- trex-model-0.1.47/trexmodel/models/datastore/customer_model_helpers.py +0 -148
- trex-model-0.1.47/trexmodel/models/datastore/customer_models.py +0 -302
- trex-model-0.1.47/trexmodel/models/datastore/merchant_models.py +0 -829
- trex-model-0.1.47/trexmodel/models/datastore/product_models.py +0 -286
- trex-model-0.1.47/trexmodel/models/datastore/program_models.py +0 -588
- trex-model-0.1.47/trexmodel/models/datastore/redeem_models.py +0 -423
- trex-model-0.1.47/trexmodel/models/datastore/reward_models.py +0 -407
- trex-model-0.1.47/trexmodel/models/datastore/transaction_models.py +0 -390
- trex-model-0.1.47/trexmodel/models/datastore/user_models.py +0 -305
- trex-model-0.1.47/trexmodel/models/datastore/voucher_models.py +0 -201
- trex-model-0.1.47/trexmodel/program_conf.py +0 -187
- {trex-model-0.1.47 → trex_model-1.7.2}/MANIFEST.in +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/README.md +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/setup.cfg +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/__init__.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/__init__.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-0.1.47/trexmodel/utils → trex_model-1.7.2/trexmodel/models/datastore/helper}/__init__.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-0.1.47/trexmodel/utils/gcloud → trex_model-1.7.2/trexmodel/utils}/__init__.py +0 -0
- {trex-model-0.1.47/trexmodel/utils/model → trex_model-1.7.2/trexmodel/utils/gcloud}/__init__.py +0 -0
- {trex-model-0.1.47 → trex_model-1.7.2}/trexmodel/utils/gcloud/datastore_util.py +0 -0
trex_model-1.7.2/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trex_model
|
|
3
|
+
Version: 1.7.2
|
|
4
|
+
Summary: TRex database module package
|
|
5
|
+
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
|
+
Author: Jack Lok
|
|
7
|
+
Author-email: sglok77@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
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
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: summary
|
|
28
|
+
|
|
29
|
+
This is database modelusing google datastore mode module
|
|
@@ -2,8 +2,8 @@ import setuptools
|
|
|
2
2
|
with open("README.md", "r") as fh:
|
|
3
3
|
long_description = fh.read()
|
|
4
4
|
setuptools.setup(
|
|
5
|
-
name='
|
|
6
|
-
version='
|
|
5
|
+
name='trex_model',
|
|
6
|
+
version='1.7.2',
|
|
7
7
|
author="Jack Lok",
|
|
8
8
|
author_email="sglok77@gmail.com",
|
|
9
9
|
description="TRex database module package",
|
|
@@ -19,12 +19,13 @@ setuptools.setup(
|
|
|
19
19
|
include_package_data = True,
|
|
20
20
|
install_requires=[
|
|
21
21
|
'google-cloud-firestore',
|
|
22
|
-
'google_cloud_datastore
|
|
22
|
+
'google_cloud_datastore',
|
|
23
23
|
'google-cloud-ndb',
|
|
24
24
|
'six',
|
|
25
25
|
'trex-lib',
|
|
26
|
-
'flask-login',
|
|
27
|
-
'
|
|
26
|
+
'flask-login==0.6.2',
|
|
27
|
+
#'ordered-set==4.1.0',
|
|
28
|
+
|
|
28
29
|
]
|
|
29
30
|
)
|
|
30
31
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trex_model
|
|
3
|
+
Version: 1.7.2
|
|
4
|
+
Summary: TRex database module package
|
|
5
|
+
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
|
+
Author: Jack Lok
|
|
7
|
+
Author-email: sglok77@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
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
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: summary
|
|
28
|
+
|
|
29
|
+
This is database modelusing google datastore mode module
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
LICENSE
|
|
1
2
|
MANIFEST.in
|
|
2
3
|
README.md
|
|
3
4
|
setup.cfg
|
|
@@ -9,32 +10,57 @@ trex_model.egg-info/requires.txt
|
|
|
9
10
|
trex_model.egg-info/top_level.txt
|
|
10
11
|
trexmodel/__init__.py
|
|
11
12
|
trexmodel/conf.py
|
|
13
|
+
trexmodel/pos_conf.py
|
|
12
14
|
trexmodel/program_conf.py
|
|
13
15
|
trexmodel/models/__init__.py
|
|
16
|
+
trexmodel/models/merchant_helpers.py
|
|
14
17
|
trexmodel/models/model_decorator.py
|
|
18
|
+
trexmodel/models/prepaid_helpers.py
|
|
15
19
|
trexmodel/models/datastore/__init__.py
|
|
16
20
|
trexmodel/models/datastore/admin_models.py
|
|
17
21
|
trexmodel/models/datastore/analytic_models.py
|
|
22
|
+
trexmodel/models/datastore/app_models.py
|
|
18
23
|
trexmodel/models/datastore/coporate_models.py
|
|
19
24
|
trexmodel/models/datastore/customer_model_helpers.py
|
|
20
25
|
trexmodel/models/datastore/customer_models.py
|
|
26
|
+
trexmodel/models/datastore/fan_club_models.py
|
|
21
27
|
trexmodel/models/datastore/fb_subsriber_models.py
|
|
28
|
+
trexmodel/models/datastore/import_models.py
|
|
22
29
|
trexmodel/models/datastore/inventory_model.py
|
|
30
|
+
trexmodel/models/datastore/loyalty_models.py
|
|
31
|
+
trexmodel/models/datastore/lucky_draw_models.py
|
|
32
|
+
trexmodel/models/datastore/marketing_models.py
|
|
23
33
|
trexmodel/models/datastore/membership_models.py
|
|
24
34
|
trexmodel/models/datastore/merchant_models.py
|
|
35
|
+
trexmodel/models/datastore/merchant_promotion_models.py
|
|
36
|
+
trexmodel/models/datastore/message_model_helper.py
|
|
37
|
+
trexmodel/models/datastore/message_models.py
|
|
25
38
|
trexmodel/models/datastore/model_decorators.py
|
|
26
39
|
trexmodel/models/datastore/ndb_models.py
|
|
40
|
+
trexmodel/models/datastore/partnership_models.py
|
|
41
|
+
trexmodel/models/datastore/pos_models.py
|
|
42
|
+
trexmodel/models/datastore/prepaid_models.py
|
|
27
43
|
trexmodel/models/datastore/product_models.py
|
|
28
44
|
trexmodel/models/datastore/program_models.py
|
|
45
|
+
trexmodel/models/datastore/rating_models.py
|
|
46
|
+
trexmodel/models/datastore/recruit_models.py
|
|
29
47
|
trexmodel/models/datastore/redeem_models.py
|
|
48
|
+
trexmodel/models/datastore/redemption_catalogue_models.py
|
|
49
|
+
trexmodel/models/datastore/referral_program_model.py
|
|
30
50
|
trexmodel/models/datastore/reward_models.py
|
|
31
51
|
trexmodel/models/datastore/spending_base_program_model.py
|
|
52
|
+
trexmodel/models/datastore/support_models.py
|
|
32
53
|
trexmodel/models/datastore/system_models.py
|
|
33
54
|
trexmodel/models/datastore/task_models.py
|
|
34
55
|
trexmodel/models/datastore/test_models.py
|
|
35
56
|
trexmodel/models/datastore/transaction_models.py
|
|
36
57
|
trexmodel/models/datastore/user_models.py
|
|
37
58
|
trexmodel/models/datastore/voucher_models.py
|
|
59
|
+
trexmodel/models/datastore/helper/__init__.py
|
|
60
|
+
trexmodel/models/datastore/helper/membership_helpers.py
|
|
61
|
+
trexmodel/models/datastore/helper/reward_model_helpers.py
|
|
62
|
+
trexmodel/models/datastore/helper/reward_transaction_helper.py
|
|
63
|
+
trexmodel/models/datastore/helper/sales_transaction_helpers.py
|
|
38
64
|
trexmodel/utils/__init__.py
|
|
39
65
|
trexmodel/utils/gcloud/__init__.py
|
|
40
66
|
trexmodel/utils/gcloud/datastore_util.py
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import os, config_path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
INTERNAL_MAX_FETCH_RECORD = 9999
|
|
5
|
+
MAX_FETCH_RECORD_FULL_TEXT_SEARCH = 1000
|
|
6
|
+
MAX_FETCH_RECORD_FULL_TEXT_SEARCH_PER_PAGE = 10
|
|
7
|
+
MAX_FETCH_RECORD = 99999999
|
|
8
|
+
MAX_FETCH_IMAGE_RECORD = 100
|
|
9
|
+
MAX_CHAR_RANDOM_UUID4 = 20
|
|
10
|
+
PAGINATION_SIZE = 10
|
|
11
|
+
VISIBLE_PAGE_COUNT = 10
|
|
12
|
+
|
|
13
|
+
DEFAULT_GMT_HOURS = 8
|
|
14
|
+
|
|
15
|
+
GENDER_MALE_CODE = 'm'
|
|
16
|
+
GENDER_FEMALE_CODE = 'f'
|
|
17
|
+
GENDER_UNKNOWN_CODE = 'u'
|
|
18
|
+
|
|
19
|
+
APPLICATION_ACCOUNT_PROVIDER = 'app'
|
|
20
|
+
|
|
21
|
+
MODEL_PROJECT_ID = os.environ['GCLOUD_PROJECT_ID']
|
|
22
|
+
|
|
23
|
+
DATASTORE_SERVICE_ACCOUNT_KEY_FILEPATH = os.environ['SERVICE_ACCOUNT_KEY']
|
|
24
|
+
|
|
25
|
+
ACCOUNT_LOCKED_IN_MINUTES = os.environ['ACCOUNT_LOCKED_IN_MINUTES']
|
|
26
|
+
|
|
27
|
+
DATASTORE_CREDENTIAL_PATH = os.path.abspath(os.path.dirname(config_path.__file__)) + '/' + DATASTORE_SERVICE_ACCOUNT_KEY_FILEPATH
|
|
28
|
+
|
|
29
|
+
MERCHANT_STAT_FIGURE_UPDATE_INTERVAL_IN_MINUTES = os.environ.get('MERCHANT_STAT_FIGURE_UPDATE_INTERVAL_IN_MINUTES') or 60
|
|
30
|
+
|
|
31
|
+
MESSAGE_CATEGORY_ANNOUNCEMENT = 'announcement'
|
|
32
|
+
MESSAGE_CATEGORY_ALERT = 'alert'
|
|
33
|
+
MESSAGE_CATEGORY_PROMOTION = 'promotion'
|
|
34
|
+
MESSAGE_CATEGORY_SURVEY = 'survey'
|
|
35
|
+
MESSAGE_CATEGORY_SYSTEM = 'system'
|
|
36
|
+
MESSAGE_CATEGORY_REWARD = 'reward'
|
|
37
|
+
MESSAGE_CATEGORY_REFERRAL = 'referral'
|
|
38
|
+
MESSAGE_CATEGORY_BIRTHDAY = 'birthday'
|
|
39
|
+
MESSAGE_CATEGORY_REDEEM = 'redeem'
|
|
40
|
+
MESSAGE_CATEGORY_PAYMENT = 'payment'
|
|
41
|
+
MESSAGE_CATEGORY_REDEMPTION_CATALOGUE = 'redemption_catalogue'
|
|
42
|
+
|
|
43
|
+
MESSAGE_CATEGORIES = (
|
|
44
|
+
MESSAGE_CATEGORY_ANNOUNCEMENT,
|
|
45
|
+
MESSAGE_CATEGORY_ALERT,
|
|
46
|
+
MESSAGE_CATEGORY_PROMOTION,
|
|
47
|
+
MESSAGE_CATEGORY_SURVEY,
|
|
48
|
+
MESSAGE_CATEGORY_SYSTEM,
|
|
49
|
+
MESSAGE_CATEGORY_REWARD,
|
|
50
|
+
MESSAGE_CATEGORY_REDEEM,
|
|
51
|
+
MESSAGE_CATEGORY_REDEMPTION_CATALOGUE,
|
|
52
|
+
MESSAGE_CATEGORY_PAYMENT,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
MESSAGE_STATUS_NEW = 'n'
|
|
56
|
+
MESSAGE_STATUS_READ = 'r'
|
|
57
|
+
|
|
58
|
+
USER_STATUS_ANONYMOUS = 'anonymous'
|
|
59
|
+
USER_STATUS_REGISTERED = 'registered'
|
|
60
|
+
USER_STATUS_ENTER_BIODATA = 'enterBiodata'
|
|
61
|
+
USER_STATUS_COMPLETED = 'completedRegistration'
|
|
62
|
+
|
|
63
|
+
USER_STATUS_SET = (USER_STATUS_REGISTERED, USER_STATUS_ENTER_BIODATA, USER_STATUS_COMPLETED)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
MESSAGE_STATUS_SET = (MESSAGE_STATUS_NEW, MESSAGE_STATUS_READ)
|
|
67
|
+
|
|
68
|
+
PREPAID_REDEEM_URL = os.environ['PREPAID_REDEEM_URL']
|
|
69
|
+
|
|
@@ -6,6 +6,10 @@ Created on 8 May 2020
|
|
|
6
6
|
from google.cloud import ndb
|
|
7
7
|
from trexmodel.models.datastore.user_models import UserMin
|
|
8
8
|
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
9
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
10
|
+
from trexlib.utils.string_util import random_string
|
|
11
|
+
from trexlib.utils.common.common_util import logger
|
|
12
|
+
from trexconf import conf
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
class SuperUser(UserMin):
|
|
@@ -78,4 +82,56 @@ class AdminUser(SuperUser):
|
|
|
78
82
|
admin_user.is_superuser = is_superuser
|
|
79
83
|
admin_user.permission = {'granted_access': permission}
|
|
80
84
|
admin_user.put()
|
|
85
|
+
|
|
86
|
+
class AppBannerFile(BaseNModel, DictModel):
|
|
87
|
+
banner_file_type = ndb.StringProperty(required=True)
|
|
88
|
+
banner_file_public_url = ndb.StringProperty(required=True)
|
|
89
|
+
banner_file_storage_filename = ndb.StringProperty(required=True)
|
|
90
|
+
sequence = ndb.IntegerProperty(required=False, default=0)
|
|
91
|
+
|
|
92
|
+
dict_properties = ['banner_file_public_url', 'banner_file_storage_filename', 'banner_file_type', 'sequence']
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def list():
|
|
96
|
+
result = AppBannerFile.query().fetch(limit=conf.MAX_FETCH_RECORD)
|
|
97
|
+
return result
|
|
98
|
+
|
|
99
|
+
@staticmethod
|
|
100
|
+
def upload_file(uploading_file, bucket, banner_file_type=None):
|
|
101
|
+
file_prefix = random_string(8)
|
|
102
|
+
banner_file_storage_filename = 'app/banner/'+file_prefix+'-'+uploading_file.filename
|
|
103
|
+
blob = bucket.blob(banner_file_storage_filename)
|
|
104
|
+
|
|
105
|
+
logger.debug('banner_file_storage_filename=%s', banner_file_storage_filename)
|
|
106
|
+
|
|
107
|
+
blob.upload_from_string(
|
|
108
|
+
uploading_file.read(),
|
|
109
|
+
content_type=uploading_file.content_type
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
uploaded_url = blob.public_url
|
|
113
|
+
|
|
114
|
+
logger.debug('banner_file_type=%s', uploaded_url)
|
|
115
|
+
logger.debug('product_file_type=%s', banner_file_type)
|
|
116
|
+
|
|
117
|
+
count = AppBannerFile.query().count()
|
|
118
|
+
|
|
119
|
+
banner_file = AppBannerFile(
|
|
120
|
+
banner_file_public_url = uploaded_url,
|
|
121
|
+
banner_file_storage_filename = banner_file_storage_filename,
|
|
122
|
+
banner_file_type = banner_file_type,
|
|
123
|
+
sequence = count+1,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
banner_file.put()
|
|
127
|
+
|
|
128
|
+
return banner_file
|
|
129
|
+
|
|
130
|
+
@staticmethod
|
|
131
|
+
def remove_file(banner_file, bucket):
|
|
132
|
+
|
|
133
|
+
old_logo_blob = bucket.get_blob(banner_file.banner_file_storage_filename)
|
|
134
|
+
if old_logo_blob:
|
|
135
|
+
old_logo_blob.delete()
|
|
136
|
+
banner_file.delete()
|
|
81
137
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Created on 25 Jan 2021
|
|
3
|
+
|
|
4
|
+
@author: jacklok
|
|
5
|
+
'''
|
|
6
|
+
from trexconf import conf as model_conf
|
|
7
|
+
from google.cloud import ndb
|
|
8
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
+
from datetime import timedelta
|
|
10
|
+
from trexmodel.models.datastore.merchant_models import MerchantAcct
|
|
11
|
+
|
|
12
|
+
class UpstreamData(BaseNModel, DictModel):
|
|
13
|
+
merchant_acct = ndb.KeyProperty(name="merchant_acct", kind=MerchantAcct)
|
|
14
|
+
table_template_name = ndb.StringProperty(required=True)
|
|
15
|
+
dataset_name = ndb.StringProperty(required=True)
|
|
16
|
+
table_name = ndb.StringProperty(required=True)
|
|
17
|
+
stream_content = ndb.JsonProperty(required=True)
|
|
18
|
+
is_sent = ndb.BooleanProperty(required=True, default=False)
|
|
19
|
+
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
20
|
+
partition_datetime = ndb.DateTimeProperty(required=False)
|
|
21
|
+
|
|
22
|
+
dict_properties = ['table_template_name', 'dataset_name', 'table_name', 'stream_content', 'is_sent', 'partition_datetime']
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def list_not_send(offset=0, limit=model_conf.MAX_FETCH_RECORD, start_cursor=None,return_with_cursor=False, keys_only=False):
|
|
26
|
+
query = UpstreamData.query(ndb.AND(UpstreamData.is_sent==False))
|
|
27
|
+
|
|
28
|
+
return UpstreamData.list_all_with_condition_query(query, offset=offset, start_cursor=start_cursor, return_with_cursor=return_with_cursor, keys_only=keys_only, limit=limit)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def list_all(offset=0, limit=model_conf.MAX_FETCH_RECORD, start_cursor=None,return_with_cursor=False, keys_only=False):
|
|
33
|
+
query = UpstreamData.query()
|
|
34
|
+
|
|
35
|
+
return UpstreamData.list_all_with_condition_query(query, offset=offset, start_cursor=start_cursor, return_with_cursor=return_with_cursor, keys_only=keys_only, limit=limit)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def list_by_date_range(datetime_start, datetime_end, offset=0, limit=model_conf.MAX_FETCH_RECORD, start_cursor=None,return_with_cursor=False, keys_only=False):
|
|
39
|
+
|
|
40
|
+
datetime_end = datetime_end + timedelta(days=1)
|
|
41
|
+
query = UpstreamData.query(ndb.AND(
|
|
42
|
+
UpstreamData.created_datetime>=datetime_start,
|
|
43
|
+
UpstreamData.created_datetime<datetime_end,
|
|
44
|
+
))
|
|
45
|
+
|
|
46
|
+
return UpstreamData.list_all_with_condition_query(query, offset=offset, start_cursor=start_cursor, return_with_cursor=return_with_cursor, keys_only=keys_only, limit=limit)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def count_not_sent(limit=model_conf.MAX_FETCH_RECORD):
|
|
51
|
+
return UpstreamData.query(ndb.AND(UpstreamData.is_sent==False)).count(limit = limit)
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def count_all(limit=model_conf.MAX_FETCH_RECORD):
|
|
55
|
+
return UpstreamData.query().count(limit = limit)
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def count_by_date_range(datetime_start, datetime_end, limit=model_conf.MAX_FETCH_RECORD):
|
|
59
|
+
datetime_end = datetime_end + timedelta(days=1)
|
|
60
|
+
|
|
61
|
+
return UpstreamData.query(ndb.AND(
|
|
62
|
+
UpstreamData.created_datetime>=datetime_start,
|
|
63
|
+
UpstreamData.created_datetime<datetime_end,
|
|
64
|
+
)).count(limit = limit)
|
|
65
|
+
|
|
66
|
+
@staticmethod
|
|
67
|
+
def create(merchant_acct, dataset_name, table_name, table_template_name, stream_content, partition_datetime=None):
|
|
68
|
+
UpstreamData(
|
|
69
|
+
merchant_acct = merchant_acct.create_ndb_key(),
|
|
70
|
+
table_template_name = table_template_name,
|
|
71
|
+
dataset_name = dataset_name,
|
|
72
|
+
table_name = table_name,
|
|
73
|
+
stream_content = stream_content,
|
|
74
|
+
partition_datetime = partition_datetime,
|
|
75
|
+
).put()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Created on 23 May 2023
|
|
3
|
+
|
|
4
|
+
@author: jacklok
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
+
from google.cloud import ndb
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
import trexmodel.conf as model_conf
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger('model')
|
|
14
|
+
|
|
15
|
+
class AppMessageBase(BaseNModel, DictModel):
|
|
16
|
+
title = ndb.StringProperty(required=True)
|
|
17
|
+
content = ndb.StringProperty(required=False)
|
|
18
|
+
start_date = ndb.DateProperty(required=True)
|
|
19
|
+
end_date = ndb.DateProperty(required=True)
|
|
20
|
+
archived = ndb.BooleanProperty(default=False)
|
|
21
|
+
|
|
22
|
+
created_datetime = ndb.DateTimeProperty(required=True, auto_now_add=True)
|
|
23
|
+
modified_datetime = ndb.DateTimeProperty(required=True, auto_now=True)
|
|
24
|
+
archived_datetime = ndb.DateTimeProperty(required=False)
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def create(cls, title, content=None, start_date=None, end_date=None):
|
|
28
|
+
message = cls(
|
|
29
|
+
title = title,
|
|
30
|
+
content = content,
|
|
31
|
+
start_date = start_date,
|
|
32
|
+
end_date = end_date,
|
|
33
|
+
)
|
|
34
|
+
message.put()
|
|
35
|
+
return message
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def update(cls, message, title=None, content=None, start_date=None, end_date=None):
|
|
39
|
+
message.title = title
|
|
40
|
+
message.content = content
|
|
41
|
+
message.start_date = start_date
|
|
42
|
+
message.end_date = end_date
|
|
43
|
+
message.put()
|
|
44
|
+
|
|
45
|
+
def archive(self):
|
|
46
|
+
self.archived = True
|
|
47
|
+
self.archived_datetime = datetime.now()
|
|
48
|
+
self.put()
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def list(cls, is_archived=False):
|
|
52
|
+
return cls.query(ndb.AND(cls.archived == is_archived)).fetch(limit=model_conf.MAX_FETCH_RECORD)
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def list_active(cls):
|
|
56
|
+
now = datetime.now().date()
|
|
57
|
+
return cls.query(ndb.AND(cls.archived == False, cls.start_date>=now, cls.end_date<now)).fetch(limit=model_conf.MAX_FETCH_RECORD)
|
|
58
|
+
|
|
59
|
+
class AppMessage(AppMessageBase):
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class AppPromotion(AppMessageBase):
|
|
64
|
+
image_file_type = ndb.StringProperty(required=False)
|
|
65
|
+
image_file_public_url = ndb.StringProperty(required=False)
|
|
66
|
+
image_file_storage_filename = ndb.StringProperty(required=False)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
@@ -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')
|