diff --git a/Pearlception/app/assets/javascripts/grades.coffee b/Pearlception/app/assets/javascripts/grades.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/Pearlception/app/assets/javascripts/grades.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/Pearlception/app/assets/stylesheets/grades.scss b/Pearlception/app/assets/stylesheets/grades.scss new file mode 100644 index 0000000..ba73e1a --- /dev/null +++ b/Pearlception/app/assets/stylesheets/grades.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the grades controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/Pearlception/app/controllers/grades_controller.rb b/Pearlception/app/controllers/grades_controller.rb new file mode 100644 index 0000000..2d197f1 --- /dev/null +++ b/Pearlception/app/controllers/grades_controller.rb @@ -0,0 +1,11 @@ +class GradesController < ApplicationController + before_filter :deny_to_visitors + + def index + @grades = Grade.all + end + + def deny_to_visitors + redirect_to "/signin" unless user_signed_in? && !current_user.admin? + end +end diff --git a/Pearlception/app/helpers/grades_helper.rb b/Pearlception/app/helpers/grades_helper.rb new file mode 100644 index 0000000..5514f32 --- /dev/null +++ b/Pearlception/app/helpers/grades_helper.rb @@ -0,0 +1,2 @@ +module GradesHelper +end diff --git a/Pearlception/app/models/user.rb b/Pearlception/app/models/user.rb index 4b7680d..486d2eb 100644 --- a/Pearlception/app/models/user.rb +++ b/Pearlception/app/models/user.rb @@ -7,9 +7,7 @@ class User < ApplicationRecord :recoverable, :rememberable, :trackable, :validatable def after_database_authentication - binding.pry if !self.admin - binding.pry Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,'')) end end diff --git a/Pearlception/app/views/companies/index.html.erb b/Pearlception/app/views/companies/index.html.erb index b505cdf..48197a8 100644 --- a/Pearlception/app/views/companies/index.html.erb +++ b/Pearlception/app/views/companies/index.html.erb @@ -39,9 +39,7 @@ <% if current_user.admin? %>
  • Companies
  • <% else %> -
  • Reports
  • -
  • Analytics
  • -
  • Export
  • + <% end %> diff --git a/Pearlception/app/views/grades/index.html.erb b/Pearlception/app/views/grades/index.html.erb new file mode 100644 index 0000000..51f2325 --- /dev/null +++ b/Pearlception/app/views/grades/index.html.erb @@ -0,0 +1,149 @@ +<%= stylesheet_link_tag "dashboard" %>_ + + + + +
    +
    + +
    +

    Grades

    +

    Total Grades: <%= @grades.count %>

    +
    + <%= link_to(new_grade_path, :method => :get) do %> + Add a New Grade + <% end %> + + + + + + + + + + + + + + + <% if @grades.empty? %> +
    Grade NameMin VolumeMax VolumeMin LengthMax LengthMin WidthMax WidthMin HeightMax Height
    +
    +

    No Grades Recorded.

    +
    + <% else %> + + <% @grades.each_slice(1) do |row| %> + + <% row.each do |grade|%> + + + + <%= grade.Full_name %> + + + + + <%= grade.Volume_min %> + + + + + <%= grade.Volume_max %> + + + + + <%= grade.Length_min %> + + + + + <%= grade.Length_max %> + + + + + <%= grade.Width_min %> + + + + + <%= grade.Width_max %> + + + + + <%= grade.Height_min %> + + + + + <%= grade.Height_max %> + + <% end %> + + <% end %> + + + <% end %> +
    +
    +
    +
    + <%= javascript_include_tag "bootstrap.min" %>_ + diff --git a/Pearlception/config/routes.rb b/Pearlception/config/routes.rb index 7c9b104..d958c2f 100644 --- a/Pearlception/config/routes.rb +++ b/Pearlception/config/routes.rb @@ -6,6 +6,7 @@ Rails.application.routes.draw do root "dashboard#index" resources :runs resources :companies + resources :grades devise_for :users, :controllers => {:registrations => 'registrations'} devise_scope :users do diff --git a/Pearlception/test/controllers/grades_controller_test.rb b/Pearlception/test/controllers/grades_controller_test.rb new file mode 100644 index 0000000..f9c6a0e --- /dev/null +++ b/Pearlception/test/controllers/grades_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class GradesControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end