trex-model 1.5.1__tar.gz → 1.5.3__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.

Files changed (61) hide show
  1. {trex-model-1.5.1 → trex-model-1.5.3}/PKG-INFO +1 -1
  2. {trex-model-1.5.1 → trex-model-1.5.3}/setup.py +1 -1
  3. {trex-model-1.5.1 → trex-model-1.5.3}/trex_model.egg-info/PKG-INFO +1 -1
  4. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/redemption_catalogue_models.py +11 -1
  5. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/merchant_helpers.py +57 -17
  6. {trex-model-1.5.1 → trex-model-1.5.3}/LICENSE +0 -0
  7. {trex-model-1.5.1 → trex-model-1.5.3}/MANIFEST.in +0 -0
  8. {trex-model-1.5.1 → trex-model-1.5.3}/README.md +0 -0
  9. {trex-model-1.5.1 → trex-model-1.5.3}/setup.cfg +0 -0
  10. {trex-model-1.5.1 → trex-model-1.5.3}/trex_model.egg-info/SOURCES.txt +0 -0
  11. {trex-model-1.5.1 → trex-model-1.5.3}/trex_model.egg-info/dependency_links.txt +0 -0
  12. {trex-model-1.5.1 → trex-model-1.5.3}/trex_model.egg-info/requires.txt +0 -0
  13. {trex-model-1.5.1 → trex-model-1.5.3}/trex_model.egg-info/top_level.txt +0 -0
  14. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/__init__.py +0 -0
  15. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/conf.py +0 -0
  16. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/__init__.py +0 -0
  17. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/__init__.py +0 -0
  18. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/admin_models.py +0 -0
  19. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/analytic_models.py +0 -0
  20. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/app_models.py +0 -0
  21. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/coporate_models.py +0 -0
  22. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
  23. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/customer_models.py +0 -0
  24. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
  25. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/import_models.py +0 -0
  26. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/inventory_model.py +0 -0
  27. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/loyalty_models.py +0 -0
  28. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
  29. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/marketing_models.py +0 -0
  30. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/membership_models.py +0 -0
  31. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/merchant_models.py +0 -0
  32. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/message_model_helper.py +0 -0
  33. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/message_models.py +0 -0
  34. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/model_decorators.py +0 -0
  35. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/ndb_models.py +0 -0
  36. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/pos_models.py +0 -0
  37. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/prepaid_models.py +0 -0
  38. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/product_models.py +0 -0
  39. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/program_models.py +0 -0
  40. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/rating_models.py +0 -0
  41. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/recruit_models.py +0 -0
  42. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/redeem_models.py +0 -0
  43. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/referral_program_model.py +0 -0
  44. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/reward_model_helpers.py +0 -0
  45. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/reward_models.py +0 -0
  46. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
  47. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/system_models.py +0 -0
  48. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/task_models.py +0 -0
  49. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/test_models.py +0 -0
  50. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/transaction_models.py +0 -0
  51. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/user_models.py +0 -0
  52. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/datastore/voucher_models.py +0 -0
  53. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/model_decorator.py +0 -0
  54. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/models/prepaid_helpers.py +0 -0
  55. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/pos_conf.py +0 -0
  56. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/program_conf.py +0 -0
  57. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/utils/__init__.py +0 -0
  58. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/utils/gcloud/__init__.py +0 -0
  59. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/utils/gcloud/datastore_util.py +0 -0
  60. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/utils/model/__init__.py +0 -0
  61. {trex-model-1.5.1 → trex-model-1.5.3}/trexmodel/utils/model/model_util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trex-model
3
- Version: 1.5.1
3
+ Version: 1.5.3
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -3,7 +3,7 @@ with open("README.md", "r") as fh:
3
3
  long_description = fh.read()
