mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
Merge branch 'master' of https://github.com/oonyeje/Pearlception_Website_RoR
This commit is contained in:
commit
6c2d6f4918
@ -2,7 +2,29 @@ class DashboardController < ApplicationController
|
|||||||
before_filter :deny_to_visitors
|
before_filter :deny_to_visitors
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@results = Result.page(params[:page]).per(5)
|
#This is a temporary fix until runs and results models are properly discussed with bobby
|
||||||
|
#@results = Result.page(params[:page]).per(5)
|
||||||
|
if current_user.admin?
|
||||||
|
puts params
|
||||||
|
@results = Hash.new
|
||||||
|
names = (Company.pluck :company_name) - ["IVA"]
|
||||||
|
names.map!{|tenant| tenant.gsub(/'/,'').gsub(/\s/,'')}
|
||||||
|
names.each do
|
||||||
|
|name|
|
||||||
|
|
||||||
|
Apartment::Tenant.switch!(name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
|
|
||||||
|
if params[:company] == name
|
||||||
|
@results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: true, name: name}
|
||||||
|
else
|
||||||
|
@results[name.gsub(/'/,'').gsub(/\s/,'')] = {results: Run.page(params[:page]).per(5), active: false}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#binding.pry
|
||||||
|
Apartment::Tenant.switch!
|
||||||
|
else
|
||||||
|
@results = Run.page(params[:page]).per(5)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,13 +5,11 @@ class SessionsController < Devise::RegistrationsController
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
binding.pry
|
|
||||||
resource = warden.authenticate!(:scope => :user)
|
resource = warden.authenticate!(:scope => :user)
|
||||||
binding.pry
|
|
||||||
sign_in(:user, resource)
|
sign_in(:user, resource)
|
||||||
if !current_user.admin
|
if !current_user.admin
|
||||||
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
end
|
end
|
||||||
redirect_to "/"
|
redirect_to "/"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,6 @@ class Company < ApplicationRecord
|
|||||||
private
|
private
|
||||||
|
|
||||||
def create_tenant
|
def create_tenant
|
||||||
binding.pry
|
|
||||||
if company_name != "IVA"
|
if company_name != "IVA"
|
||||||
Apartment::Tenant.create(company_name.gsub(/'/,'').gsub(/\s/,''))
|
Apartment::Tenant.create(company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
Apartment::Tenant.switch!
|
Apartment::Tenant.switch!
|
||||||
|
|||||||
@ -5,10 +5,12 @@ class User < ApplicationRecord
|
|||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
def after_database_authentication
|
def after_database_authentication
|
||||||
if !self.admin
|
if !self.admin
|
||||||
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/,''))
|
||||||
|
else
|
||||||
|
Apartment::Tenant.switch!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -88,142 +88,177 @@
|
|||||||
|
|
||||||
<% if current_user.admin? %>
|
<% if current_user.admin? %>
|
||||||
<h2 class="sub-header">Recent Results From All Companies</h2>
|
<h2 class="sub-header">Recent Results From All Companies</h2>
|
||||||
|
|
||||||
|
<div class="panel-group" id="accordion">
|
||||||
|
<span hidden><%= @i = 1 %></span>
|
||||||
|
<% ((Company.pluck :company_name) - ["IVA"]).each do |company_name| %>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title text-center">
|
||||||
|
<a data-toggle="collapse" data-parent="#accordion" href="#collapse<%="#{@i}"%>">
|
||||||
|
<%= company_name %> </a>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div id="collapse<%="#{@i}"%>" class="panel-collapse collapse <%= (@results[company_name.gsub(/'/,'').gsub(/\s/,'')][:active] && @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:name] == company_name.gsub(/'/,'').gsub(/\s/,'') ) ? "in" : ""%>">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="table-responsive panel panel-primary">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Run Date</th>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>Harvest Time</th>
|
||||||
|
<th>Supplier</th>
|
||||||
|
<th>Distributor</th>
|
||||||
|
<th>Total Processed</th>
|
||||||
|
<th>Other</th>
|
||||||
|
<th>Oyster Info</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<span hidden><%= Apartment::Tenant.switch!(company_name.gsub(/'/,'').gsub(/\s/,'')) %></span>
|
||||||
|
<tbody>
|
||||||
|
<% @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results].each_slice(1) do |row| %>
|
||||||
|
<tr>
|
||||||
|
<% row.each do |result|
|
||||||
|
run = result#Run.find(result.id) %>
|
||||||
|
<!-- run date -->
|
||||||
|
<td>
|
||||||
|
<%= run.runDate %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- location -->
|
||||||
|
<td>
|
||||||
|
<%= run.location ? run.location : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- harvest time -->
|
||||||
|
<td>
|
||||||
|
<%= "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- supplier -->
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= run.supplier ? run.supplier : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- distributor -->
|
||||||
|
<td>
|
||||||
|
<%= run.distributor ? run.distributor : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- total processed -->
|
||||||
|
<td>
|
||||||
|
"result"
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- other -->
|
||||||
|
<td>
|
||||||
|
<%= run.other ? run.other : "" %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</div>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="center-block">
|
||||||
|
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||||
|
<%= paginate @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results] , params: {company: company_name.gsub(/'/,'').gsub(/\s/,'')} %></br>
|
||||||
|
<%= page_entries_info @results[company_name.gsub(/'/,'').gsub(/\s/,'')][:results] %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span hidden><%= @i = @i + 1%></span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<h2 class="sub-header">Recent Results</h2>
|
<h2 class="sub-header">Recent Results</h2>
|
||||||
<% end %>
|
<div class="table-responsive panel panel-primary">
|
||||||
<div class="table-responsive panel panel-primary">
|
<table class="table table-striped">
|
||||||
<table class="table table-striped">
|
<div class="panel-heading">
|
||||||
<div class="panel-heading">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<th>Run Date</th>
|
||||||
<% if current_user.admin? %>
|
<th>Location</th>
|
||||||
<th>Company</th>
|
<th>Harvest Time</th>
|
||||||
|
<th>Supplier</th>
|
||||||
|
<th>Distributor</th>
|
||||||
|
<th>Total Processed</th>
|
||||||
|
<th>Other</th>
|
||||||
|
<th>Oyster Info</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<tbody>
|
||||||
|
<% @results.each_slice(1) do |row| %>
|
||||||
|
<tr>
|
||||||
|
<% row.each do |result|
|
||||||
|
run = Run.find(result.id) %>
|
||||||
|
<!-- run date -->
|
||||||
|
<td>
|
||||||
|
<%= run.runDate %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- location -->
|
||||||
|
<td>
|
||||||
|
<%= run.location ? run.location : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- harvest time -->
|
||||||
|
<td>
|
||||||
|
<%= "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- supplier -->
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<%= run.supplier ? run.supplier : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- distributor -->
|
||||||
|
<td>
|
||||||
|
<%= run.distributor ? run.distributor : "" %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- total processed -->
|
||||||
|
<td>
|
||||||
|
"result"
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<!-- other -->
|
||||||
|
<td>
|
||||||
|
<%= run.other ? run.other : "" %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th>Run Date</th>
|
</tbody>
|
||||||
<th>Location</th>
|
</div>
|
||||||
<th>Harvest Time</th>
|
</table>
|
||||||
<th>Supplier</th>
|
</div>
|
||||||
<th>Distributor</th>
|
<div class="center-block">
|
||||||
<th>Total Processed</th>
|
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||||
<th>Other</th>
|
<%= paginate @results %></br>
|
||||||
<th>Oyster Info</th>
|
<%= page_entries_info @results %>
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
</div>
|
||||||
<tbody>
|
<% end %>
|
||||||
<% if current_user.admin? %>
|
|
||||||
<% @results.each_slice(1) do |row| %>
|
|
||||||
<tr>
|
|
||||||
<% row.each do |result|
|
|
||||||
run = Run.find(result.id)
|
|
||||||
#company = Company.find(run.company_id)
|
|
||||||
%>
|
|
||||||
|
|
||||||
<!-- company name -->
|
|
||||||
<td>
|
|
||||||
<%= #company.company_name
|
|
||||||
"Fake Industries" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- run date -->
|
|
||||||
<td>
|
|
||||||
<%= run.runDate %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- location -->
|
|
||||||
<td>
|
|
||||||
<%= run.location ? run.location : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- harvest time -->
|
|
||||||
<td>
|
|
||||||
<%= "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- supplier -->
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= run.supplier ? run.supplier : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- distributor -->
|
|
||||||
<td>
|
|
||||||
<%= run.distributor ? run.distributor : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- total processed -->
|
|
||||||
<td>
|
|
||||||
<%= result.total %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- other -->
|
|
||||||
<td>
|
|
||||||
<%= run.other ? run.other : "" %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<% @results.each_slice(1) do |row| %>
|
|
||||||
<tr>
|
|
||||||
<% row.each do |result|
|
|
||||||
run = Run.find(result.id) %>
|
|
||||||
<!-- run date -->
|
|
||||||
<td>
|
|
||||||
<%= run.runDate %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- location -->
|
|
||||||
<td>
|
|
||||||
<%= run.location ? run.location : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- harvest time -->
|
|
||||||
<td>
|
|
||||||
<%= "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- supplier -->
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<%= run.supplier ? run.supplier : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- distributor -->
|
|
||||||
<td>
|
|
||||||
<%= run.distributor ? run.distributor : "" %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- total processed -->
|
|
||||||
<td>
|
|
||||||
<%= result.total %>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- other -->
|
|
||||||
<td>
|
|
||||||
<%= run.other ? run.other : "" %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</div>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="center-block">
|
|
||||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
|
||||||
<%= paginate @results %></br>
|
|
||||||
<%= page_entries_info @results %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
2450
Pearlception/nohup.out
Normal file
2450
Pearlception/nohup.out
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user