@@ -714,12 +714,12 @@ def put(nr, *args, **kwargs):
714
714
715
715
if state not in State .VALID_STATES :
716
716
return make_response (jsonify ({"message" : "not a valid state" }), 406 )
717
-
717
+ myStr = 'continue...stateCd: {}'
718
718
try :
719
719
user = get_or_create_user_by_jwt (g .jwt_oidc_token_info )
720
720
nrd = RequestDAO .find_by_nr (nr )
721
721
722
- current_app .logger .debug (f"continue...stateCd: { 0 } " .format (nrd .stateCd ))
722
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
723
723
# current_app.logger.error("Error when replacing NR:{0} Err:{1}".format(nr, err))
724
724
if not nrd :
725
725
return make_response (jsonify ({"message" : "Request:{} not found" .format (nr )}), 404 )
@@ -733,7 +733,8 @@ def put(nr, *args, **kwargs):
733
733
734
734
if not valid_state_transition (user , nrd , state ):
735
735
return make_response (jsonify (message = 'you are not authorized to make these changes' ), 401 )
736
- current_app .logger .debug (f"continue...stateCd: { 0 } " .format (nrd .stateCd ))
736
+
737
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
737
738
name_choice_exists = {1 : False , 2 : False , 3 : False }
738
739
for name in json_input .get ('names' , None ):
739
740
if name ['name' ] and name ['name' ] != '' :
@@ -742,7 +743,8 @@ def put(nr, *args, **kwargs):
742
743
return make_response (jsonify (message = 'Data does not include a name choice 1' ), 400 )
743
744
if not name_choice_exists [2 ] and name_choice_exists [3 ]:
744
745
return make_response (jsonify (message = 'Data contains a name choice 3 without a name choice 2' ), 400 )
745
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
746
+
747
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
746
748
try :
747
749
existing_nr = RequestDAO .get_inprogress (user )
748
750
if existing_nr :
@@ -770,7 +772,7 @@ def put(nr, *args, **kwargs):
770
772
except Exception as e :
771
773
current_app .logger .debug (f"Error parsing expirationDate: { str (e )} " )
772
774
pass
773
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
775
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
774
776
# convert NWPTA dates to correct format
775
777
if json_input .get ('nwpta' , None ):
776
778
for region in json_input ['nwpta' ]:
@@ -789,7 +791,7 @@ def put(nr, *args, **kwargs):
789
791
reset = False
790
792
if nrd .furnished == RequestDAO .REQUEST_FURNISHED and json_input .get ('furnished' , None ) == 'N' :
791
793
reset = True
792
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
794
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
793
795
nrd .additionalInfo = convert_to_ascii (json_input .get ('additionalInfo' , None ))
794
796
nrd .consentFlag = json_input .get ('consentFlag' , None )
795
797
nrd .consent_dt = json_input .get ('consent_dt' , None )
@@ -828,11 +830,11 @@ def put(nr, *args, **kwargs):
828
830
nrd .previousRequestId = None
829
831
except KeyError :
830
832
nrd .previousRequestId = None
831
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
833
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
832
834
# if we're changing to a completed or cancelled state, clear reset flag on NR record
833
835
if state in State .COMPLETED_STATE + [State .CANCELLED ]:
834
836
nrd .hasBeenReset = False
835
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
837
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
836
838
# check if any of the Oracle db fields have changed, so we can send them back
837
839
is_changed__request = False
838
840
is_changed__previous_request = False
@@ -856,7 +858,7 @@ def put(nr, *args, **kwargs):
856
858
is_changed_consent = True
857
859
if nrd .consentFlag == 'R' :
858
860
queue_util .publish_email_notification (nrd .nrNum , 'CONSENT_RECEIVED' )
859
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
861
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
860
862
# Need this for a re-open
861
863
if nrd .stateCd != State .CONDITIONAL and is_changed__request_state :
862
864
nrd .consentFlag = None
@@ -867,7 +869,7 @@ def put(nr, *args, **kwargs):
867
869
### APPLICANTS ###
868
870
is_changed__applicant = False
869
871
is_changed__address = False
870
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
872
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
871
873
if nrd .applicants :
872
874
applicants_d = nrd .applicants [0 ]
873
875
orig_applicant = applicants_d .as_dict ()
@@ -895,7 +897,7 @@ def put(nr, *args, **kwargs):
895
897
applicants_d .postalCd = convert_to_ascii (appl .get ('postalCd' , None ))
896
898
applicants_d .stateProvinceCd = convert_to_ascii (appl .get ('stateProvinceCd' , None ))
897
899
applicants_d .countryTypeCd = convert_to_ascii (appl .get ('countryTypeCd' , None ))
898
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
900
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
899
901
# check if any of the Oracle db fields have changed, so we can send them back
900
902
if applicants_d .lastName != orig_applicant ['lastName' ]:
901
903
is_changed__applicant = True
@@ -931,12 +933,12 @@ def put(nr, *args, **kwargs):
931
933
is_changed__address = True
932
934
if applicants_d .countryTypeCd != orig_applicant ['countryTypeCd' ]:
933
935
is_changed__address = True
934
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
936
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
935
937
else :
936
938
applicants_d .delete_from_db ()
937
939
is_changed__applicant = True
938
940
is_changed__address = True
939
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
941
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
940
942
941
943
### END applicants ###
942
944
@@ -947,7 +949,7 @@ def put(nr, *args, **kwargs):
947
949
is_changed__name2 = False
948
950
is_changed__name3 = False
949
951
deleted_names = [False ] * 3
950
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
952
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
951
953
if len (nrd .names ) == 0 :
952
954
new_name_choice = Name ()
953
955
new_name_choice .nrId = nrd .id
@@ -956,23 +958,23 @@ def put(nr, *args, **kwargs):
956
958
new_name_choice .name = convert_to_ascii (new_name_choice .name )
957
959
958
960
nrd .names .append (new_name_choice )
959
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
961
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
960
962
for nrd_name in nrd .names :
961
963
962
964
orig_name = nrd_name .as_dict ()
963
965
964
966
for in_name in json_input .get ('names' , []):
965
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
967
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
966
968
if len (nrd .names ) < in_name ['choice' ]:
967
969
968
970
errors = names_schema .validate (in_name , partial = False )
969
971
if errors :
970
972
MessageServices .add_message (MessageServices .ERROR , 'names_validation' , errors )
971
973
# return make_response(jsonify(errors), 400
972
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
974
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
973
975
# don't save if the name is blank
974
976
if in_name .get ('name' ) and in_name .get ('name' ) != '' :
975
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
977
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
976
978
new_name_choice = Name ()
977
979
new_name_choice .nrId = nrd .id
978
980
new_name_choice .choice = in_name .get ('choice' )
@@ -999,7 +1001,7 @@ def put(nr, *args, **kwargs):
999
1001
is_changed__name3 = True
1000
1002
1001
1003
elif nrd_name .choice == in_name ['choice' ]:
1002
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1004
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1003
1005
errors = names_schema .validate (in_name , partial = False )
1004
1006
if errors :
1005
1007
MessageServices .add_message (MessageServices .ERROR , 'names_validation' , errors )
@@ -1020,48 +1022,48 @@ def put(nr, *args, **kwargs):
1020
1022
nrd_name .name = in_name .get ('name' )
1021
1023
nrd_name .state = in_name .get ('state' )
1022
1024
nrd_name .name = convert_to_ascii (nrd_name .name .upper ())
1023
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1025
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1024
1026
# set comments (existing or cleared)
1025
1027
if in_name .get ('comment' , None ) is not None :
1026
1028
1027
1029
# if there is a comment ID in data, just set it
1028
1030
if in_name ['comment' ].get ('id' , None ) is not None :
1029
1031
nrd_name .commentId = in_name ['comment' ].get ('id' )
1030
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1032
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1031
1033
1032
1034
# if no comment id, it's a new comment, so add it
1033
1035
else :
1034
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1036
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1035
1037
# no business case for this at this point - this code will never run
1036
1038
pass
1037
1039
1038
1040
else :
1039
1041
nrd_name .comment = None
1040
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1042
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1041
1043
# convert data to ascii, removing data that won't save to Oracle
1042
1044
# - also force uppercase
1043
1045
nrd_name .name = convert_to_ascii (nrd_name .name )
1044
1046
if (nrd_name .name is not None ):
1045
1047
nrd_name .name = nrd_name .name .upper ()
1046
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1048
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1047
1049
# check if any of the Oracle db fields have changed, so we can send them back
1048
1050
# - this is only for editing a name from the Edit NR section, NOT making a decision
1049
1051
if nrd_name .name != orig_name ['name' ]:
1050
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1052
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1051
1053
if nrd_name .choice == 1 :
1052
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1054
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1053
1055
is_changed__name1 = True
1054
1056
json_input ['comments' ].append ({'comment' : 'Name choice 1 changed from {0} to {1}'
1055
1057
.format (orig_name ['name' ], nrd_name .name )})
1056
1058
if nrd_name .choice == 2 :
1057
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1059
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1058
1060
is_changed__name2 = True
1059
1061
if not nrd_name .name :
1060
1062
deleted_names [nrd_name .choice - 1 ] = True
1061
1063
json_input ['comments' ].append ({'comment' : 'Name choice 2 changed from {0} to {1}'
1062
1064
.format (orig_name ['name' ], nrd_name .name )})
1063
1065
if nrd_name .choice == 3 :
1064
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1066
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1065
1067
is_changed__name3 = True
1066
1068
if not nrd_name .name :
1067
1069
deleted_names [nrd_name .choice - 1 ] = True
@@ -1074,17 +1076,17 @@ def put(nr, *args, **kwargs):
1074
1076
# we only add new comments, we do not change existing comments
1075
1077
# - we can find new comments in json as those with no ID
1076
1078
# - This must come after names section above, to handle comments re. changed names.
1077
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1079
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1078
1080
for in_comment in json_input ['comments' ]:
1079
1081
is_new_comment = False
1080
1082
try :
1081
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1083
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1082
1084
if in_comment ['id' ] is None or in_comment ['id' ] == 0 :
1083
1085
is_new_comment = True
1084
1086
except KeyError :
1085
1087
is_new_comment = True
1086
1088
if is_new_comment and in_comment ['comment' ] is not None :
1087
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1089
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1088
1090
new_comment = Comment ()
1089
1091
new_comment .comment = convert_to_ascii (in_comment ['comment' ])
1090
1092
new_comment .examiner = user
@@ -1096,17 +1098,17 @@ def put(nr, *args, **kwargs):
1096
1098
1097
1099
is_changed__nwpta_ab = False
1098
1100
is_changed__nwpta_sk = False
1099
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1101
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1100
1102
if nrd .partnerNS .count () > 0 :
1101
1103
for nrd_nwpta in nrd .partnerNS .all ():
1102
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1104
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1103
1105
1104
1106
orig_nwpta = nrd_nwpta .as_dict ()
1105
1107
1106
1108
for in_nwpta in json_input ['nwpta' ]:
1107
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1109
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1108
1110
if nrd_nwpta .partnerJurisdictionTypeCd == in_nwpta ['partnerJurisdictionTypeCd' ]:
1109
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1111
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1110
1112
errors = nwpta_schema .validate (in_nwpta , partial = False )
1111
1113
if errors :
1112
1114
MessageServices .add_message (MessageServices .ERROR , 'nwpta_validation' , errors )
@@ -1138,21 +1140,21 @@ def put(nr, *args, **kwargs):
1138
1140
1139
1141
# if there were errors, abandon changes and return the set of errors
1140
1142
warning_and_errors = MessageServices .get_all_messages ()
1141
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1143
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1142
1144
if warning_and_errors :
1143
1145
for we in warning_and_errors :
1144
1146
if we ['type' ] == MessageServices .ERROR :
1145
1147
return make_response (jsonify (errors = warning_and_errors ), 400 )
1146
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1148
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1147
1149
if reset :
1148
1150
nrd .expirationDate = None
1149
1151
nrd .consentFlag = None
1150
1152
nrd .consent_dt = None
1151
1153
is_changed__request = True
1152
1154
is_changed_consent = True
1153
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1155
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1154
1156
else :
1155
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1157
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1156
1158
change_flags = {
1157
1159
'is_changed__request' : is_changed__request ,
1158
1160
'is_changed__previous_request' : is_changed__previous_request ,
@@ -1168,33 +1170,33 @@ def put(nr, *args, **kwargs):
1168
1170
}
1169
1171
1170
1172
if any (value is True for value in change_flags .values ()):
1171
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1173
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1172
1174
nrd .save_to_db ()
1173
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1175
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1174
1176
1175
1177
# Delete any names that were blanked out
1176
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1178
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1177
1179
for nrd_name in nrd .names :
1178
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1180
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1179
1181
if deleted_names [nrd_name .choice - 1 ]:
1180
1182
nrd_name .delete_from_db ()
1181
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1183
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1182
1184
1183
1185
# if there were errors, return the set of errors
1184
1186
warning_and_errors = MessageServices .get_all_messages ()
1185
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1187
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1186
1188
if warning_and_errors :
1187
1189
for we in warning_and_errors :
1188
1190
if we ['type' ] == MessageServices .ERROR :
1189
1191
return make_response (jsonify (errors = warning_and_errors ), 400 )
1190
1192
1191
1193
# Finally save the entire graph
1192
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1194
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1193
1195
nrd .save_to_db ()
1194
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1196
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1195
1197
1196
1198
EventRecorder .record (user , Event .PUT , nrd , json_input )
1197
- current_app .logger .debug ('continue...stateCd: {}' .format (nrd .stateCd ))
1199
+ current_app .logger .debug (myStr .format (nrd .stateCd ))
1198
1200
1199
1201
except ValidationError as ve :
1200
1202
return make_response (jsonify (ve .messages ), 400 )
0 commit comments