4
4
  setuptools.setup(
5
5
  name='trex-model',
6
- version='1.5.1',
6
+ version='1.5.3',
7
7
  author="Jack Lok",
8
8
  author_email="sglok77@gmail.com",
9
9
  description="TRex database module package",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trex-model
3
- Version: 1.5.1
3
+ Version: 1.5.3
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -76,16 +76,22 @@ class RedemptionCatalogue(BaseNModel, DictModel):
76
76
  def exclusive_tags_list(self):
77
77
  if self.catalogue_settings.get('exclusivity') and self.catalogue_settings.get('exclusivity').get('tags'):
78
78
  return self.catalogue_settings.get('exclusivity').get('tags') or []
79
+ else:
80
+ return []
79
81
 
80
82
  @property
81
83
  def exclusive_memberships_list(self):
82
84
  if self.catalogue_settings.get('exclusivity') and self.catalogue_settings.get('exclusivity').get('memberships'):
83
85
  return self.catalogue_settings.get('exclusivity').get('memberships') or []
86
+ else:
87
+ return []
84
88
 
85
89
  @property
86
90
  def exclusive_tier_memberships_list(self):
87
91
  if self.catalogue_settings.get('exclusivity') and self.catalogue_settings.get('exclusivity').get('tier_memberships'):
88
92
  return self.catalogue_settings.get('exclusivity').get('tier_memberships') or []
93
+ else:
94
+ return []
89
95
 
90
96
  @property
91
97
  def catalogue_items(self):
@@ -355,7 +361,11 @@ class RedemptionCatalogue(BaseNModel, DictModel):
355
361
  'start_date' : self.start_date.strftime('%d-%m-%Y'),
356
362
  'end_date' : self.end_date.strftime('%d-%m-%Y'),
357
363
  'items' : self.catalogue_settings.get('items'),
358
- 'exclusivity' : self.catalogue_settings.get('exclusivity'),
364
+ 'exclusivity' : {
365
+ 'tags' : self.exclusive_tags_list,
366
+ 'memberships' : self.exclusive_memberships_list,
367
+ 'tier_memberships' : self.exclusive_tier_memberships_list,
368
+ },
359
369
  }
360
370
 
361
371
  return catalogue_configuration
@@ -4,6 +4,10 @@ from trexmodel.models.datastore.merchant_models import ReceiptSetup, Outlet,\
4
4
  BannerFile
5
5
  from trexlib.utils.string_util import is_not_empty
6
6
  from trexconf import conf
7
+ from datetime import datetime
8
+ import logging
9
+
10
+ logger = logging.getLogger('helper')
7
11
 
8
12
  def construct_merchant_acct_info(merchant_acct):
