@@ -709,6 +709,7 @@ class Meta:
709709 company_id = UnicodeAttribute (hash_key = True )
710710 project_id = UnicodeAttribute (range_key = True )
711711
712+ # LG: patched class
712713class DateTimeAttribute (UTCDateTimeAttribute ):
713714 """
714715 We need to patch deserialize, see https://pynamodb.readthedocs.io/en/stable/upgrading.html#no-longer-parsing-date-time-strings-leniently
@@ -720,6 +721,20 @@ def deserialize(self, value):
720721 except (TypeError , ValueError ):
721722 return parsedatestring (value )
722723
724+ # LG: patched class
725+ class PatchedUnicodeSetAttribute (UnicodeSetAttribute ):
726+ """
727+ In attribute value we can have:
728+ - set of strings "SS": {"SS":["id1","id2"]} - this is expected by pynamodb
729+ - list of strings "LS": {"L":[{"S": "id"},{"S":"id2"}] - this is what golang saves
730+ - NULL: {"NULL":true}
731+ """
732+ def get_value (self , value ):
733+ # if self.attr_type not in value:
734+ if self .attr_type == 'SS' and 'L' in value :
735+ value = {'SS' :list (map (lambda x : x ['S' ], value ['L' ]))}
736+ super (PatchedUnicodeSetAttribute , self ).get_value (value )
737+
723738class BaseModel (Model ):
724739 """
725740 Base pynamodb model used for all CLA models.
@@ -1174,7 +1189,7 @@ class Meta:
11741189 project_name_lower_search_index = ProjectNameLowerIndex ()
11751190 foundation_sfid_project_name_index = ProjectFoundationIDIndex ()
11761191
1177- project_acl = UnicodeSetAttribute (default = set )
1192+ project_acl = PatchedUnicodeSetAttribute (default = set )
11781193 # Default is v1 for all of our models - override for this model so that we can redirect to new UI when ready
11791194 # version = UnicodeAttribute(default="v2") # Schema version is v2 for Project Models
11801195
@@ -1583,7 +1598,7 @@ class Meta:
15831598 user_id = UnicodeAttribute (hash_key = True )
15841599 # User Emails are specifically GitHub Emails
15851600 user_external_id = UnicodeAttribute (null = True )
1586- user_emails = UnicodeSetAttribute (default = set )
1601+ user_emails = PatchedUnicodeSetAttribute (default = set )
15871602 user_name = UnicodeAttribute (null = True )
15881603 user_company_id = UnicodeAttribute (null = True )
15891604 user_github_id = NumberAttribute (null = True )
@@ -2505,7 +2520,7 @@ class Meta:
25052520 signature_return_url = UnicodeAttribute (null = True )
25062521 signature_callback_url = UnicodeAttribute (null = True )
25072522 signature_user_ccla_company_id = UnicodeAttribute (null = True )
2508- signature_acl = UnicodeSetAttribute (default = set )
2523+ signature_acl = PatchedUnicodeSetAttribute (default = set )
25092524 signature_project_index = ProjectSignatureIndex ()
25102525 signature_reference_index = ReferenceSignatureIndex ()
25112526 signature_envelope_id = UnicodeAttribute (null = True )
@@ -2792,7 +2807,6 @@ def get_signature_user_ccla_company_id(self):
27922807 return self .model .signature_user_ccla_company_id
27932808
27942809 def get_signature_acl (self ):
2795- cla .log .info (f"LG:{ self .get_signature_id ()} : get_signature_acl: --> { self .model .signature_acl } " )
27962810 return self .model .signature_acl or set ()
27972811
27982812 def get_signature_return_url_type (self ):
@@ -2934,7 +2948,6 @@ def set_signature_user_ccla_company_id(self, company_id) -> None:
29342948
29352949 def set_signature_acl (self , signature_acl_username ) -> None :
29362950 self .model .signature_acl = set ([signature_acl_username ])
2937- cla .log .info (f"LG:{ self .get_signature_id ()} : set_signature_acl: { self .model .signature_acl } <-- { signature_acl_username } " )
29382951
29392952 def set_signature_return_url_type (self , signature_return_url_type ) -> None :
29402953 self .model .signature_return_url_type = signature_return_url_type
@@ -2994,16 +3007,12 @@ def add_signature_acl(self, username) -> None:
29943007 if not self .model .signature_acl :
29953008 self .model .signature_acl = set ()
29963009 self .model .signature_acl .add (username )
2997- # LG:
2998- cla .log .info (f"LG:{ self .get_signature_id ()} : add_signature_acl: { self .model .signature_acl } <-- { username } " )
29993010
30003011 def remove_signature_acl (self , username ) -> None :
30013012 current_acl = self .model .signature_acl or set ()
30023013 if username not in current_acl :
30033014 return
30043015 self .model .signature_acl .remove (username )
3005- # LG:
3006- cla .log .info (f"LG:{ self .get_signature_id ()} : remove_signature_acl: { self .model .signature_acl } <-- { username } " )
30073016
30083017 def set_user_email (self , user_email ) -> None :
30093018 self .model .user_email = user_email
@@ -3518,7 +3527,7 @@ class Meta:
35183527 company_name_index = CompanyNameIndex ()
35193528 signing_entity_name_index = SigningEntityNameIndex ()
35203529 company_external_id_index = ExternalCompanyIndex ()
3521- company_acl = UnicodeSetAttribute (default = set )
3530+ company_acl = PatchedUnicodeSetAttribute (default = set )
35223531 note = UnicodeAttribute (null = True )
35233532
35243533
@@ -4585,7 +4594,7 @@ class Meta:
45854594 host = "http://localhost:8000"
45864595
45874596 username = UnicodeAttribute (hash_key = True )
4588- projects = UnicodeSetAttribute (default = set )
4597+ projects = PatchedUnicodeSetAttribute (default = set )
45894598
45904599
45914600class UserPermissions (model_interfaces .UserPermissions ): # pylint: disable=too-many-public-methods
@@ -5285,7 +5294,7 @@ class Meta:
52855294 project_id = UnicodeAttribute (null = True )
52865295 project_name = UnicodeAttribute (null = True )
52875296 request_status = UnicodeAttribute (null = True )
5288- user_emails = UnicodeSetAttribute (default = set )
5297+ user_emails = PatchedUnicodeSetAttribute (default = set )
52895298 user_id = UnicodeAttribute (null = True )
52905299 user_github_id = UnicodeAttribute (null = True )
52915300 user_github_username = UnicodeAttribute (null = True )
0 commit comments