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

Files changed (61) hide show
  1. {trex-model-1.4.6 → trex-model-1.5.0}/PKG-INFO +1 -1
  2. {trex-model-1.4.6 → trex-model-1.5.0}/setup.py +1 -1
  3. {trex-model-1.4.6 → trex-model-1.5.0}/trex_model.egg-info/PKG-INFO +1 -1
  4. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/conf.py +10 -1
  5. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/merchant_models.py +71 -1
  6. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/message_model_helper.py +2 -1
  7. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/program_models.py +100 -7
  8. {trex-model-1.4.6 → trex-model-1.5.0}/LICENSE +0 -0
  9. {trex-model-1.4.6 → trex-model-1.5.0}/MANIFEST.in +0 -0
  10. {trex-model-1.4.6 → trex-model-1.5.0}/README.md +0 -0
  11. {trex-model-1.4.6 → trex-model-1.5.0}/setup.cfg +0 -0
  12. {trex-model-1.4.6 → trex-model-1.5.0}/trex_model.egg-info/SOURCES.txt +0 -0
  13. {trex-model-1.4.6 → trex-model-1.5.0}/trex_model.egg-info/dependency_links.txt +0 -0
  14. {trex-model-1.4.6 → trex-model-1.5.0}/trex_model.egg-info/requires.txt +0 -0
  15. {trex-model-1.4.6 → trex-model-1.5.0}/trex_model.egg-info/top_level.txt +0 -0
  16. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/__init__.py +0 -0
  17. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/__init__.py +0 -0
  18. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/__init__.py +0 -0
  19. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/admin_models.py +0 -0
  20. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/analytic_models.py +0 -0
  21. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/app_models.py +0 -0
  22. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/coporate_models.py +0 -0
  23. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
  24. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/customer_models.py +0 -0
  25. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/fb_subsriber_models.py +0 -0
  26. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/import_models.py +0 -0
  27. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/inventory_model.py +0 -0
  28. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/loyalty_models.py +0 -0
  29. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/lucky_draw_models.py +0 -0
  30. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/marketing_models.py +0 -0
  31. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/membership_models.py +0 -0
  32. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/message_models.py +0 -0
  33. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/model_decorators.py +0 -0
  34. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/ndb_models.py +0 -0
  35. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/pos_models.py +0 -0
  36. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/prepaid_models.py +0 -0
  37. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/product_models.py +0 -0
  38. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/rating_models.py +0 -0
  39. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/recruit_models.py +0 -0
  40. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/redeem_models.py +0 -0
  41. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/redemption_catalogue_models.py +0 -0
  42. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/referral_program_model.py +0 -0
  43. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/reward_model_helpers.py +0 -0
  44. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/reward_models.py +0 -0
  45. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
  46. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/system_models.py +0 -0
  47. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/task_models.py +0 -0
  48. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/test_models.py +0 -0
  49. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/transaction_models.py +0 -0
  50. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/user_models.py +0 -0
  51. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/datastore/voucher_models.py +0 -0
  52. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/merchant_helpers.py +0 -0
  53. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/model_decorator.py +0 -0
  54. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/models/prepaid_helpers.py +0 -0
  55. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/pos_conf.py +0 -0
  56. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/program_conf.py +0 -0
  57. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/utils/__init__.py +0 -0
  58. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/utils/gcloud/__init__.py +0 -0
  59. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/utils/gcloud/datastore_util.py +0 -0
  60. {trex-model-1.4.6 → trex-model-1.5.0}/trexmodel/utils/model/__init__.py +0 -0
  61. {trex-model-1.4.6 → trex-model-1.5.0}/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.4.6
3
+ Version: 1.5.0
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.4.6',
6
+ version='1.5.0',
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.4.6
3
+ Version: 1.5.0
4
4
  Summary: TRex database module package
5
5
  Home-page: https://bitbucket.org/lokjac/trex-model
6
6
  Author: Jack Lok
@@ -37,7 +37,16 @@ MESSAGE_CATEGORY_REWARD = 'reward'
37
37
  MESSAGE_CATEGORY_REDEEM = 'redeem'
38
38
  MESSAGE_CATEGORY_REDEMPTION_CATALOGUE = 'redemption_catalogue'
39
39
 