9
13
  account_settings = {
@@ -37,28 +41,20 @@ def construct_merchant_acct_info(merchant_acct):
37
41
 
38
42
 
39
43
 
40
- '''
41
- merchant_news_list = [
42
- {
43
- 'image_url': 'https://scontent.cdninstagram.com/v/t39.30808-6/395358935_817823987014226_84933362912055577_n.jpg?stp=dst-jpg_e35&efg=eyJ2ZW5jb2RlX3RhZyI6ImltYWdlX3VybGdlbi42NTF4NjUwLnNkci5mMzA4MDgifQ&_nc_ht=scontent.cdninstagram.com&_nc_cat=102&_nc_ohc=v_kSSi1t6JgQ7kNvgERj6Vi&edm=APs17CUAAAAA&ccb=7-5&ig_cache_key=MzIyMjUxMzQ0MzI0ODIyMzYzMg%3D%3D.2-ccb7-5&oh=00_AfAUoP1jFeskadyDc4xrwkZb1PuH9t5JSajL6Q5tKAwCew&oe=663DAE72&_nc_sid=10d13b',
44
- 'text':'',
45
- },
46
- {
47
- 'image_url': 'https://scontent.cdninstagram.com/v/t39.30808-6/422867915_881086610687963_4914358090885890823_n.jpg?stp=dst-jpg_e35&efg=eyJ2ZW5jb2RlX3RhZyI6ImltYWdlX3VybGdlbi4xMDAweDEwMDAuc2RyLmYzMDgwOCJ9&_nc_ht=scontent.cdninstagram.com&_nc_cat=111&_nc_ohc=-26XTqUwW_UQ7kNvgGzfHx3&edm=APs17CUAAAAA&ccb=7-5&ig_cache_key=MzI5MDg0MTIxNDU3MjA1Nzk3OA%3D%3D.2-ccb7-5&oh=00_AfC8Mj_E7VFXjv_lXqKRYZujgLyIzSHCIL7zM4-sVgRl_A&oe=663DC772&_nc_sid=10d13b',
48
- 'text':'',
49
- },
50
- {
51
- 'image_url': 'https://scontent.cdninstagram.com/v/t39.30808-6/429531381_18323200675112934_3919053740927881532_n.jpg?stp=dst-jpg_e35&efg=eyJ2ZW5jb2RlX3RhZyI6ImltYWdlX3VybGdlbi4xMDgweDEwODAuc2RyLmYzMDgwOCJ9&_nc_ht=scontent.cdninstagram.com&_nc_cat=106&_nc_ohc=xNmQi508i6sQ7kNvgEEkOg4&edm=APs17CUAAAAA&ccb=7-5&ig_cache_key=MzMxMzI2NDY1NDg3NDQxNDI1Mw%3D%3D.2-ccb7-5&oh=00_AfApkzmZjDGPJB1Vnf49is-ZpqqYYL5nKgmB9jXmDGpUGQ&oe=663FD578&_nc_sid=10d13b',
52
- 'text':'',
53
- }
54
-
55
- ]
56
- '''
57
44
  merchant_news_list=[]
58
45
 
59
46
  if merchant_acct.published_news_configuration:
60
47
  merchant_news_list = merchant_acct.published_news_configuration['news']
61
48
 
49
+ published_redemption_catalogue_configuration = merchant_acct.published_redemption_catalogue_configuration
50
+ catalogues_list = []
51
+ if published_redemption_catalogue_configuration:
52
+ catalogues_list = published_redemption_catalogue_configuration.get('catalogues')
53
+
54
+ if len(catalogues_list)>0:
55
+ for catalogue in catalogues_list:
56
+ catalogue['items'] = __resolve_catalogue_items_details(catalogue.get('items'), merchant_acct.published_voucher_configuration.get('vouchers'))
57
+
62
58
  info = {
63
59
  'key' : merchant_acct.key_in_str,
64
60
  'company_name' : merchant_acct.company_name,
@@ -72,6 +68,9 @@ def construct_merchant_acct_info(merchant_acct):
72
68
  'outlets' : outlet_json_list,
73
69
  'banners' : banner_listing,
74
70
  'merchant_news' : merchant_news_list,
71
+ 'redemption_catalogues' : catalogues_list,
72
+ 'published_voucher_configuration' : merchant_acct.published_voucher_configuration,
73
+
75
74
  }
76
75
  if is_not_empty(referral_program_settings):
77
76
 
@@ -88,6 +87,47 @@ def construct_merchant_acct_info(merchant_acct):
88
87
 
89
88
  return info
90
89
 
90
+ def __check_is_still_active(catalogue):
91
+ today = datetime.utcnow().date()
92
+ start_date = datetime.strptime(catalogue.get('start_date'), '%d-%m-%Y').date()
93
+ end_date = datetime.strptime(catalogue.get('end_date'), '%d-%m-%Y').date()
94
+
95
+ if today>=start_date and today<=end_date:
96
+ logger.info('catalogue is still valid')
97
+ return True
98
+ else:
99
+ logger.info('catalogue is expired')
100
+ return False
101
+
102
+ def __resolve_catalogue_items_details(catalogue_items_list, vouchers_list):
103
+ resolved_items_list = []
104
+ voucher_dict = __convert_vouchers_list_to_dict(vouchers_list)
105
+ for item in catalogue_items_list:
106
+ voucher = voucher_dict.get(item.get('voucher_key'))
107
+ if voucher:
108
+ resolved_items_list.append(
109
+ {
110
+ 'voucher_key' : item.get('voucher_key'),
111
+ 'amount' : item.get('voucher_amount'),
112
+ 'label' : voucher.get('label'),
113
+ 'image_url' : voucher.get('image_url'),
114
+ 'terms_and_conditions' : voucher.get('terms_and_conditions'),
115
+ 'redeem_reward_amount' : item.get('redeem_reward_amount'),
116
+ }
117
+
118
+ )
119
+ else:
120
+ resolved_items_list.append(item)
121
+
122
+ return resolved_items_list
123
+
124
+ def __convert_vouchers_list_to_dict(vouchers_list):
125
+ voucher_dict = {}
126
+ for voucher in vouchers_list:
127
+ voucher_dict[voucher.get('voucher_key')] = voucher
128
+
129
+ return voucher_dict
130
+
91
131
  def construct_outlet_info(outlet):
92
132
  geo_location = None
93
133
  if outlet.geo_location:
File without changes
File without changes
File without changes
File without changes
File without changes