From 9a2ed7c934fa9a5f3a6d2050bf9a82c70fde6a18 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 14 Dec 2017 14:45:24 -0500 Subject: [PATCH] Fix issue with front end calls for regTime from attendees. Need to make sure the attendee has proper regTime data first. --- js/frontRegApp.js | 21 +++++++++++---------- js/models/front/regEvent.js | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 817d56b..415f81f 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -157,17 +157,18 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time }); if ( foundRegTime ) { foundRegTime.reg_event = foundClass.get('reg_event'); + + // Now add the time if needed + var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); + if ( !hasRegTime ) { + foundClass.regTimes.create( foundRegTime ); + hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id }); + hasRegTime.set({ parent: foundClass }); + } + // Add the registrant + var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')}); + nRegTime.registrants.create( registrants[i] ); } - // Now add the time if needed - var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); - if ( !hasRegTime ) { - foundClass.regTimes.create( foundRegTime ); - hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id }); - hasRegTime.set({ parent: foundClass }); - } - // Add the registrant - var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')}); - nRegTime.registrants.create( registrants[i] ); } } diff --git a/js/models/front/regEvent.js b/js/models/front/regEvent.js index 3e66a4c..3ef61ae 100644 --- a/js/models/front/regEvent.js +++ b/js/models/front/regEvent.js @@ -41,17 +41,18 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time }); if ( foundRegTime ) { foundRegTime.reg_event = foundClass.get('reg_event'); + + // Now add the time if needed + var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); + if ( !hasRegTime ) { + foundClass.regTimes.create( foundRegTime ); + hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id }); + hasRegTime.set({ parent: foundClass }); + } + // Add the registrant + var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')}); + nRegTime.registrants.create( registrants[i] ); } - // Now add the time if needed - var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); - if ( !hasRegTime ) { - foundClass.regTimes.create( foundRegTime ); - hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id }); - hasRegTime.set({ parent: foundClass }); - } - // Add the registrant - var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')}); - nRegTime.registrants.create( registrants[i] ); } } -- 2.17.1