Skip to content
This repository has been archived by the owner on Aug 12, 2018. It is now read-only.

Commit

Permalink
notifications done
Browse files Browse the repository at this point in the history
  • Loading branch information
slmyers committed Mar 18, 2016
1 parent ff8312b commit 6ced432
Show file tree
Hide file tree
Showing 16 changed files with 1,095 additions and 253 deletions.
56 changes: 49 additions & 7 deletions backend/app/lib/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,34 +141,75 @@ def self.person_notifications
@supervised_raw = @unapproved_supervisions.where(:supervisor_id => p.id)
.includes(degree: :institution)
.includes(person: :institution)
@supervised = self.supervisors(@supervised_raw)
@supervised = self.supervised(@supervised_raw)

@mentored_raw = @unapproved_mentorships.where(:mentor_id => p.id)
.includes(:institution)
.includes(person: :institution)
@mentored = self.mentors(@mentored_raw)
@mentored = self.mentored(@mentored_raw)

@aggregated_person =
{
'target' => @target,
'mentors' => @mentors,
'mentored' => @mentored,
'supervisors' => @supervisors,
'supervised' => @supervised
'supervised' => @supervised,
'supervisors' => @supervisors
}
@res_array.push(@aggregated_person)
end
return @res_array
end

# helper method used to build mentorships for unnapproved person

# helper method for building the person notification where they
# were supervised
def self.supervisors(unapproved_supervisions)
@supervisions = Array.new

unapproved_supervisions.each do |s|
@supervision_obj = {
'supervision' => s,
'degree' => {
'degree' => s.degree,
'institution' => s.degree.institution
},
'supervisor' => {
'person' => s.supervisor,
'institution' => s.supervisor.institution
}
}
@supervisions.push(@supervision_obj)
end
return @supervisions
end

# helper method used to gather the persons mentors
def self.mentors(unapproved_mentorships)
@mentorships = Array.new
unapproved_mentorships.each do |m|
@mentorships_obj = {
'mentorship' => m,
'instituiton' => m.institution,
'mentor' => {
'person' => m.mentor,
'institution' => m.mentor.institution
}
}
@mentorships.push(@mentorships_obj)
end
return @mentorships
end

# helper method used to build the mentorships where the person was the
# mentor
def self.mentored(unapproved_mentorships)
@mentorships = Array.new
unapproved_mentorships.each do |m|
@mentorships_obj = {
'mentorship' => m,
'instituiton' => m.institution,
'mentored' => {
'person' => m.person,
'institution' => m.person.institution
}
Expand All @@ -179,7 +220,8 @@ def self.mentors(unapproved_mentorships)
end

# helper method used to build supervisions for unapproved person
def self.supervisors(unapproved_supervisions)
# where the person was the supervisor
def self.supervised(unapproved_supervisions)
@supervisions = Array.new

unapproved_supervisions.each do |s|
Expand All @@ -189,7 +231,7 @@ def self.supervisors(unapproved_supervisions)
'degree' => s.degree,
'institution' => s.degree.institution
},
'supervisor' => {
'supervised' => {
'person' => s.person,
'institution' => s.person.institution
}
Expand Down
52 changes: 51 additions & 1 deletion backend/db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{
password: 'admin', email: '[email protected]', password_digest: 'pword',
first_name: 'todd', last_name: 'lowary', approved: true
},
{
password: 'user', email: '[email protected]', password_digest: 'pword',
first_name: 'josh', last_name: 'cameron', approved: true
}
])

Expand Down Expand Up @@ -38,7 +42,7 @@
{name: 'james baddiley', position: nil, institution_id: nil, approved: true},
{name: 'jun liu', position: nil, institution_id: nil, approved: true},
{name: 'clinton ballou', position: nil, institution_id: nil, approved: true},
{name: 'harold jennings', position: nil, institution_id: nil, approved: true}
{name: 'harold jennings', position: nil, institution_id: nil, approved: true} #id=10
])

Degree.create!([
Expand All @@ -63,3 +67,49 @@
{person_id: 4, mentor_id: 10, start: 1971, end: 1973, institution_id: 7, approved: true},
{person_id: 4, mentor_id: 6, start: 1973, end: 1975, institution_id: 1, approved: true}
])

# delete this next data when in production
# this is to test notifications while in development enviroment
Person.create!([
{name: 'Steven Myers', position: 'professor', institution_id: 1, approved: false},
{name: 'steve supervised', position: 'prof', institution_id: 1, approved: true},
{name: "steve's mentor", position: 'professor', institution_id: 1, approved: true},
{name: "steve's mentored", position: 'professor', institution_id: 1, approved: true},
{name: "x mentor", position: "professor", institution_id: 1, approved: true}, #id=15
{name: "mentored by x", position: "professor", institution_id: 1, approved: true},
{name: "y supervisor", position: "professor", institution_id:3, approved: true},
{name: "supervised by y", position: "professor", institution_id: 2, approved: true}
])

Degree.create!([
{year: 2024, institution_id: 1, degree_type: 'phd', approved: false},
{year: 2030, institution_id: 1, degree_type: 'phd', approved: false},
{year: 2050, institution_id: 4, degree_type: 'masters', approved: false}
])

Supervision.create!([
{approved: false, degree_id: 5, person_id: 11, supervisor_id: 1},
{approved: false, degree_id: 6, person_id: 12, supervisor_id: 11},
{approved: false, degree_id: 7, person_id: 18, supervisor_id: 17}
])

