// setClassRegistrants
// To setup the registrant
// Has to create a regTime first for the class
- // Then is can add the registrant into that regTime model.
+ // Then is can add the registrant into that regTime model collection.
setClassRegistrants: function( registrants ){
for ( var i = 0; i < registrants.length; i++ ) {
+ // Find the class that this registrant belongs to.
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+ // console.log( foundClass );
if ( foundClass != undefined ) {
// Try looking through the class times
+ // console.log( registrants[i].reg_time );
+ // console.log( foundClass.get('times') );
+ // Using the registrants reg_time lookup the regTime
// var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
+ // console.log( foundRegTime );
if ( foundRegTime ) {
+ // Set the reg_event for this reg_time to the class we found for registrant
foundRegTime.reg_event = foundClass.get('reg_event');
// Now add the time if needed
+ // First check to see if there's not one added already (regTime).
var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
if ( !hasRegTime ) {
+ // Here we have to add the regTime into the class.
foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
hasRegTime.set({ parent: foundClass });
}
- // Add the registrant
+ // Add the registrant to the regTime.
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
nRegTime.registrants.create( registrants[i] );
}
this.model.regTimes.create( newTime );
}
- console.log( classTimes );
+ // console.log( classTimes );
return this;
},
// setClassRegistrants
// To setup the registrant
// Has to create a regTime first for the class
- // Then is can add the registrant into that regTime model.
+ // Then is can add the registrant into that regTime model collection.
setClassRegistrants: function( registrants ){
for ( var i = 0; i < registrants.length; i++ ) {
+ // Find the class that this registrant belongs to.
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+ // console.log( foundClass );
if ( foundClass != undefined ) {
// Try looking through the class times
+ // console.log( registrants[i].reg_time );
+ // console.log( foundClass.get('times') );
+ // Using the registrants reg_time lookup the regTime
// var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
+ // console.log( foundRegTime );
if ( foundRegTime ) {
+ // Set the reg_event for this reg_time to the class we found for registrant
foundRegTime.reg_event = foundClass.get('reg_event');
// Now add the time if needed
+ // First check to see if there's not one added already (regTime).
var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
if ( !hasRegTime ) {
+ // Here we have to add the regTime into the class.
foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
hasRegTime.set({ parent: foundClass });
}
- // Add the registrant
+ // Add the registrant to the regTime.
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
nRegTime.registrants.create( registrants[i] );
}