mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-04 12:06:49 +00:00
Mark projects as archived, but don't actually delete them
This commit is contained in:
parent
6dd792e5e9
commit
d528ac21a3
4 changed files with 13 additions and 14 deletions
services/web
app/coffee
test/UnitTests/coffee/Project
|
@ -32,12 +32,6 @@ module.exports =
|
|||
async.series [
|
||||
(cb)->
|
||||
documentUpdaterHandler.flushProjectToMongoAndDelete project_id, cb
|
||||
(cb)->
|
||||
Project.applyToAllFilesRecursivly project.rootFolder[0], (file)=>
|
||||
FileStoreHandler.deleteFile project_id, file._id, ->
|
||||
cb()
|
||||
(cb)->
|
||||
AutomaticSnapshotManager.unmarkProjectAsUpdated project_id, cb
|
||||
(cb)->
|
||||
tagsHandler.removeProjectFromAllTags project.owner_ref, project_id, (err)->
|
||||
cb() #doesn't matter if this fails or the order it happens in
|
||||
|
@ -50,7 +44,7 @@ module.exports =
|
|||
tagsHandler.removeProjectFromAllTags readOnly_ref, project_id, ->
|
||||
cb()
|
||||
(cb)->
|
||||
Project.remove {_id:project_id}, cb
|
||||
Project.update {_id:project_id}, { $set: { archived: true }}, cb
|
||||
], (err)->
|
||||
if err?
|
||||
logger.err err:err, "problem deleting project"
|
||||
|
|
|
@ -28,7 +28,7 @@ module.exports =
|
|||
requestCanAccessProject : (req, res, next)->
|
||||
doRequest = (req, res, next) ->
|
||||
getRequestUserAndProject req, res, {allow_auth_token: options?.allow_auth_token}, (err, user, project)->
|
||||
if !project?
|
||||
if !project? or project.archived
|
||||
return HomeController.notFound(req, res, next)
|
||||
userCanAccessProject user, project, (canAccess, permissionLevel)->
|
||||
if canAccess
|
||||
|
@ -156,7 +156,7 @@ module.exports =
|
|||
|
||||
getRequestUserAndProject = (req, res, options, callback)->
|
||||
project_id = req.params.Project_id
|
||||
Project.findById project_id, 'name owner_ref readOnly_refs collaberator_refs publicAccesLevel', (err, project)=>
|
||||
Project.findById project_id, 'name owner_ref readOnly_refs collaberator_refs publicAccesLevel archived', (err, project)=>
|
||||
if err?
|
||||
logger.err err:err, "error getting project for security check"
|
||||
return callback err
|
||||
|
|
|
@ -26,6 +26,7 @@ ProjectSchema = new Schema
|
|||
deletedByExternalDataSource : {type: Boolean, default: false}
|
||||
useClsi2 : {type:Boolean, default: true}
|
||||
description : {type:String, default:''}
|
||||
archived : { type: Boolean }
|
||||
|
||||
ProjectSchema.statics.getProject = (project_or_id, fields, callback)->
|
||||
if project_or_id._id?
|
||||
|
@ -53,9 +54,9 @@ ProjectSchema.statics.findPopulatedById = (project_id, callback)->
|
|||
callback(null, projects[0])
|
||||
|
||||
ProjectSchema.statics.findAllUsersProjects = (user_id, requiredFields, callback)->
|
||||
this.find {owner_ref:user_id}, requiredFields, (err, projects)=>
|
||||
this.find {collaberator_refs:user_id}, requiredFields, (err, collabertions)=>
|
||||
this.find {readOnly_refs:user_id}, requiredFields, (err, readOnlyProjects)=>
|
||||
this.find {owner_ref:user_id, archived: { $exists: false }}, requiredFields, (err, projects)=>
|
||||
this.find {collaberator_refs:user_id, archived: { $exists: false }}, requiredFields, (err, collabertions)=>
|
||||
this.find {readOnly_refs:user_id, archived: { $exists: false }}, requiredFields, (err, readOnlyProjects)=>
|
||||
callback(err, projects, collabertions, readOnlyProjects)
|
||||
|
||||
sanitizeTypeOfElement = (elementType)->
|
||||
|
|
|
@ -61,7 +61,7 @@ describe 'Project deleter', ->
|
|||
|
||||
describe "deleteProject", ->
|
||||
beforeEach ->
|
||||
@Project.remove.callsArgWith(1)
|
||||
@Project.update.callsArgWith(2)
|
||||
|
||||
it "should flushProjectToMongoAndDelete in doc updater", (done)->
|
||||
@deleter.deleteProject @project_id, =>
|
||||
|
@ -70,7 +70,11 @@ describe 'Project deleter', ->
|
|||
|
||||
it "should remove the project", (done)->
|
||||
@deleter.deleteProject @project_id, =>
|
||||
@Project.remove.calledWith(_id:@project_id).should.equal true
|
||||
@Project.update.calledWith({
|
||||
_id:@project_id
|
||||
}, {
|
||||
$set: { archived: true }
|
||||
}).should.equal true
|
||||
done()
|
||||
|
||||
it "should removeProjectFromAllTags", (done)->
|
||||
|
|
Loading…
Reference in a new issue