40
- MESSAGE_CATEGORIES = (MESSAGE_CATEGORY_ANNOUNCEMENT, MESSAGE_CATEGORY_ALERT, MESSAGE_CATEGORY_PROMOTION, MESSAGE_CATEGORY_SURVEY, MESSAGE_CATEGORY_SYSTEM, MESSAGE_CATEGORY_REWARD, MESSAGE_CATEGORY_REDEEM)
40
+ MESSAGE_CATEGORIES = (
41
+ MESSAGE_CATEGORY_ANNOUNCEMENT,
42
+ MESSAGE_CATEGORY_ALERT,
43
+ MESSAGE_CATEGORY_PROMOTION,
44
+ MESSAGE_CATEGORY_SURVEY,
45
+ MESSAGE_CATEGORY_SYSTEM,
46
+ MESSAGE_CATEGORY_REWARD,
47
+ MESSAGE_CATEGORY_REDEEM,
48
+ MESSAGE_CATEGORY_REDEMPTION_CATALOGUE,
49
+ )
41
50
 
42
51
  MESSAGE_STATUS_NEW = 'n'
43
52
  MESSAGE_STATUS_READ = 'r'
@@ -70,6 +70,7 @@ class MerchantAcct(MerchantMin):
70
70
  published_voucher_configuration = ndb.JsonProperty()
71
71
  published_redemption_catalogue_configuration = ndb.JsonProperty()
72
72
  published_news_configuration = ndb.JsonProperty()
73
+ published_tier_program_configuration = ndb.JsonProperty()
73
74
 
74
75
  membership_configuration = ndb.JsonProperty()
75
76
  tier_membership_configuration = ndb.JsonProperty()
@@ -91,7 +92,7 @@ class MerchantAcct(MerchantMin):
91
92
  'office_phone', 'fax_phone', 'email', 'account_code', 'country',
92
93
  'registered_datetime', 'modified_datetime', 'plan_start_date', 'plan_end_date', 'currency_code',
93
94
  'timezone', 'effective_referral_program_count',
94
- 'published_program_configuration', 'published_referral_program_configuration',
95
+ 'published_program_configuration', 'published_tier_program_configuration', 'published_referral_program_configuration',
95
96
  'published_voucher_configuration', 'published_news_configuration', 'membership_configuration',
96
97
  'tier_membership_configuration', 'prepaid_configuration', 'lucky_draw_configuration', 'product_modifier_configuration',
97
98
  'dashboard_stat_figure', 'program_settings', 'is_tier_membership_configured', 'website',
@@ -573,6 +574,32 @@ class MerchantAcct(MerchantMin):
573
574
 
574
575
  self.put()
575
576
 
577
+ def update_published_tier_program(self, program_configuration):
578
+ if is_empty(self.published_tier_program_configuration):
579
+ self.published_program_configuration = {
580
+ 'programs' :[program_configuration],
581
+ 'count' : 1,
582
+ }
583
+
584
+ else:
585
+ self.flush_dirty_program_configuration()
586
+ existing_programs_list = self.published_tier_program_configuration.get('programs')
587
+
588
+ program_key = program_configuration.get('program_key')
589
+ index = 0
590
+ for p in existing_programs_list:
591
+ if p.get('program_key') == program_key:
592
+ existing_programs_list.pop(index)
593
+
594
+ index = index+1
595
+
596
+ existing_programs_list.append(program_configuration)
597
+
598
+ self.published_tier_program_configuration['programs'] = existing_programs_list
599
+ self.published_tier_program_configuration['count'] = len(existing_programs_list)
600
+
601
+ self.put()
602
+
576
603
  def update_published_referral_program(self, program_configuration):
577
604
  if is_empty(self.published_referral_program_configuration):
