Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Commit

Permalink
mongodb removed
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelatorrelabs committed Mar 4, 2014
1 parent e6aebab commit 8362945
Show file tree
Hide file tree
Showing 35 changed files with 328 additions and 922 deletions.
3 changes: 0 additions & 3 deletions app/controllers/experiments.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Experiment = mongoose.model('Experiment'),
_ = require('underscore');

/**
* Find article by id
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
_ = require('underscore');


exports.render = function(req, res) {
res.render('index', {
user: req.user ? JSON.stringify(req.user) : "null"
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/users.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
User = mongoose.model('User');

/**
* Auth callback
Expand Down
188 changes: 0 additions & 188 deletions app/models/experiments.js
Original file line number Diff line number Diff line change
@@ -1,188 +0,0 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
config = require('../../config/config'),
Schema = mongoose.Schema;


/**
* Experiment Schema
*/
var ExperimentSchema = new Schema({
created: {
type: Date,
default: Date.now
},
EXPERIMENT_ID: {
type: String,
default: '',
trim: true
},
STUDY_ID: {
type: String,
default: '',
trim: true
},
STUDY_NAME: {
type: String,
default: '',
trim: true
},
CENTER_NAME: {
type: String,
default: '',
trim: true
},
FIRST_SUBMISSION_DATE: {
type: String,
default: '',
trim: true
},
SEQ_RUNS_COUNT: {
type: String,
default: '',
trim: true
},
SAMPLE_ID: {
type: String,
default: '',
trim: true
},
SAMPLE_NAME: {
type: String,
default: '',
trim: true
},
INSTRUMENT_PLATFORM: {
type: String,
default: '',
trim: true
},
INSTRUMENT_MODEL: {
type: String,
default: '',
trim: true
},
LIBRARY_NAME: {
type: String,
default: '',
trim: true
},
LIBRARY_LAYOUT: {
type: String,
default: '',
trim: true
},
LIBRARY_STRATEGY: {
type: String,
default: '',
trim: true
},
EXPERIMENT_TYPE: {
type: String,
default: '',
trim: true
},
DISEASE: {
type: String,
default: '',
trim: true
},
BIOMATERIAL_PROVIDER: {
type: String,
default: '',
trim: true
},
BIOMATERIAL_TYPE: {
type: String,
default: '',
trim: true
},
CELL_TYPE: {
type: String,
default: '',
trim: true
},
SPECIMEN_PROCESSING: {
type: String,
default: '',
trim: true
},
SPECIMEN_STORAGE: {
type: String,
default: '',
trim: true
},
READ_QUALITIES: {
type: String,
default: '',
trim: true
},
MOLECULE: {
type: String,
default: '',
trim: true
},
RUN_ID: {
type: String,
default: '',
trim: true
},
READ_COUNT: {
type: String,
default: '',
trim: true
},
BASE_COUNT: {
type: String,
default: '',
trim: true
},
READ_LENGTH: {
type: String,
default: '',
trim: true
},
FILE: {
type: String,
default: '',
trim: true
},
WITHDRAWN: {
type: String,
default: '',
trim: true
},
TYPE: {
type: String,
default: '',
trim: true
},
FILE_MD5: {
type: String,
default: '',
trim: true
},
FILE_SIZE: {
type: String,
default: '',
trim: true
},
SUBMISSION_ID: {
type: String,
default: '',
trim: true
},
RUN_NAME: {
type: String,
default: '',
trim: true
},
user: {
type: Schema.ObjectId,
ref: 'User'
}
});

mongoose.model('Experiment', ExperimentSchema);
120 changes: 1 addition & 119 deletions app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,124 +1,6 @@
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
crypto = require('crypto'),
var crypto = require('crypto'),
_ = require('underscore'),
authTypes = ['github', 'twitter', 'facebook', 'google'];


/**
* User Schema
*/
var UserSchema = new Schema({
name: String,
email: String,
username: {
type: String,
unique: true
},
provider: String,
hashed_password: String,
salt: String,
facebook: {},
twitter: {},
github: {},
google: {}
});

/**
* Virtuals
*/
UserSchema.virtual('password').set(function(password) {
this._password = password;
this.salt = this.makeSalt();
this.hashed_password = this.encryptPassword(password);
}).get(function() {
return this._password;
});

/**
* Validations
*/
var validatePresenceOf = function(value) {
return value && value.length;
};

// the below 4 validations only apply if you are signing up traditionally
UserSchema.path('name').validate(function(name) {
// if you are authenticating by any of the oauth strategies, don't validate
if (authTypes.indexOf(this.provider) !== -1) return true;
return name.length;
}, 'Name cannot be blank');