Mentorship.create!([
{person_id: 11, mentor_id: 13, start: 2026, end: 2027, institution_id: 1, approved: false},
{person_id: 14, mentor_id: 11, start: 2031, end: 2032, institution_id: 1, approved: false},
{person_id: 16, mentor_id: 15, start:1999, end:2001, institution_id: 2, approved: false}
])

User.create!([
{
password: 'xxx', email: '[email protected]', password_digest: 'pword',
first_name: 'james', last_name: 'brown', approved: false
},
{
password: 'xxx', email: '[email protected]', password_digest: 'pword',
first_name: 'tupac', last_name: 'shakur', approved: true
}
])

Admin.create!([
{user_id: 5, approved: false}
])
224 changes: 15 additions & 209 deletions frontend/web/app/controllers/adminPanelController.js
Original file line number Diff line number Diff line change
@@ -1,210 +1,16 @@
/**
* Controller for the Submission page.
*
* Status: CONTROLLER
* Associated files: submit.html
*
* The submission page is going to be the core of where the users will be able to supply information to begin a new
* page for a given particular user. This page is going to be essentially a massive collection of information that
* we will be inserting into the system.
*
* Things that we're collecting include basic information like:
* -first name
* -last name
* -degree type
* -postdoc postings
* -etc
*
*/


angular.module('chemGeno')

//Stating that this is a controller for this project.
.controller('adminPanelController', ['$scope', 'adminPanelService', '$mdDialog', '$mdMedia', '$location',
function($scope, adminPanelService, $mdDialog, $mdMedia, $location) {

$scope.mockChangesObject = {
//List of all of the changes made in the application.
changesList: [
{
person: 'personname 1',
title: 'title 1',
institution: 'instituttion 1',
postdoc :[{
pdStartYear: 2078, pdSupervisor: "the cheese goddess", pdInstitution: "NeverEverLand", pdEndYear: "0007"
}],

degree:[{
year: "2973", supervisor: "Cheese King", institution: "University of NeverEverLand", type: "Doctorate"

}]
},
{
person: 'onion knight',
title: 'onion knight (of course)',
institution: 'onion knight... academy...?',
postdoc: 'c2',
degree: 'd2',
degree_Supervision: 'e2'
}
],

//List for all newly registered accounts.
newUsersList: [
{
username: "Username1",
password: "Password1",
email: "email1"
},
{
username: "Username2",
password: "Password2",
email: "email2"
},
{
username: "Username3",
password: "Password3",
email: "email3"
}
]


};


/**
* Mock object for what I am sending to the backend from the admin panel page. (INFORMATION.)
*/

$scope.mockReturnObject = {
uniqueID: "10281921", //String? Int? Whatever you guys send me! Returning it for identification.
status: "accepted" //User hit accept button, commit changes.
};

$scope.mockReturnObject2 = {
uniqueID: "991", //String? Int? Whatever you guys send me! Returning it for identification.
status: "rejected" //User hit the reject button, discard changes.
};

/**
* Mock object for what I am sending to the backend from the admin panel page. (USERS.)
*/

$scope.mockReturnObject3 = {
uniqueID: "usr91", //unique identifier
status: "accepted" //accepted the new user
};

$scope.mockReturnObject4 = {
uniqueID: "usr71827818291", //unique identifier
status: "rejected" //rejected the new user
};



$scope.goBackToMain = function(){
$location.path('search'); // path not hash

};

//For information modification requests.
$scope.viewInformationModRequests = false;

$scope.showInformationModRequests = function(){
$scope.viewInformationModRequests = true;
};

$scope.hideInformationModRequests = function(){
$scope.viewInformationModRequests = false;
};

$scope.rejectInformationModRequest = function(item){
console.log("Reject Request made on item" + item);
};

$scope.acceptInformationModRequest = function(item){
console.log("Accept Request made on item" + item);

};


//For new user requests.
$scope.viewNewUserRequests = false;

$scope.showNewUserRequests = function(){
$scope.viewNewUserRequests = true;
};

$scope.hideNewUserRequests = function(){
$scope.viewNewUserRequests = false;
};

$scope.rejectNewUserRequest = function(user){
console.log("Reject Request made on user" + user.username);
};

$scope.acceptNewUserRequest = function(user){
console.log("Accept Request made on user" + user.username);

};



//Attempt at getting a dialogue working to show detailed information...
$scope.status = ' ';
$scope.customFullscreen = $mdMedia('xs') || $mdMedia('sm');
$scope.showAdvanced = function(ev, item) {


var useFullScreen = ($mdMedia('sm') || $mdMedia('xs')) && $scope.customFullscreen;
$mdDialog.show({
controller: DialogController,
templateUrl: '/app/views/adminPanelDetailed.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
fullscreen: useFullScreen
})
.then(function(answer) {
$scope.status = 'You said the information was "' + answer + '".';
}, function() {
$scope.status = 'You cancelled the dialog.';
});
$scope.$watch(function() {
return $mdMedia('xs') || $mdMedia('sm');
}, function(wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};





function DialogController($scope, $mdDialog) {
$scope.leItem = $scope.itemDetailsItem;
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};

}


/**
* Functions that are associated with the detailed administrator page...
*/

//Mock object for right now at this point in time.





}]);
.controller('adminPanelController', ['$scope', 'adminPanelService',
function($scope, adminPanelService) {
$scope.loadData = function() {
var promise = adminPanelService.loadNotifications();
promise.then(function(resp){
$scope.data = resp.data;
console.log($scope.data)
}, function(error){
alert('error loading notifications');
})
};
$scope.loadData();


}]);
Loading

0 comments on commit 6ced432

Please sign in to comment.