578
605
  self.published_referral_program_configuration = {
@@ -912,6 +939,49 @@ class MerchantAcct(MerchantMin):
912
939
  self.published_program_configuration['count'] = program_count
913
940
 
914
941
  self.put()
942
+
943
+ def remove_tier_program_from_published_tier_program_configuration(self, program_key_to_remove):
944
+
945
+ logger.debug('remove_tier_program_from_published_tier_program_configuration: program_key_to_remove=%s', program_key_to_remove)
946
+
947
+ #self.flush_dirty_program_configuration()
948
+ if self.published_tier_program_configuration:
949
+ existing_programs_list = self.published_tier_program_configuration['programs']
950
+ program_count = len(existing_programs_list)
951
+
952
+ else:
953
+ self.published_tier_program_configuration = {}
954
+ existing_programs_list = []
955
+ program_count = 0
956
+
957
+
958
+ logger.debug('program_count before remove=%s', program_count)
959
+
960
+ index = 0
961
+
962
+ for program in existing_programs_list:
963
+
964
+ logger.debug('program_key=%s', program.get('program_key'))
965
+
966
+ is_same_program_key = program.get('program_key') == program_key_to_remove
967
+
968
+ logger.debug('is_same_program_key=%s', is_same_program_key)
969
+
970
+ if is_same_program_key:
971
+ existing_programs_list.pop(index)
972
+
973
+ logger.debug('Found program to be remove')
974
+
975
+ index = index+1
976
+
977
+ program_count = len(existing_programs_list)
978
+
979
+ logger.debug('program_count after remove=%s', program_count)
980
+
981
+ self.published_tier_program_configuration['programs'] = existing_programs_list
982
+ self.published_tier_program_configuration['count'] = program_count
983
+
984
+ self.put()
915
985
 
916
986
  def remove_program_from_published_referral_program_configuration(self, program_key_to_remove):
917
987
 
@@ -10,6 +10,7 @@ from trexmodel.conf import MESSAGE_CATEGORY_REWARD, MESSAGE_STATUS_NEW,\
10
10
  from trexconf import program_conf
11
11
  from babel.numbers import format_currency
12
12
  import logging
13
+ from flask_babel import gettext
13
14
 
14
15
 
15
16
  logger = logging.getLogger('helper')
@@ -198,7 +199,7 @@ def create_redeem_catalogue_item_message(customer, entitled_vouchers_summary, re
198
199
  message = Message(
199
200
  parent = user_acct.create_ndb_key(),
200
201
  message_to = user_acct.create_ndb_key(),
201
- title = 'Redemption Catalogue Reward',
202
+ title = gettext('Redemption Catalogue Reward'),
202
203
  message_category = MESSAGE_CATEGORY_REDEMPTION_CATALOGUE,
203
204
  message_content = __create_message_from_redeem_catalogue_transaction(customer, entitled_vouchers_summary),
204
205
  message_data = __create_message_data_from_redemption_catalogue(redemption_catalogue_transaction),
@@ -19,6 +19,26 @@ from trexlib.utils.common.common_util import sort_list, sort_dict_list
19
19
  #logger = logging.getLogger('model')
20
20
  logger = logging.getLogger('debug')
21
21
 
22
+ def create_schedule_program(merchant_acct, program):
23
+ if program.reward_base in (program_conf.SCHEDULE_BASED_PROGRAM):
24
+
25
+ if program.reward_base == program_conf.REWARD_BASE_ON_BIRTHDAY:
26
+ if program.giveaway_reward_when == program_conf.PROGRAM_SCHEDULE_TYPE_MONTH_START:
27
+ MerchantScheduleProgram.create_first_day_of_month_schedule_program(merchant_acct, program)
28
+
29
+ elif program.giveaway_reward_when == program_conf.ADVANCE_IN_DAY:
30
+ MerchantScheduleProgram.create_daily_schedule_program(merchant_acct, program)
31
+
32
+ elif program.reward_base == program_conf.REWARD_BASE_ON_GIVEAWAY:
33
+ if program.giveaway_system_condition == program_conf.GIVEAWAY_SYSTEM_CONDITION_MEMBERSHIP_YEAR:
34
+ MerchantScheduleProgram.create_daily_schedule_program(merchant_acct, program)
35
+
36
+
37
+
38
+ def remove_schedule_program(program):
39
+ if program.reward_base in (program_conf.SCHEDULE_BASED_PROGRAM):
40
+ MerchantScheduleProgram.remove_by_merchant_program(program)
41
+
22
42
  class BaseProgram(BaseNModel, DictModel):
23
43
  reward_base = ndb.StringProperty(required=True, choices=set(program_conf.REWARD_BASE_SET))
24
44
  reward_format = ndb.StringProperty(required=False, choices=set(program_conf.REWARD_FORMAT_SET))
@@ -164,9 +184,9 @@ class BaseProgram(BaseNModel, DictModel):
164
184
  program.put()
165
185
 
166
186
  return program
167
-
187
+ '''
168
188
  @classmethod
169
- def __create_schedule_program(cls, merchant_acct, program):
189
+ def create_schedule_program(cls, merchant_acct, program):
170
190
  if program.reward_base in (program_conf.SCHEDULE_BASED_PROGRAM):
171
191
 
172
192
  if program.reward_base == program_conf.REWARD_BASE_ON_BIRTHDAY:
@@ -182,9 +202,10 @@ class BaseProgram(BaseNModel, DictModel):
182
202
 
183
203
 
184
204
  @classmethod
185
- def __remove_schedule_program(cls, program):
205
+ def remove_schedule_program(cls, program):
186
206
  if program.reward_base in (program_conf.SCHEDULE_BASED_PROGRAM):
187
207
  MerchantScheduleProgram.remove_by_merchant_program(program)
208
+ '''
188
209
 
189
210
  @classmethod
190
211
  @model_transactional(desc="publish_program")
@@ -196,7 +217,7 @@ class BaseProgram(BaseNModel, DictModel):
196
217
  merchant_acct = program.merchant_acct
197
218
  merchant_acct.update_published_program(program.to_configuration())
198
219
 
199
- cls.__create_schedule_program(merchant_acct, program)
220
+ create_schedule_program(merchant_acct, program)
200
221
 
201
222
  @classmethod
202
223
  @model_transactional(desc="archive_program")
@@ -208,7 +229,7 @@ class BaseProgram(BaseNModel, DictModel):
208
229
  merchant_acct = program.merchant_acct
209
230
  merchant_acct.remove_program_from_published_program_configuration(program.key_in_str)
210
231
 
211
- cls.__remove_schedule_program(program)
232
+ remove_schedule_program(program)
212
233
 
213
234
 
214
235
  @classmethod
@@ -231,7 +252,7 @@ class BaseProgram(BaseNModel, DictModel):
231
252
  merchant_acct = program.merchant_acct
232
253
  merchant_acct.update_published_program(program.to_configuration())
233
254
 
234
- cls.__create_schedule_program(merchant_acct, program)
255
+ create_schedule_program(merchant_acct, program)
235
256
 
236
257
 
237
258
  @classmethod
@@ -254,7 +275,7 @@ class BaseProgram(BaseNModel, DictModel):
254
275
  merchant_acct = program.merchant_acct
255
276
  merchant_acct.remove_program_from_published_program_configuration(program.key_in_str)
256
277
 
257
- cls.__remove_schedule_program(program)
278
+ remove_schedule_program(program)
258
279
 
259
280
  def to_configuration(self):
260
281
  program_configuration = {
@@ -698,6 +719,78 @@ class MerchantTierRewardProgram(MerchantProgram):
698
719
 
699
720
  return reward_settings_list
700
721
 
722
+ @staticmethod
723
+ @model_transactional(desc="publish_program")
724
+ def publish_program(program):
725
+ program.completed_status = program_conf.PROGRAM_STATUS_PUBLISH
726
+ program.published_datetime = datetime.now()
727
+ program.put()
728
+
729
+ merchant_acct = program.merchant_acct
730
+ merchant_acct.update_published_program(program.to_configuration())
731
+
732
+ create_schedule_program(merchant_acct, program)
733
+
734
+ @staticmethod
735
+ @model_transactional(desc="archive_program")
736
+ def archive_program(program):
737
+ program.archived = True
738
+ program.archived_datetime = datetime.now()
739
+ program.put()
740
+
741
+ merchant_acct = program.merchant_acct
742
+ #merchant_acct.remove_tier_program_from_published_tier_program_configuration(program.key_in_str)
743
+ merchant_acct.remove_program_from_published_program_configuration(program.key_in_str)
744
+
745
+ remove_schedule_program(program)
746
+
747
+ @staticmethod
748
+ @model_transactional(desc="enable program")
749
+ def enable(program, modified_by=None):
750
+ program.enabled = True
751
+
752
+ modified_by_username = None
753
+
754
+ if is_not_empty(modified_by):
755
+ if isinstance(modified_by, MerchantUser):
756
+ modified_by_username = modified_by.username
757
+
758
+ program.modified_by = modified_by.create_ndb_key()
759
+ program.modified_by_username = modified_by_username
760
+
761
+ program.put()
762
+
763
+ if program.is_published:
764
+ merchant_acct = program.merchant_acct
765
+ #merchant_acct.update_published_tier_program(program.to_configuration())
766
+ merchant_acct.update_published_program(program.to_configuration())
767
+
768
+ create_schedule_program(merchant_acct, program)
769
+
770
+
771
+ @classmethod
772
+ @model_transactional(desc="disable program")
773
+ def disable(cls, program, modified_by=None):
774
+ program.enabled = False
775
+
776
+ modified_by_username = None
777
+
778
+ if is_not_empty(modified_by):
779
+ if isinstance(modified_by, MerchantUser):
780
+ modified_by_username = modified_by.username
781
+ program.modified_by = modified_by.create_ndb_key()
782
+
783
+ program.modified_by_username = modified_by_username
784
+
785
+ program.put()
786
+
787
+ if program.is_published:
788
+ merchant_acct = program.merchant_acct
789
+ #merchant_acct.remove_tier_program_from_published_tier_program_configuration(program.key_in_str)
790
+ merchant_acct.remove_program_from_published_program_configuration(program.key_in_str)
791
+
792
+ remove_schedule_program(program)
793
+
701
794
  @staticmethod
702
795
  def create(merchant_acct, label=None, is_tier_recycle=True, is_show_progress=True, reward_format=None,
703
796
  desc=None, start_date=None, end_date=None, created_by=None):
File without changes
File without changes
File without changes
File without changes