Fix issue with front end calls for regTime from attendees.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Dec 2017 19:45:24 +0000 (14:45 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 14 Dec 2017 20:00:20 +0000 (15:00 -0500)
Need to make sure the attendee has proper regTime data first.

js/frontRegApp.js
js/models/front/regEvent.js

index 817d56b..415f81f 100644 (file)
@@ -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] );
 
             }
         }
index 3e66a4c..3ef61ae 100644 (file)
@@ -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] );
 
             }
         }