diff --git a/server/campaigns/Campaign.coffee b/server/campaigns/Campaign.coffee deleted file mode 100644 index fbd374392..000000000 --- a/server/campaigns/Campaign.coffee +++ /dev/null @@ -1,22 +0,0 @@ -mongoose = require('mongoose') -plugins = require('../plugins/plugins') - -NestedLevelSchema = new mongoose.Schema( - name: String - description: String - thumbnail: Buffer - original: {type: mongoose.Schema.ObjectId, ref: 'level'} - majorVersion: Number -) - -CampaignSchema = new mongoose.Schema( - description: String - levels: [NestedLevelSchema] -) - -CampaignSchema.plugin(plugins.NamedPlugin) -CampaignSchema.plugin(plugins.PermissionsPlugin) -CampaignSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']}) - -module.exports = Campaign = mongoose.model('campaign', CampaignSchema) - diff --git a/server/campaigns/CampaignStatus.coffee b/server/campaigns/CampaignStatus.coffee deleted file mode 100644 index 77058902a..000000000 --- a/server/campaigns/CampaignStatus.coffee +++ /dev/null @@ -1,17 +0,0 @@ -mongoose = require('mongoose') - -LevelStatusSchema = new mongoose.Schema( - lastPlayed: Date - victorious: Boolean - original: {type: mongoose.Schema.ObjectId, ref: 'level'} - majorVersion: Number -) - -CampaignStatusSchema = new mongoose.Schema( - user: {type: mongoose.Schema.ObjectId, ref: 'User'} - campaign: {type: mongoose.Schema.ObjectId, ref: 'campaign'} - levelStatuses: [LevelStatusSchema] -) -CampaignStatusSchema.index {user: 1, campaign: 1}, {unique: true} - -module.exports = CampaignStatus = mongoose.model('campaign.status', CampaignStatusSchema) \ No newline at end of file diff --git a/server/campaigns/campaign_handler.coffee b/server/campaigns/campaign_handler.coffee deleted file mode 100644 index abf83b3f7..000000000 --- a/server/campaigns/campaign_handler.coffee +++ /dev/null @@ -1,10 +0,0 @@ -Campaign = require('./Campaign') -Handler = require('../commons/Handler') - -CampaignHandler = class CampaignHandler extends Handler - modelClass: Campaign - editableProperties: ['name', 'description', 'levels'] - - - -module.exports = new CampaignHandler() \ No newline at end of file diff --git a/server/campaigns/campaign_status_handler.coffee b/server/campaigns/campaign_status_handler.coffee deleted file mode 100644 index f9b93e5c2..000000000 --- a/server/campaigns/campaign_status_handler.coffee +++ /dev/null @@ -1,13 +0,0 @@ -CampaignStatus = require('./CampaignStatus') -Handler = require('../commons/Handler') - -CampaignStatusHandler = class CampaignStatusHandler extends Handler - modelClass: CampaignStatus - editableProperties: ['levelStatuses'] - postEditableProperties: ['campaign', 'user'] - - post: (req, res) -> - req.body.user = req.user._id - super(req, res) - -module.exports = new CampaignStatusHandler() diff --git a/server/commons/mapping.coffee b/server/commons/mapping.coffee index a26717b58..0a74baa04 100644 --- a/server/commons/mapping.coffee +++ b/server/commons/mapping.coffee @@ -1,12 +1,8 @@ module.exports.handlers = 'article': 'articles/article_handler' - 'campaign': 'campaigns/campaign_handler' - 'campaign_status': 'campaigns/campaign_status_handler' - 'file': 'files/file_handler' 'level': 'levels/level_handler' 'level_component': 'levels/components/level_component_handler' - 'level_draft': 'levels/drafts/level_draft_handler' 'level_feedback': 'levels/feedbacks/level_feedback_handler' 'level_session': 'levels/sessions/level_session_handler' 'level_system': 'levels/systems/level_system_handler' @@ -16,7 +12,6 @@ module.exports.handlers = module.exports.schemas = 'article': 'articles/article_schema' 'common': 'commons/schemas' -#'file': 'files/file_schema' 'i18n': 'commons/i18n_schema' 'level': 'levels/level_schema' 'level_component': 'levels/components/level_component_schema' @@ -38,4 +33,4 @@ module.exports.routes = 'routes/languages' 'routes/mail' 'routes/sprites' - ] \ No newline at end of file + ] diff --git a/server/files/File.coffee b/server/files/File.coffee deleted file mode 100644 index 1ec779271..000000000 --- a/server/files/File.coffee +++ /dev/null @@ -1,8 +0,0 @@ -mongoose = require('mongoose') -plugins = require('../plugins/plugins') - -FileSchema = new mongoose.Schema() - -FileSchema.plugin(plugins.SearchablePlugin, {searchable: ['metadata.description', 'metadata.name']}) - -module.exports = mongoose.model('media.files', FileSchema) diff --git a/server/files/file_handler.coffee b/server/files/file_handler.coffee deleted file mode 100644 index 3cf067081..000000000 --- a/server/files/file_handler.coffee +++ /dev/null @@ -1,13 +0,0 @@ -File = require('./File') -Handler = require('../commons/Handler') - -FileHandler = class FileHandler extends Handler - modelClass: File - editableProperties: ['metadata'] - - hasAccess: (req) -> - req.method is 'GET' - -# TODO: once we're building the clients, need special GET handler, search handler - -module.exports = new FileHandler() diff --git a/server/files/file_schema.coffee b/server/files/file_schema.coffee deleted file mode 100644 index 2967890f3..000000000 --- a/server/files/file_schema.coffee +++ /dev/null @@ -1,25 +0,0 @@ -c = require '../commons/schemas' - -FileSchema = c.baseSchema() - -_.extend(FileSchema.properties, { - filename: c.shortStringProp() - contentType: c.shortStringProp() - length: { type: 'number' } - chunkSize: { type: 'number', format: 'hidden' } - uploadDate: { type: 'string' } - aliases: {} - metadata: - type: 'object' - additionalProperties: false - name: c.shortStringArrayProp() - description: { type: 'string' } - createdFor: { type: 'array', items: {}} - path: { type: 'string' } - creator: { type: 'string' } -}) - -c.extendSearchableProperties(FileSchema.properties.metadata) -FileSchema.format = 'file' - -module.exports = FileSchema \ No newline at end of file diff --git a/server/levels/drafts/LevelDraft.coffee b/server/levels/drafts/LevelDraft.coffee deleted file mode 100644 index c5e265642..000000000 --- a/server/levels/drafts/LevelDraft.coffee +++ /dev/null @@ -1,9 +0,0 @@ -mongoose = require('mongoose') -Level = require('../Level') - -LevelDraftSchema = new mongoose.Schema( - user: {type: mongoose.Schema.ObjectId, ref: 'User'} - level: {} -) - -module.exports = LevelDraft = mongoose.model('level.draft', LevelDraftSchema) \ No newline at end of file diff --git a/server/levels/drafts/level_draft_handler.coffee b/server/levels/drafts/level_draft_handler.coffee deleted file mode 100644 index 2b4c1532d..000000000 --- a/server/levels/drafts/level_draft_handler.coffee +++ /dev/null @@ -1,13 +0,0 @@ -LevelDraft = require('./LevelDraft') -Handler = require('../../commons/Handler') - -LevelDraftHandler = class LevelDraftHandler extends Handler - modelClass: LevelDraft - editableProperties: ['level'] - postEditableProperties: ['user'] - - post: (req, res) -> - req.body.user = req.user._id - super(req, res) - -module.exports = new LevelDraftHandler() \ No newline at end of file diff --git a/test/server/common.coffee b/test/server/common.coffee index 5ba7551dd..16f0982bc 100644 --- a/test/server/common.coffee +++ b/test/server/common.coffee @@ -10,12 +10,9 @@ path = require('path') models_path = [ '../../server/articles/Article' - '../../server/campaigns/Campaign' - '../../server/campaigns/CampaignStatus' '../../server/levels/Level' '../../server/levels/components/LevelComponent' '../../server/levels/systems/LevelSystem' - '../../server/levels/drafts/LevelDraft' '../../server/levels/sessions/LevelSession' '../../server/levels/thangs/LevelThangType' '../../server/users/User' diff --git a/test/server/functional/campaign.spec.coffee b/test/server/functional/campaign.spec.coffee deleted file mode 100644 index 8f6cb6a5c..000000000 --- a/test/server/functional/campaign.spec.coffee +++ /dev/null @@ -1,42 +0,0 @@ -require '../common' - -describe '/db/campaign', -> - request = require 'request' - it 'clears the db first', (done) -> - clearModels [User, Campaign], (err) -> - throw err if err - done() - - campaign = {name: 'A', description:'B'} - url = getURL('/db/campaign') - campaigns = {} - - it 'allows making Campaigns.', (done) -> - loginJoe (user) -> - campaign.permissions = [access: 'owner', target: user._id] - request.post {uri:url, json:campaign}, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.permissions).toBeDefined() - campaigns[0] = body - done() - - it 'does not allow other users access', (done) -> - loginSam -> - request.get {uri:url+'/'+campaigns[0]._id}, (err, res, body) -> - expect(res.statusCode).toBe(403) - done() - - it 'allows editing permissions.', (done) -> - loginJoe -> - campaigns[0].permissions.push(access: 'read', target: 'public') - request.put {uri:url, json:campaigns[0]}, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.permissions.length).toBe(2) - campaigns[0] = body - done() - - it 'allows anyone to access it through public permissions', (done) -> - loginSam -> - request.get {uri:url+'/'+campaigns[0]._id}, (err, res, body) -> - expect(res.statusCode).toBe(200) - done() diff --git a/test/server/functional/campaign_status.spec.coffee b/test/server/functional/campaign_status.spec.coffee deleted file mode 100644 index db8edaf5d..000000000 --- a/test/server/functional/campaign_status.spec.coffee +++ /dev/null @@ -1,21 +0,0 @@ -require '../common' - -describe '/db/campaign_status', -> - request = require 'request' - it 'clears the db first', (done) -> - clearModels [Campaign, CampaignStatus], (err) -> - throw err if err - done() - - user = new User(name:'sup') - campaign = new Campaign(name:'Project Vengeance.', permissions: simplePermissions) - stat = {campaign: campaign._id, user: user._id} - url = getURL('/db/campaign_status') - - it 'can make a CampaignStatus, and ignores the user property given.', (done) -> - loginJoe (joe) -> - request.post {uri:url, json:stat}, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.user).toBe(joe._id.toString()) - expect(body.user).not.toBe(user._id.toString()) - done() diff --git a/test/server/functional/level_draft.spec.coffee b/test/server/functional/level_draft.spec.coffee deleted file mode 100644 index 006cdb787..000000000 --- a/test/server/functional/level_draft.spec.coffee +++ /dev/null @@ -1,23 +0,0 @@ -require '../common' - -describe '/db/campaign_draft', -> - - draft = { - level: {} - user: 'yoyoyo' - } - - request = require 'request' - it 'clears the db first', (done) -> - clearModels [LevelDraft], (err) -> - throw err if err - done() - - url = getURL('/db/level_draft') - - it 'can make a LevelDraft, and ignores the user property given.', (done) -> - loginJoe (joe) -> - request.post {uri:url, json:draft}, (err, res, body) -> - expect(res.statusCode).toBe(200) - expect(body.user).toBe(joe._id.toString()) - done() \ No newline at end of file diff --git a/test/server/integration/models/CampaignStatus.spec.coffee b/test/server/integration/models/CampaignStatus.spec.coffee deleted file mode 100644 index 8a6b64c66..000000000 --- a/test/server/integration/models/CampaignStatus.spec.coffee +++ /dev/null @@ -1,34 +0,0 @@ -require '../../common' - -describe 'CampaignStatus', -> - - user = new User(name:'sup') - campaign = new Campaign(name:'Project Vengeance.', permissions: simplePermissions) - stat = new CampaignStatus(user: user._id, campaign: campaign._id) - - it 'clears things first', (done) -> - clearModels [User, Campaign, CampaignStatus], (err) -> - expect(err).toBeNull() - done() - - it 'can be saved', (done) -> - saveModels [user, campaign, stat], (err) -> - expect(err).toBeNull() - done() - - it 'can populate', (done) -> - CampaignStatus - .findOne({_id:stat._id}) - .populate('user') - .populate('campaign') - .exec (err, c) -> - expect(err).toBe(null) - expect(c.user.get('name')).toBeDefined() - expect(c.campaign.get('name')).toBeDefined() - done() - - it 'rejects duplicates', (done) -> - stat2 = new CampaignStatus(user: user._id, campaign: campaign._id) - stat2.save (err) -> - expect(err).not.toBe(null) - done() diff --git a/test/server/integration/models/LevelDraft.spec.coffee b/test/server/integration/models/LevelDraft.spec.coffee deleted file mode 100644 index 07b5c7a50..000000000 --- a/test/server/integration/models/LevelDraft.spec.coffee +++ /dev/null @@ -1,31 +0,0 @@ -require '../../common' - -describe 'LevelDraft', -> - - level = new Level( - name: "King's Peak Redux" - description: 'Climb a mountain.' - permissions: simplePermissions - original: new ObjectId() - ) - - it 'clears things first', (done) -> - clearModels [Level, LevelDraft], (err) -> - expect(err).toBeNull() - done() - - it 'saves', (done) -> - level.save (err) -> - throw err if err - - draft = new LevelDraft( - user: new ObjectId() - level: level - ) - - draft.save (err) -> - throw err if err - - LevelDraft.findOne {_id:draft._id}, (err, fetched) -> - expect(fetched.level.original).toBeDefined() - done() diff --git a/test/server/integration/models/campaign.spec.coffee b/test/server/integration/models/campaign.spec.coffee deleted file mode 100644 index 68c9e3d12..000000000 --- a/test/server/integration/models/campaign.spec.coffee +++ /dev/null @@ -1,26 +0,0 @@ -require '../../common' - -describe 'Campaign', -> - - raw = - name:'Battlefield 1942' - description:'Vacation all over the world!' - levels: [] - permissions:[ - target:'not_the_public' - access:'owner' - ] - - campaign = new Campaign(raw) - - it 'clears things first', (done) -> - Campaign.remove {}, (err) -> - expect(err).toBeNull() - done() - - it 'can be saved', (done) -> - campaign.save (err) -> - expect(err).toBeNull() - done() - - diff --git a/test/server/integration/models/plugins.spec.coffee b/test/server/integration/models/plugins.spec.coffee index 0c436a7e1..b01c74ef5 100644 --- a/test/server/integration/models/plugins.spec.coffee +++ b/test/server/integration/models/plugins.spec.coffee @@ -328,27 +328,3 @@ describe 'SearchablePlugin', -> target:'not_the_public' access:'owner' ] - - campaign = new Campaign(raw) - - it 'clears things first', (done) -> - Campaign.remove {}, (err) -> - expect(err).toBeNull() - done() - - it 'hides private entities from public searches', (done) -> - campaign.save (err) -> - throw err if err - done() - - Campaign.textSearch 'battlefield', {filter:{ index: true}}, (err, results) -> - expect(results.results.length).toBe(0) - done() - - it 'allows private searches for owning users', (done) -> - campaign.save (err) -> - throw err if err - - Campaign.textSearch 'battlefield', {filter: { index: 'not_the_public' }}, (err, results) -> - expect(results.results.length).toBeGreaterThan(0) - done()