UserSchema.path('email').validate(function(email) {
// if you are authenticating by any of the oauth strategies, don't validate
if (authTypes.indexOf(this.provider) !== -1) return true;
return email.length;
}, 'Email cannot be blank');

UserSchema.path('username').validate(function(username) {
// if you are authenticating by any of the oauth strategies, don't validate
if (authTypes.indexOf(this.provider) !== -1) return true;
return username.length;
}, 'Username cannot be blank');

UserSchema.path('hashed_password').validate(function(hashed_password) {
// if you are authenticating by any of the oauth strategies, don't validate
if (authTypes.indexOf(this.provider) !== -1) return true;
return hashed_password.length;
}, 'Password cannot be blank');


/**
* Pre-save hook
*/
UserSchema.pre('save', function(next) {
if (!this.isNew) return next();

if (!validatePresenceOf(this.password) && authTypes.indexOf(this.provider) === -1)
next(new Error('Invalid password'));
else
next();
});

/**
* Methods
*/
UserSchema.methods = {
/**
* Authenticate - check if the passwords are the same
*
* @param {String} plainText
* @return {Boolean}
* @api public
*/
authenticate: function(plainText) {
return this.encryptPassword(plainText) === this.hashed_password;
},

/**
* Make salt
*
* @return {String}
* @api public
*/
makeSalt: function() {
return Math.round((new Date().valueOf() * Math.random())) + '';
},

/**
* Encrypt password
*
* @param {String} password
* @return {String}
* @api public
*/
encryptPassword: function(password) {
if (!password) return '';
return crypto.createHmac('sha1', this.salt).update(password).digest('hex');
}
};

mongoose.model('User', UserSchema);
7 changes: 6 additions & 1 deletion app/views/includes/foot.jade
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ script(type='text/javascript', src='/lib/angular-ui-router/release/angular-ui-ro
script(type='text/javascript', src='/js/elasticjs/elastic.min.js')
script(type='text/javascript', src='/js/elasticjs/elastic-angular-client.min.js')

//Tree directive
script(type='text/javascript', src='/js/abn_tree_directive.js')

//Application Init
script(type='text/javascript', src='/js/app.js')
script(type='text/javascript', src='/js/config.js')
Expand All @@ -32,9 +35,11 @@ script(type='text/javascript', src='/js/controllers/analyses_dnaseq_reads.js')
script(type='text/javascript', src='/js/controllers/file_types.js')
script(type='text/javascript', src='/js/controllers/experiment_types.js')
script(type='text/javascript', src='/js/controllers/institutions.js')
script(type='text/javascript', src='/js/controllers/patients.js')
script(type='text/javascript', src='/js/controllers/donors_results.js')
script(type='text/javascript', src='/js/controllers/samples_results.js')
script(type='text/javascript', src='/js/controllers/variants.js')
script(type='text/javascript', src='/js/controllers/genes.js')
script(type='text/javascript', src='/js/controllers/hpos.js')
script(type='text/javascript', src='/js/controllers/orphanets.js')
script(type='text/javascript', src='/js/controllers/omims.js')
script(type='text/javascript', src='/js/controllers/icd10s.js')
Expand Down
1 change: 1 addition & 0 deletions app/views/includes/head.jade
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ head
link(rel='stylesheet', href='/skins/blue.css')
link(rel='stylesheet', href='/css/cslider.css')
link(rel='stylesheet', href='/css/nv.d3.css')
link(rel='stylesheet', href='/css/abn_tree.css')
link(rel='stylesheet', href='/css/custom.css')

link(rel='stylesheet', href='/css/views/articles.css')
Expand Down
1 change: 0 additions & 1 deletion config/env/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ rootPath = path.normalize(__dirname + '/../..');
module.exports = {
root: rootPath,
port: process.env.PORT || 3000,
db: process.env.MONGOHQ_URL
}
1 change: 0 additions & 1 deletion config/env/development.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
db: "mongodb:https://localhost/dataportal-dev",
app: {
name: "Dataportal. An integrated platform connecting databases, registries, biobanks and clinical bioinformatics"
},
Expand Down
1 change: 0 additions & 1 deletion config/env/production.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
db: "mongodb:https://localhost/dataportal",
app: {
name: "Dataportal. An integrated platform connecting databases, registries, biobanks and clinical bioinformatics"
},
Expand Down
Loading

0 comments on commit 8362945

Please sign in to comment.