mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 11:47:41 +00:00
Grades Tab implemented for Company Users
This commit is contained in:
parent
1156f37b26
commit
15492253da
3
Pearlception/app/assets/javascripts/grades.coffee
Normal file
3
Pearlception/app/assets/javascripts/grades.coffee
Normal file
@ -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/
|
||||||
3
Pearlception/app/assets/stylesheets/grades.scss
Normal file
3
Pearlception/app/assets/stylesheets/grades.scss
Normal file
@ -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/
|
||||||
11
Pearlception/app/controllers/grades_controller.rb
Normal file
11
Pearlception/app/controllers/grades_controller.rb
Normal file
@ -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
|
||||||
2
Pearlception/app/helpers/grades_helper.rb
Normal file
2
Pearlception/app/helpers/grades_helper.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module GradesHelper
|
||||||
|
end
|
||||||
@ -7,9 +7,7 @@ class User < ApplicationRecord
|
|||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
def after_database_authentication
|
def after_database_authentication
|
||||||
binding.pry
|
|
||||||
if !self.admin
|
if !self.admin
|
||||||
binding.pry
|
|
||||||
Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
Apartment::Tenant.switch!(Company.find(self.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -39,9 +39,7 @@
|
|||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<li class="active"><a href="companies#index">Companies</a></li>
|
<li class="active"><a href="companies#index">Companies</a></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><a href="#">Reports</a></li>
|
|
||||||
<li><a href="#">Analytics</a></li>
|
|
||||||
<li><a href="#">Export</a></li>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <ul class="nav nav-sidebar">
|
<!-- <ul class="nav nav-sidebar">
|
||||||
|
|||||||
@ -40,6 +40,7 @@
|
|||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<li><a href="companies#index">Companies</a></li>
|
<li><a href="companies#index">Companies</a></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
<li><a href="grades#index">Grades</a></li>
|
||||||
<!-- <li><a>Reports</a></li>
|
<!-- <li><a>Reports</a></li>
|
||||||
<li><a>Analytics</a></li>
|
<li><a>Analytics</a></li>
|
||||||
<li><a>Export</a></li> -->
|
<li><a>Export</a></li> -->
|
||||||
|
|||||||
149
Pearlception/app/views/grades/index.html.erb
Normal file
149
Pearlception/app/views/grades/index.html.erb
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
<%= stylesheet_link_tag "dashboard" %>_
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="/">Pearlception</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<!-- <li><a href="#">Dashboard</a></li> -->
|
||||||
|
<!-- <li><a href="#">Settings</a></li>
|
||||||
|
<li><a href="#">Profile</a></li>
|
||||||
|
<li><a href="#">Help</a></li> -->
|
||||||
|
<li>
|
||||||
|
<%= link_to(destroy_user_session_path, class: 'logout-link', :method => :delete) do %>
|
||||||
|
<i class="fa fa-external-link"></i> Logout
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- <form class="navbar-form navbar-right">
|
||||||
|
<input type="text" class="form-control" placeholder="Search...">
|
||||||
|
</form> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-3 col-md-2 sidebar">
|
||||||
|
<ul class="nav nav-sidebar">
|
||||||
|
<li><a href="/">Overview</a></li>
|
||||||
|
<!-- This will be removed and placed with correct logic in corresponding controller -->
|
||||||
|
<% if current_user.admin? %>
|
||||||
|
<li><a href="companies#index">Companies</a></li>
|
||||||
|
<% else %>
|
||||||
|
<li class="active"><a href="grades#index">Grades <span class="sr-only">(current)</span></a></li>
|
||||||
|
<!-- <li><a>Reports</a></li>
|
||||||
|
<li><a>Analytics</a></li>
|
||||||
|
<li><a>Export</a></li> -->
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<!-- <ul class="nav nav-sidebar">
|
||||||
|
<li><a href="">Nav item</a></li>
|
||||||
|
<li><a href="">Nav item again</a></li>
|
||||||
|
<li><a href="">One more nav</a></li>
|
||||||
|
<li><a href="">Another nav item</a></li>
|
||||||
|
<li><a href="">More navigation</a></li>
|
||||||
|
</ul>
|
||||||
|
<ul class="nav nav-sidebar">
|
||||||
|
<li><a href="">Nav item again</a></li>
|
||||||
|
<li><a href="">One more nav</a></li>
|
||||||
|
<li><a href="">Another nav item</a></li>
|
||||||
|
</ul> -->
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||||
|
<h1 class="page-header">Grades</h1>
|
||||||
|
<h2 class="sub-header">Total Grades: <%= @grades.count %> </h2>
|
||||||
|
<div class="panel panel-primary table-responsive">
|
||||||
|
<%= link_to(new_grade_path, :method => :get) do %>
|
||||||
|
<i class="fa fa-external-link"></i> Add a New Grade
|
||||||
|
<% end %>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Grade Name</th>
|
||||||
|
<th>Min Volume</th>
|
||||||
|
<th>Max Volume</th>
|
||||||
|
<th>Min Length</th>
|
||||||
|
<th>Max Length</th>
|
||||||
|
<th>Min Width</th>
|
||||||
|
<th>Max Width</th>
|
||||||
|
<th>Min Height</th>
|
||||||
|
<th>Max Height</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<% if @grades.empty? %>
|
||||||
|
</table>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<p>No Grades Recorded.</p>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<tbody>
|
||||||
|
<% @grades.each_slice(1) do |row| %>
|
||||||
|
<tr>
|
||||||
|
<% row.each do |grade|%>
|
||||||
|
|
||||||
|
<!-- grade_name -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Full_name %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- volume min -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Volume_min %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- volume max -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Volume_max %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- length min -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Length_min %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- length max -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Length_max %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- width min -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Width_min %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- width max -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Width_max %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- height min -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Height_min %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- height max -->
|
||||||
|
<td>
|
||||||
|
<%= grade.Height_max %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= javascript_include_tag "bootstrap.min" %>_
|
||||||
|
</body>
|
||||||
@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
|||||||
root "dashboard#index"
|
root "dashboard#index"
|
||||||
resources :runs
|
resources :runs
|
||||||
resources :companies
|
resources :companies
|
||||||
|
resources :grades
|
||||||
|
|
||||||
devise_for :users, :controllers => {:registrations => 'registrations'}
|
devise_for :users, :controllers => {:registrations => 'registrations'}
|
||||||
devise_scope :users do
|
devise_scope :users do
|
||||||
|
|||||||
7
Pearlception/test/controllers/grades_controller_test.rb
Normal file
7
Pearlception/test/controllers/grades_controller_test.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class GradesControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user