diff --git a/app/assets/javascripts/app.js b/app/assets/javascripts/app.js index 2f323ac..0b0de41 100644 --- a/app/assets/javascripts/app.js +++ b/app/assets/javascripts/app.js @@ -20,6 +20,7 @@ planner.run(['$rootScope', function($rootScope){ planner.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise('/students'); $stateProvider + .state('dashboard', { url: '', views: { @@ -32,6 +33,7 @@ planner.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, } } }) + .state('dashboard.students', { url: '/students', resolve: { @@ -49,6 +51,7 @@ planner.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, } } }) + .state('dashboard.meetings', { url: '/classes', views: { @@ -58,4 +61,5 @@ planner.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, } } }); + }]); diff --git a/app/controllers/advisors/registrations_controller.rb b/app/controllers/advisors/registrations_controller.rb index bf58ca1..7fa7fb0 100644 --- a/app/controllers/advisors/registrations_controller.rb +++ b/app/controllers/advisors/registrations_controller.rb @@ -4,6 +4,7 @@ class Advisors::RegistrationsController < Devise::RegistrationsController skip_before_action :require_no_authentication, only: [:new, :create] before_action :require_admin, only: [:new, :create] + before_action :require_current_advisor, only: [:edit] # GET /resource/sign_up def new @@ -30,7 +31,9 @@ def create # Commented Out to Override Devise's Automatic Login Upon Creation # sign_up(resource_name, resource) - respond_with resource, location: after_sign_up_path_for(resource) + redirect_to advisors_path + + # respond_with resource, location: after_sign_up_path_for(resource) else set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}" expire_data_after_sign_in! @@ -44,14 +47,14 @@ def create end # GET /resource/edit - # def edit - # super - # end + def edit + super + end # PUT /resource - # def update - # super - # end + def update + super + end # DELETE /resource # def destroy diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cfb80f2..b669134 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,4 +21,10 @@ def require_admin end end + def require_current_advisor + unless current_advisor.id == params[:id].to_i + redirect_back(fallback_location: root_path) + end + end + end diff --git a/app/views/advisors/_delete_advisor.html.erb b/app/views/advisors/_delete_advisor.html.erb index cd10203..d966e48 100644 --- a/app/views/advisors/_delete_advisor.html.erb +++ b/app/views/advisors/_delete_advisor.html.erb @@ -1 +1 @@ -<%= link_to "Delete Advisor?", advisor_path(advisor), method: :delete, data: { confirm: "Are you sure you want to delete #{ advisor.name }?" } %> \ No newline at end of file +<%= button_to "Delete", advisor_path(advisor), method: :delete, data: { confirm: "Are you sure you want to delete #{ advisor.name }?"} %> \ No newline at end of file diff --git a/app/views/advisors/index.html.erb b/app/views/advisors/index.html.erb index e2a823f..f8a743f 100644 --- a/app/views/advisors/index.html.erb +++ b/app/views/advisors/index.html.erb @@ -6,7 +6,7 @@