Skip to content
This repository has been archived by the owner on Dec 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #45 from xiaods/master
Browse files Browse the repository at this point in the history
add travis ci tracker
  • Loading branch information
xiaods committed Jul 23, 2014
2 parents 88cf029 + 5206539 commit c653cc7
Show file tree
Hide file tree
Showing 8 changed files with 549 additions and 500 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js
node_js:
- "0.10"
services:
- mongodb
before_install: npm install -g grunt-cli
install: npm install
before_script:
- "export PHANTOMJS_EXECUTABLE='phantomjs --local-to-remote-url-access=yes --ignore-ssl-errors=yes'"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "grunt default"
- "cp settings.json.example settings.json"
script:
- "DISPLAY=:99.0 grunt test"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ used as internal productivity tool in [Red Hat](https://www.redhat.com/).
This we believe, is a great open source project for
learning HTML5/Nodejs/socket.io/backbone.js technology.

[![Build Status](https://travis-ci.org/onepiecejs/nodejs-cantas.svg?branch=master)](http://travis-ci.org/onepiecejs/nodejs-cantas)

Thanks for [all Contributors](AUTHORS.md)

![project screenshot](./public/images/cantas-help-list.gif)
Expand Down
206 changes: 103 additions & 103 deletions models/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@
"use strict";

var mongoose = require('mongoose'),
Mailer = require('../services/mail'),
List = require('./list'),
Activity = require("./activity"),
User = require("./user"),
BoardMemberRelation = require('./boardMemberRelation'),
Notification = require("../services/notification"),
BoardMemberStatus = require("./boardMemberStatus"),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
async = require('async'),
Sites = require("../services/sites"),
LogActivity = require("../services/activity").Activity,

BoardSchema = new Schema({
title: { type: String, required: true },
description: { type: String, default: '' },
isClosed: { type: Boolean, default: false },
updated: { type: Date, default: Date.now },
created: { type: Date, default: Date.now },
creatorId: { type: ObjectId, required: true, ref: 'User', index: true },
groupId: { type: ObjectId, index: true },
isPublic: {type: Boolean, default: true},
voteStatus: {type: String, default: 'enabled'},
commentStatus: {type: String, default: 'enabled'},
perms: {
delete: {
users: [ ObjectId ],
roles: [ ObjectId ]
},
update: {
users: [ ObjectId ],
roles: [ ObjectId ]
}
Mailer = require('../services/mail'),
List = require('./list'),
Activity = require("./activity"),
User = require("./user"),
BoardMemberRelation = require('./boardMemberRelation'),
Notification = require("../services/notification"),
BoardMemberStatus = require("./boardMemberStatus"),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
async = require('async'),
Sites = require("../services/sites"),
LogActivity = require("../services/activity").Activity,

BoardSchema = new Schema({
title: { type: String, required: true },
description: { type: String, default: '' },
isClosed: { type: Boolean, default: false },
updated: { type: Date, default: Date.now },
created: { type: Date, default: Date.now },
creatorId: { type: ObjectId, required: true, ref: 'User', index: true },
groupId: { type: ObjectId, index: true },
isPublic: {type: Boolean, default: true},
voteStatus: {type: String, default: 'enabled'},
commentStatus: {type: String, default: 'enabled'},
perms: {
delete: {
users: [ ObjectId ],
roles: [ ObjectId ]
},
update: {
users: [ ObjectId ],
roles: [ ObjectId ]
}
});
}
});

BoardSchema.pre('save', function(next) {
this.updated = new Date();
Expand Down Expand Up @@ -67,81 +67,81 @@
*/
BoardSchema.statics.joinBoard = function (user, boardId, socket, callback) {
var that = this,
result = null;
result = null;

async.waterfall([
function (callback) {
that.findById(boardId,
"_id isPublic creatorId isClosed",
function (err, board) {
if (err || board === null) {
result = {ok: 1, message: 'no valid board'};
return callback(result, null);
}
callback(null, board);
});
},
function (board, callback) {
if (user === null) {
result = {ok: 1, message: 'no user defined'};
return callback(result, null);
}
if (board.isClosed) {
result = {ok: 1, message: 'closed', board: board};
that.findById(boardId,
"_id isPublic creatorId isClosed",
function (err, board) {
if (err || board === null) {
result = {ok: 1, message: 'no valid board'};
return callback(result, null);
}
callback(null, board);
});
},
function (board, callback) {
if (user === null) {
result = {ok: 1, message: 'no user defined'};
return callback(result, null);
}
if (board.isClosed) {
result = {ok: 1, message: 'closed', board: board};
return callback(result, null);
}
board.getMemberStatus(user._id, function (err, status) {
if (err) {
result = {ok: 1, message: 'getMemberStatus failed'};
return callback(result, null);
}
board.getMemberStatus(user._id, function (err, status) {
if (err) {
result = {ok: 1, message: 'getMemberStatus failed'};
return callback(result, null);
}

if (status === BoardMemberStatus.inviting) {
//update user status
board.confirmInvitation(user._id, function (err, obj) {
if (err) {
result = {ok: 1, message: 'confirmInvitation failed'};
return callback(result, null);
}
var content = user.username + ' has accepted invitation and joined the board.';
var activity = new LogActivity({socket: socket, exceptMe: false});
activity.log({
content: content,
creatorId: user._id,
boardId: board._id
});

callback(null, board);

if (status === BoardMemberStatus.inviting) {
//update user status
board.confirmInvitation(user._id, function (err, obj) {
if (err) {
result = {ok: 1, message: 'confirmInvitation failed'};
return callback(result, null);
}
var content = user.username + ' has accepted invitation and joined the board.';
var activity = new LogActivity({socket: socket, exceptMe: false});
activity.log({
content: content,
creatorId: user._id,
boardId: board._id
});
} else {
//redirect to next callback

callback(null, board);
}
});
},
function (board, callback) {
BoardMemberRelation.isBoardMember(user._id, boardId, function (err, memberStatus) {
if (err) {
result = {ok: 1, message: 'isBoardMember failed'};
return callback(result, null);
}
callback(null, board, memberStatus);
});
},
function (board, memberStatus, callback) {
if (board.creatorId.equals(user._id) ||
memberStatus === true) {
result = {ok: 0, message: 'isMember', board: board};
callback(null, result);
} else if (board.isPublic === true && memberStatus === false) {
result = {ok: 0, message: 'normal', board: board};
callback(null, result);
});
} else {
//private board without member relation, you can't login
result = {ok: 1, message: 'nologin', board: board};
//redirect to next callback
callback(null, board);
}
});
},
function (board, callback) {
BoardMemberRelation.isBoardMember(user._id, boardId, function (err, memberStatus) {
if (err) {
result = {ok: 1, message: 'isBoardMember failed'};
return callback(result, null);
}
callback(null, board, memberStatus);
});
},
function (board, memberStatus, callback) {
if (board.creatorId.equals(user._id) ||
memberStatus === true) {
result = {ok: 0, message: 'isMember', board: board};
callback(null, result);
} else if (board.isPublic === true && memberStatus === false) {
result = {ok: 0, message: 'normal', board: board};
callback(null, result);
} else {
//private board without member relation, you can't login
result = {ok: 1, message: 'nologin', board: board};
return callback(result, null);
}
}
], function (err, result) {
if (err) {
result = err;
Expand All @@ -154,7 +154,7 @@

/*
* Get a board by Id.
*
*
* Arguments:
* - boardId: the ID that board is retrieving.
* - fields: a string. Which fields are necessary to get. Field names are
Expand All @@ -164,10 +164,10 @@
BoardSchema.statics.getById = function (boardId, fields, callback) {
var _callback = typeof fields === 'function' ? fields : callback;
this
.findById(boardId)
.select(fields)
.populate([{ path: 'creatorId' }, { path: 'members' }])
.exec(_callback);
.findById(boardId)
.select(fields)
.populate([{ path: 'creatorId' }, { path: 'members' }])
.exec(_callback);
};

/*
Expand Down
15 changes: 8 additions & 7 deletions models/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@

CardSchema.pre('save', function(next) {
this.updated = new Date();
next();
});

Board.findOne({ _id: this.boardId }, function(err, board) {
if (!err && board) {
board.updated = new Date();
board.save();
}
});
CardSchema.post('save', function(card) {
card.populate('boardId', function(err) {
if (err) return done(err);

next();
card.boardId.updated = new Date();
card.boardId.save();
});
});

// virtual attributes
Expand Down
Loading

0 comments on commit c653cc7

Please sign in to comment.