Skip to content
This repository has been archived by the owner on Jun 23, 2018. It is now read-only.

Add: run end and start logic #155

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/models/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ export default DS.Model.extend({
name: DS.attr(),
start: DS.attr(),
end: DS.attr(),
enrollmentStart: DS.attr (),
enrollmentEnd: DS.attr (),
isFree: DS.attr(),
price: DS.attr(),
runAttemptId: DS.attr(),
course: DS.belongsTo('course'),
user: DS.belongsTo('user'),
percentComplete: DS.attr()
percentComplete: DS.attr(),
isEnded: Ember.computed ('end', function () {
const now = Math.floor (((new Date ()).getTime ()) / 1000),
endTime = this.get ('end')
;

return (now >= endTime)
})
})
8 changes: 8 additions & 0 deletions app/pods/classroom/run/index/route.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import Ember from 'ember';

export default Ember.Route.extend({
notify: Ember.inject.service (),

model () {
return this.modelFor('classroom.run')
},
afterModel (model, transition) {
if (model.get ('isEnded')) {
this.get ('notify').alert ('That batch has ended. Please buy the course again.')
return this.transitionTo ('courses.preview', model.get ('course'))
}
},
setupController (controller, model) {
controller.set('run', model);
controller.set('course', model.get('course'));
Expand Down