Commit 0466dfb5 authored by Mark Stenglein's avatar Mark Stenglein

Finish fixing the models:

- had a couple mistakes still on naming etc.
parent 9ea9e5d1
......@@ -10,7 +10,7 @@ module.exports = function (sequelize, DataTypes) {
semester: {
type: DataTypes.STRING,
references: {
model: 'Semester',
model: 'Semesters',
key : 'slug'
}
},
......@@ -86,47 +86,6 @@ module.exports = function (sequelize, DataTypes) {
FclassType: DataTypes.STRING,
Flocation: DataTypes.STRING
}, {
validate: {
Msession_validate: function (value) {
if ((this.Msession === true) &&
(this.MtimeStart === null || this.MtimeEnd === null)) {
throw new Error('Start and end times must be defined for' +
' Monday if class is set to true.')
}
},
Tsession_validate: function (value) {
if ((this.Tsession === true) &&
(this.TtimeStart === null || this.TtimeEnd === null)) {
throw new Error('Start and end times must be defined for' +
' Tuesday if class is set to true.')
}
},
Wsession_validate: function (value) {
if ((this.Wsession === true) &&
(this.WtimeStart === null || this.WtimeEnd === null)) {
throw new Error('Start and end times must be defined for' +
' Wednesday if class is set to true.')
}
},
Rsession_validate: function (value) {
if ((this.Rsession === true) &&
(this.RtimeStart === null || this.RtimeEnd === null)) {
throw new Error('Start and end times must be defined for' +
' Thursday if class is set to true.')
}
},
Fsession_validate: function (value) {
if ((this.Fsession === true) &&
(this.FtimeStart === null || this.FtimeEnd === null)) {
throw new Error('Start and end times must be defined for' +
' Friday if class is set to true.')
}
}
},
indexes: [
{
unique: true,
......@@ -155,7 +114,7 @@ module.exports = function (sequelize, DataTypes) {
],
classMethods: {
associate: function (models) {
models.Section.belongsTo(models.Semester)
models.Section.belongsTo(models.Semester, {foreignKey: 'semester'})
}
}
})
......
......@@ -9,7 +9,7 @@ module.exports = function (sequelize, DataTypes) {
university: {
type: DataTypes.STRING,
references: {
model: 'University',
model: 'Universities',
key : 'slug'
}
},
......@@ -24,8 +24,8 @@ module.exports = function (sequelize, DataTypes) {
}
], classMethods: {
associate: function (models) {
models.Semester.belongsTo(models.University)
models.Semester.hasMany(models.Section)
models.Semester.belongsTo(models.University, {foreignKey: 'university'})
models.Semester.hasMany(models.Section, {foreignKey: 'semester'})
}
}
})
......
......@@ -25,7 +25,7 @@ module.exports = function (sequelize, DataTypes) {
],
classMethods: {
associate: function (models) {
models.University.hasMany(models.Semester)
models.University.hasMany(models.Semester, {foreignKey: 'university'})
}
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment