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 @@ Last Name Email Admin Status - Delete + Delete? <% @advisors.each do |advisor| %> @@ -15,11 +15,17 @@ <%= advisor.email %> <%= advisor_status(advisor) %> + <%= advisor_deletion(advisor) %> <% end %> - + + +Add new admin or advisor + + + diff --git a/app/views/angular_app/index.html.erb b/app/views/angular_app/index.html.erb index 2215700..8dc5ee2 100644 --- a/app/views/angular_app/index.html.erb +++ b/app/views/angular_app/index.html.erb @@ -1,4 +1,4 @@ +
-
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index a6adcea..29b00a7 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,4 +1,4 @@ -

Edit <%= resource_name.to_s.humanize %>

+

Edit Your Account

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= devise_error_messages! %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 9deaaf9..e6ec54e 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,4 +1,4 @@ -

Sign up

+

Add An Advisor

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> @@ -37,8 +37,10 @@
- <%= f.submit "Sign up" %> + <%= f.submit "Create Advisor" %>
<% end %> <%= render "devise/shared/links" %> + +<%= link_to "Back", :back %> diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 5cc7e44..9cad183 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,11 +1,3 @@ -<%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
-<% end -%> - - - <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> <%= link_to "Forgot your password?", new_password_path(resource_name) %>
<% end -%> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e97ed48..b69539c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,7 +9,10 @@ + <%= render 'shared/navbar' %> <%= render "shared/flash" %> - <%= yield %> +
+ <%= yield %> +
diff --git a/app/views/shared/_flash.html.erb b/app/views/shared/_flash.html.erb index 0bff4e8..3a65797 100644 --- a/app/views/shared/_flash.html.erb +++ b/app/views/shared/_flash.html.erb @@ -1,7 +1,9 @@ <% if flash.any? %>
- <% flash.each do |k, v| %> -

<%= v %>

- <% end %> +
+ <% flash.each do |k, v| %> +

<%= v %>

+ <% end %> +
<% end %> \ No newline at end of file diff --git a/app/views/shared/_navbar.html.erb b/app/views/shared/_navbar.html.erb new file mode 100644 index 0000000..151268b --- /dev/null +++ b/app/views/shared/_navbar.html.erb @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index e9a0665..41479e0 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -38,7 +38,7 @@ en: destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." signed_up_as_admin: "Admin successfully added." signed_up_as_advisor: "Advisor successfully added." - signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_inactive: "Advisor successfully signed up. However, we could not sign advisor in because their account is not yet activated." signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." diff --git a/config/routes.rb b/config/routes.rb index 1696dd8..75e2d55 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,8 @@ get 'advisors/sign_out', to: 'advisors/sessions#destroy' end + resources :advisors, only: [:index, :update, :destroy] + scope :api do scope :v1 do resources :students @@ -19,6 +21,6 @@ get 'angular_app/index' - resources :advisors, only: [:index, :update, :destroy] + end diff --git a/public/templates/dashboard-header.html b/public/templates/dashboard-header.html index 2380b25..c1ce1bf 100644 --- a/public/templates/dashboard-header.html +++ b/public/templates/dashboard-header.html @@ -1,15 +1,9 @@ +
-

Welcome, admin_name!

+

Dashboard

-

Sign Out

-

Edit my account settings

+ Students + Classes + Advisors -
-

Add new admin or advisor

-

View advisors

- -

Dashboard

- -Students -Classes diff --git a/public/templates/dashboard-main.html b/public/templates/dashboard-main.html index 6e72b29..31800c0 100644 --- a/public/templates/dashboard-main.html +++ b/public/templates/dashboard-main.html @@ -1,2 +1 @@ -Dashboard-main
diff --git a/spec/features/advisor_spec.rb b/spec/features/advisor_spec.rb index eedc41f..654f0e4 100644 --- a/spec/features/advisor_spec.rb +++ b/spec/features/advisor_spec.rb @@ -192,16 +192,16 @@ end scenario 'it deletes the advisor', js: true do - expect{ click_on('Delete Advisor?') }.to change(Advisor, :count).by(-1) + expect{ click_on('Delete') }.to change(Advisor, :count).by(-1) end scenario 'it renders a flash message', js: true do - click_on('Delete Advisor?') + click_on('Delete') expect(page).to have_css('#flash') end scenario 'it remains on the advisors index page', js: true do - click_on('Delete Advisor?') + click_on('Delete') expect(current_path).to eq(advisors_path) end @@ -216,8 +216,11 @@ click_on('View advisors') end - scenario 'it does not display a delete link', js: true do - expect(page).to_not have_content('Delete Advisor?') + scenario 'it does not display a delete link', js: true, test_me: true do + + within(:css, "td:last-child") do + expect(page).to_not have_content('Delete') + end end end