From: Steve Sutton Date: Thu, 14 Dec 2017 19:45:24 +0000 (-0500) Subject: Fix issue with front end calls for regTime from attendees. X-Git-Tag: v1.0.0^2~212 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=9a2ed7c934fa9a5f3a6d2050bf9a82c70fde6a18;p=WP-Plugins%2Fglm-member-db-registrations.git Fix issue with front end calls for regTime from attendees. Need to make sure the attendee has proper regTime data first. --- 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] ); } }