Skip to content

Commit

Permalink
Merge pull request #15 from MeeraChandrasekaran/master
Browse files Browse the repository at this point in the history
added views
  • Loading branch information
DavidJDJ committed Oct 4, 2015
2 parents 8e8e8fa + 2f76081 commit ca1e93a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 35 deletions.
20 changes: 15 additions & 5 deletions client/js/homeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ saburiKonnect.controller('homeController', function($scope, $location, NewOrgani

$scope.register = function()
{
NewOrganisationFactory.addOrganisation($scope.organisation);
// console.log($scope.sponsor);
NewOrganisationFactory.addSponsor($scope.sponsor);
};

})
Expand All @@ -328,13 +329,22 @@ saburiKonnect.controller('homeController', function($scope, $location, NewOrgani
$http.post('/login', info).success(function(output){
// callback(output);
if (!output.error) {
$location.path ("/kids")
if(output.status == false){
$location.path ("/kids")
}
else{
$location.path('/newkid')
}
}
});
};
factory.addOrganisation = function(info,callback){
$http.post('/add_organisation', info).success(function(output){
callback(output);
factory.addSponsor = function(info,callback){
// console.log(info);
$http.post('/add_sponsor', info).success(function(output){
if(output.message == 'success'){
$location.path('/static');
}

});
};
return factory;
Expand Down
21 changes: 4 additions & 17 deletions client/partials/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ <h4 class="modal-title" id="myModalLabel">Login</h4>
</div>
<div class="modal-body">
<form>

<label>Email</label>
<input type="text" ng-model="orgLogin.email"><br>
<label>Password</label>
Expand All @@ -210,25 +211,11 @@ <h4 class="modal-title" id="myModalLabel">Register</h4>
</div>
<div class="modal-body">
<label>Name</label>
<input type="text" ng-model="organisation.name"><br>
<label>Description</label>
<input type="text" ng-model="organisation.description"><br>
<label>Address</label>
<input type="text" ng-model="organisation.address"><br>
<label>City</label>
<input type="text" ng-model="organisation.city"><br>
<label>State</label>
<input type="text" ng-model="organisation.state"><br>
<label>Country</label>
<input type="text" ng-model="organisation.country"><br>
<label>Zipcode</label>
<input type="text" ng-model="organisation.zipcode"><br>
<input type="text" ng-model="sponsor.name"><br>
<label>Email</label>
<input type="text" ng-model="organisation.email"><br>
<input type="text" ng-model="sponsor.email"><br>
<label>Password</label>
<input type="password" ng-model="organisation.password"><br>
<label>Contact Number</label>
<input type="text" ng-model="organisation.contact_number">
<input type="password" ng-model="sponsor.password"><br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
Expand Down
1 change: 1 addition & 0 deletions client/partials/static.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h2> Thank you for registering with us. Our team will get back to you in 24 hours </h2>
5 changes: 4 additions & 1 deletion client/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ saburiKonnect.config(function($routeProvider){
title: "Home",
controller: "homeController"
})
.when('/addKid',{
.when('/newkid',{
templateUrl: './partials/newKid.html'
})
.when('/kids',{
templateUrl: './partials/kids.html'
})
.when('/static',{
templateUrl: './partials/static.html'
})
.otherwise('/', {
redirectTo: '/'
})
Expand Down
9 changes: 5 additions & 4 deletions config/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// var Controller = require('./../server/controllers/controller.js');
var kids = require('./../server/controllers/kids.js');
var organisations = require('./../server/controllers/organisations.js');
var sponsors = require('./../server/controllers/sponsors.js');
var express = require('express');
var router = express.Router();

Expand All @@ -15,12 +15,13 @@ module.exports = function(app){
// kids.get_organisations(req,res)
});

app.post('/add_organisation',function(req,res){
organisations.add_organisation(req,res)
app.post('/add_sponsor',function(req,res){
console.log(req.body);
sponsors.add_sponsor(req,res)
});

app.post('/login',function(req,res){
organisations.login(req,res)
sponsors.login(req,res)
});

app.get('/get_kids',function(req,res){
Expand Down
45 changes: 45 additions & 0 deletions server/controllers/sponsors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var mongoose = require('mongoose');
var sponsor = mongoose.model('Sponsor');

module.exports = (function(){
return {
add_sponsor: function(req, res){
console.log(req.body);
var newsponsor = new sponsor(req.body);
newsponsor.save(function(err, result){
if(err){
console.log('error adding');
} else {
console.log('successfully added an sponsor');
res.json({message: 'success'});
}
});
},

login: function(req,res){
sponsor.find({},function(err,results){
if(err){
console.log('error');
}else{
var exists = false;
for(var i=0;i<results.length;i++){
if(results[i].email == req.body.email){
exists = true;
var index = i;
}
}
if (exists) {
console.log("found user");
res.json(results[index])
} else {
console.log("user not found");
res.json({error: true})
}

}
})
}
};
})();


10 changes: 2 additions & 8 deletions server/models/sponsor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var SponsorSchema = new mongoose.Schema({
first_name: String,
last_name : String,
name : String,
email : String,
password : String,
contact_number : Number,
address : String,
city : String,
state : String,
country : String,
zipcode : Number,
status : {type: Boolean, default: false },
created: {type: Date, default: Date.now }

});
Expand Down

0 comments on commit ca1e93a

Please sign in to comment.