trex-model 1.5.0__tar.gz → 1.5.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.

Files changed (61) hide show
  1. {trex-model-1.5.0 → trex-model-1.5.2}/PKG-INFO +1 -1
  2. {trex-model-1.5.0 → trex-model-1.5.2}/setup.py +1 -1
  3. {trex-model-1.5.0 → trex-model-1.5.2}/trex_model.egg-info/PKG-INFO +1 -1
  4. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/redemption_catalogue_models.py +11 -1
  5. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/user_models.py +1 -0
  6. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/merchant_helpers.py +55 -17
  7. {trex-model-1.5.0 → trex-model-1.5.2}/LICENSE +0 -0
  8. {trex-model-1.5.0 → trex-model-1.5.2}/MANIFEST.in +0 -0
  9. {trex-model-1.5.0 → trex-model-1.5.2}/README.md +0 -0
  10. {trex-model-1.5.0 → trex-model-1.5.2}/setup.cfg +0 -0
  11. {trex-model-1.5.0 → trex-model-1.5.2}/trex_model.egg-info/SOURCES.txt +0 -0
  12. {trex-model-1.5.0 → trex-model-1.5.2}/trex_model.egg-info/dependency_links.txt +0 -0
  13. {trex-model-1.5.0 → trex-model-1.5.2}/trex_model.egg-info/requires.txt +0 -0
  14. {trex-model-1.5.0 → trex-model-1.5.2}/trex_model.egg-info/top_level.txt +0 -0
  15. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/__init__.py +0 -0
  16. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/conf.py +0 -0
  17. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/__init__.py +0 -0
  18. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/__init__.py +0 -0
  19. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/admin_models.py +0 -0
  20. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/analytic_models.py +0 -0
  21. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/app_models.py +0 -0
  22. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/coporate_models.py +0 -0
  23. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
  24. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/customer_models.py +0 -0
  25. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
  26. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/import_models.py +0 -0
  27. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/inventory_model.py +0 -0
  28. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/loyalty_models.py +0 -0
  29. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
  30. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/marketing_models.py +0 -0
  31. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/membership_models.py +0 -0
  32. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/merchant_models.py +0 -0
  33. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/message_model_helper.py +0 -0
  34. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/message_models.py +0 -0
  35. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/model_decorators.py +0 -0
  36. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/ndb_models.py +0 -0
  37. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/pos_models.py +0 -0
  38. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/prepaid_models.py +0 -0
  39. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/product_models.py +0 -0
  40. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/program_models.py +0 -0
  41. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/rating_models.py +0 -0
  42. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/recruit_models.py +0 -0
  43. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/redeem_models.py +0 -0
  44. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/referral_program_model.py +0 -0
  45. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/reward_model_helpers.py +0 -0
  46. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/reward_models.py +0 -0
  47. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
  48. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/system_models.py +0 -0
  49. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/task_models.py +0 -0
  50. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/test_models.py +0 -0
  51. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/transaction_models.py +0 -0
  52. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/datastore/voucher_models.py +0 -0
  53. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/model_decorator.py +0 -0
  54. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/models/prepaid_helpers.py +0 -0
  55. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/pos_conf.py +0 -0
  56. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/program_conf.py +0 -0
  57. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/utils/__init__.py +0 -0
  58. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/utils/gcloud/__init__.py +0 -0
  59. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/utils/gcloud/datastore_util.py +0 -0
  60. {trex-model-1.5.0 → trex-model-1.5.2}/trexmodel/utils/model/__init__.py +0 -0
  61. {trex-model-1.5.0 → trex-model-1.5.2}/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.0
3
+ Version: 1.5.2
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.0',
6
+ version='1.5.2',
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.0
3
+ Version: 1.5.2
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
@@ -515,6 +515,7 @@ class DeletedUser(User):
515
515
  birth_date_date_str = user.birth_date_date_str,
516
516
  birth_day_in_year = user.birth_day_in_year,
517
517
  reference_code = user.reference_code,
518
+ referral_code = user.referral_code,
518
519
  active = False,
519
520
  )
520
521
 
@@ -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,7 @@ 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,
75
72
  }
76
73
  if is_not_empty(referral_program_settings):
77
74
 
@@ -88,6 +85,47 @@ def construct_merchant_acct_info(merchant_acct):
88
85
 
89
86
  return info
90
87
 
88
+ def __check_is_still_active(catalogue):
89
+ today = datetime.utcnow().date()
90
+ start_date = datetime.strptime(catalogue.get('start_date'), '%d-%m-%Y').date()
91
+ end_date = datetime.strptime(catalogue.get('end_date'), '%d-%m-%Y').date()
92
+
93
+ if today>=start_date and today<=end_date:
94
+ logger.info('catalogue is still valid')
95
+ return True
96
+ else:
97
+ logger.info('catalogue is expired')
98
+ return False
99
+
100
+ def __resolve_catalogue_items_details(catalogue_items_list, vouchers_list):
101
+ resolved_items_list = []
102
+ voucher_dict = __convert_vouchers_list_to_dict(vouchers_list)
103
+ for item in catalogue_items_list:
104
+ voucher = voucher_dict.get(item.get('voucher_key'))
105
+ if voucher:
106
+ resolved_items_list.append(
107
+ {
108
+ 'voucher_key' : item.get('voucher_key'),
109
+ 'amount' : item.get('voucher_amount'),
110
+ 'label' : voucher.get('label'),
111
+ 'image_url' : voucher.get('image_url'),
112
+ 'terms_and_conditions' : voucher.get('terms_and_conditions'),
113
+ 'redeem_reward_amount' : item.get('redeem_reward_amount'),
114
+ }
115
+
116
+ )
117
+ else:
118
+ resolved_items_list.append(item)
119
+
120
+ return resolved_items_list
121
+
122
+ def __convert_vouchers_list_to_dict(vouchers_list):
123
+ voucher_dict = {}
124
+ for voucher in vouchers_list:
125
+ voucher_dict[voucher.get('voucher_key')] = voucher
126
+
127
+ return voucher_dict
128
+
91
129
  def construct_outlet_info(outlet):
92
130
  geo_location = None
93
131
  if outlet.geo_location:
File without changes
File without changes
File without changes
File without changes
File without changes