diff --git a/services/web/app/coffee/Features/InactiveData/InactiveProjectManager.coffee b/services/web/app/coffee/Features/InactiveData/InactiveProjectManager.coffee index 3f277fa931..7885107c92 100644 --- a/services/web/app/coffee/Features/InactiveData/InactiveProjectManager.coffee +++ b/services/web/app/coffee/Features/InactiveData/InactiveProjectManager.coffee @@ -10,13 +10,13 @@ MILISECONDS_IN_DAY = 86400000 module.exports = InactiveProjectManager = reactivateProjectIfRequired: (project_id, callback)-> - ProjectGetter.getProject project_id, {inactive:true}, (err, project)-> + ProjectGetter.getProject project_id, {active:true}, (err, project)-> if err? logger.err err:err, project_id:project_id, "error getting project" return callback(err) - logger.log project_id:project_id, inactive:project.inactive, "seeing if need to reactivate project" + logger.log project_id:project_id, active:project.active, "seeing if need to reactivate project" - if !project.inactive + if project.active return callback() DocstoreManager.unarchiveProject project_id, (err)-> @@ -30,7 +30,7 @@ module.exports = InactiveProjectManager = logger.log oldProjectDate:oldProjectDate, limit:limit, daysOld:daysOld, "starting process of deactivating old projects" Project.find() .where("lastOpened").lt(oldProjectDate) - .where("inactive").ne(true) + .where("active").equals(true) .select("_id") .limit(limit) .exec (err, projects)-> diff --git a/services/web/app/coffee/Features/Project/ProjectUpdateHandler.coffee b/services/web/app/coffee/Features/Project/ProjectUpdateHandler.coffee index 25466ec898..7738425c8e 100644 --- a/services/web/app/coffee/Features/Project/ProjectUpdateHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectUpdateHandler.coffee @@ -19,14 +19,14 @@ module.exports = markAsInactive: (project_id, callback)-> conditions = {_id:project_id} - update = {inactive:true} + update = {active:false} Project.update conditions, update, {}, (err)-> if callback? callback() markAsActive: (project_id, callback)-> conditions = {_id:project_id} - update = { $unset: { inactive: true }} + update = {active:true} Project.update conditions, update, {}, (err)-> if callback? callback() \ No newline at end of file diff --git a/services/web/app/coffee/models/Project.coffee b/services/web/app/coffee/models/Project.coffee index 010d48d9dd..8c458e28ed 100644 --- a/services/web/app/coffee/models/Project.coffee +++ b/services/web/app/coffee/models/Project.coffee @@ -18,7 +18,7 @@ ProjectSchema = new Schema name : {type:String, default:'new project'} lastUpdated : {type:Date, default: () -> new Date()} lastOpened : {type:Date} - inactive : { type: Boolean } + active : { type: Boolean, default: true } owner_ref : {type:ObjectId, ref:'User'} collaberator_refs : [ type:ObjectId, ref:'User' ] readOnly_refs : [ type:ObjectId, ref:'User' ] diff --git a/services/web/test/UnitTests/coffee/InactiveData/InactiveProjectManagerTests.coffee b/services/web/test/UnitTests/coffee/InactiveData/InactiveProjectManagerTests.coffee index bd538c37f3..6befd7f70f 100644 --- a/services/web/test/UnitTests/coffee/InactiveData/InactiveProjectManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/InactiveData/InactiveProjectManagerTests.coffee @@ -33,7 +33,7 @@ describe "InactiveProjectManager", -> describe "reactivateProjectIfRequired", -> beforeEach -> - @project = {inactive:true} + @project = {active:false} @ProjectGetter.getProject.callsArgWith(2, null, @project) @ProjectUpdateHandler.markAsActive.callsArgWith(1) @@ -53,8 +53,8 @@ describe "InactiveProjectManager", -> done() - it "should not call unarchiveProject if it is not inactive", (done)-> - delete @project.inactive + it "should not call unarchiveProject if it is active", (done)-> + @project.active = true @DocstoreManager.unarchiveProject.callsArgWith(1) @InactiveProjectManager.reactivateProjectIfRequired @project_id, (err)=> @DocstoreManager.unarchiveProject.calledWith(@project_id).should.equal false diff --git a/services/web/test/UnitTests/coffee/Project/ProjectUpdateHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectUpdateHandlerTests.coffee index 9aac418578..5922a027e3 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectUpdateHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectUpdateHandlerTests.coffee @@ -42,7 +42,7 @@ describe 'ProjectUpdateHandler', -> @handler.markAsInactive project_id, (err)=> args = @ProjectModel.update.args[0] args[0]._id.should.equal project_id - args[1].inactive.should.equal true + args[1].active.should.equal false done() describe "markAsActive", -> @@ -51,7 +51,7 @@ describe 'ProjectUpdateHandler', -> @handler.markAsActive project_id, (err)=> args = @ProjectModel.update.args[0] args[0]._id.should.equal project_id - args[1]["$unset"].inactive.should.equal true + args[1].active.should.equal true done()