Merge branch 'master' of github.com:sharelatex/web-sharelatex

This commit is contained in:
Henry Oswald
2014-04-28 16:27:19 +01:00
9 changed files with 30 additions and 31 deletions

View File

@@ -17,7 +17,7 @@ module.exports =
deleteProject: (req, res)->
project_id = req.params.Project_id
logger.log project_id:project_id, "deleting project"
logger.log project_id:project_id, "recived request to delete project"
projectDeleter.deleteProject project_id, (err)->
if err?
res.send 500

View File

@@ -33,13 +33,8 @@ module.exports =
(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, cb
tagsHandler.removeProjectFromAllTags project.owner_ref, project_id, (err)->
cb() #doesn't matter if this fails or the order it happens in
(cb)->
project.collaberator_refs.forEach (collaberator_ref)->
tagsHandler.removeProjectFromAllTags collaberator_ref, project_id, ->
@@ -49,5 +44,8 @@ module.exports =
tagsHandler.removeProjectFromAllTags readOnly_ref, project_id, ->
cb()
(cb)->
Project.remove {_id:project_id}, cb
], callback
Project.update {_id:project_id}, { $set: { archived: true }}, cb
], (err)->
if err?
logger.err err:err, "problem deleting project"
callback(err)

View File

@@ -3,6 +3,7 @@ settings = require("settings-sharelatex")
request = require("request")
logger = require("logger-sharelatex")
oneSecond = 1000
module.exports =
@@ -12,6 +13,7 @@ module.exports =
uri:uri
json:
name:tag
timeout:oneSecond
logger.log user_id:user_id, project_id:project_id, tag:tag, "send delete tag to tags api"
request.del opts, callback
@@ -21,6 +23,7 @@ module.exports =
uri:uri
json:
name:tag
timeout:oneSecond
logger.log user_id:user_id, project_id:project_id, tag:tag, "send add tag to tags api"
request.post opts, callback
@@ -50,6 +53,7 @@ module.exports =
uri = buildUri(user_id, project_id)
opts =
uri:"#{settings.apis.tags.url}/user/#{user_id}/project/#{project_id}"
timeout:oneSecond
logger.log user_id:user_id, project_id:project_id, "removing project_id from tags"
request.del opts, callback

View File

@@ -35,11 +35,11 @@ module.exports =
res.redirect "/project/#{project._id}"
publishProject: (user_id, project_id, callback)->
logger.log user_id:user_id, project_id:project_id, "reciving request to publish project as template"
logger.log user_id:user_id, project_id:project_id, "receiving request to publish project as template"
TemplatesPublisher.publish user_id, project_id, callback
unPublishProject: (user_id, project_id, callback)->
logger.log user_id:user_id, project_id:project_id, "reciving request to unpublish project as template"
logger.log user_id:user_id, project_id:project_id, "receiving request to unpublish project as template"
TemplatesPublisher.unpublish user_id, project_id, callback
getTemplateDetails: (user_id, project_id, callback)->

View File

@@ -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

View File

@@ -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)->

View File

@@ -59,14 +59,6 @@ block content
.content-with-navigation-sidebar
.box#projectListArea
.row-fluid
.span12
.alert.alert-info
p Due to unforeseen issues with our database, some projects which were changed or created on the 12th of April may have been rolled back 24 hours to Saturday morning (6am UTC on 12th April).
p If any or your projects are missing, or have been rolled-back to a previous version, then you can <strong> <a href="/restore">restore them from our latest back ups</a></strong>.
p We are very sorry about this. More details on what happened will follow as soon as possible.
.row-fluid
.span12
.page-header

View File

@@ -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)->

View File

@@ -6,7 +6,7 @@ modulePath = require('path').join __dirname, '../../../../app/js/Features/Tags/T
_ = require('underscore')
describe 'Tags handler', ->
describe 'TagsHandler', ->
user_id = "123nd3ijdks"
project_id = "123njdskj9jlk"
tagsUrl = "tags.sharelatex.testing"
@@ -26,17 +26,17 @@ describe 'Tags handler', ->
it 'Should post the request to the tags api with the user id in the url', (done)->
@handler.addTag user_id, project_id, tag, =>
@request.post.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}/tag", json:{name:tag}}).should.equal true
@request.post.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}/tag", timeout:1000, json:{name:tag}}).should.equal true
done()
it 'should send a delete request when a delete has been recived with the body format standardised', (done)->
@handler.deleteTag user_id, project_id, tag, =>
@request.del.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}/tag", json:{name:tag}}).should.equal true
@request.del.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}/tag", timeout:1000, json:{name:tag}}).should.equal true
done()
it 'should tell the tags api to remove the project_id from all the users tags', (done)->
@handler.removeProjectFromAllTags user_id, project_id, =>
@request.del.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}"}).should.equal true
@request.del.calledWith({uri:"#{tagsUrl}/user/#{user_id}/project/#{project_id}", timeout:1000}).should.equal true
done()
describe "groupTagsByProject", ->