@@ -220,12 +220,11 @@ def enroll(self):
220
220
'crm_field' : 'Specialisation_programme_id' ,
221
221
'unexpected_value' : student ['Specialisation_programme_id' ],
222
222
'attempted_action' : 'enroll specialisation' ,
223
- 'message' : ('Specialisation change field checked, but student'
224
- + ' is already enrolled into the same specialisation' )
223
+ 'message' : ('Student is already enrolled into this specialisation' )
225
224
}
226
225
)
227
- # return in order to prevent reenrollment
228
- return
226
+ # continue in order to prevent reenrollment
227
+ continue
229
228
230
229
# otherwise continue with enrollment
231
230
try :
@@ -252,11 +251,13 @@ def enroll(self):
252
251
#
253
252
# If specialisation change, get the previous enrolled specialisation
254
253
if specialization_change :
254
+ error_flag = False
255
255
for program in user .program_set .all ():
256
256
if program .specialization_for :
257
257
# if already enrolled into same specialisation,
258
258
# trigger exception email and stop further process
259
259
if program == specialization :
260
+ error_flag = True
260
261
log .exception (
261
262
"**Student %s already enrolled in this specialization: %s**" ,
262
263
student ['Email' ], specialization_to_enroll
@@ -272,11 +273,13 @@ def enroll(self):
272
273
+ ' is already enrolled into the same specialisation' )
273
274
}
274
275
)
275
- # return in order to prevent reenrollment
276
- return
276
+ break
277
277
# otherwise, set current specialisation as current program (to unenroll)
278
278
else :
279
279
current_program = program .program_code
280
+ # continue to prevent reenrollment
281
+ if error_flag :
282
+ continue
280
283
281
284
# Enroll the student in the (new) specialisation
282
285
specialization_enrollment_status = specialization .enroll_student_in_program (
0 commit comments