Added Dashboard Integration and Authentication

- Signin and Signup views still not being shown and defaulting to default
This commit is contained in:
Okechi Onyeje 2017-01-20 00:51:06 -05:00
parent 9d17166e8f
commit c0564fff14
3 changed files with 77 additions and 130 deletions

View File

@ -1,13 +1,23 @@
class RegistrationsController < Devise::RegistrationsController
include ApplicationHelper
protected
#protected
def create
super
binding.pry
@user = User.new(sign_up_params)
if !@user.admin?
#search by company token given by one of pearlception admins to the company
#and look up comany_id #
@user.company_id = 0
else
@user.company_id = -1
end
@user.save
sign_in @user
redirect_to "/"
end
def sign_up_params
params.require(:user).permit(:company_id, :email, :password, :password_confirmation)
params.require(:user).permit(:email, :password, :password_confirmation, :company_id)
end
end

View File

@ -10,23 +10,23 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Pearlception</a>
<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="#">Settings</a></li>
<li><a href="#">Profile</a></li>
<li><a href="#">Help</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">
<!-- <form class="navbar-form navbar-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
</form> -->
</div>
</div>
</nav>
@ -35,10 +35,15 @@
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>
<li><a href="#">Reports</a></li>
<li><a href="#">Analytics</a></li>
<li><a href="#">Export</a></li>
<li class="active"><a href="/">Overview <span class="sr-only">(current)</span></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><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>
@ -84,126 +89,58 @@
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Run Date</th>
<th>Location</th>
<th>Harvest Time</th>
<th>Supplier</th>
<th>Distributor</th>
<th>Total Processed</th>
<th>Other</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,001</td>
<td>Lorem</td>
<td>ipsum</td>
<td>dolor</td>
<td>sit</td>
</tr>
<tr>
<td>1,002</td>
<td>amet</td>
<td>consectetur</td>
<td>adipiscing</td>
<td>elit</td>
</tr>
<tr>
<td>1,003</td>
<td>Integer</td>
<td>nec</td>
<td>odio</td>
<td>Praesent</td>
</tr>
<tr>
<td>1,003</td>
<td>libero</td>
<td>Sed</td>
<td>cursus</td>
<td>ante</td>
</tr>
<tr>
<td>1,004</td>
<td>dapibus</td>
<td>diam</td>
<td>Sed</td>
<td>nisi</td>
</tr>
<tr>
<td>1,005</td>
<td>Nulla</td>
<td>quis</td>
<td>sem</td>
<td>at</td>
</tr>
<tr>
<td>1,006</td>
<td>nibh</td>
<td>elementum</td>
<td>imperdiet</td>
<td>Duis</td>
</tr>
<tr>
<td>1,007</td>
<td>sagittis</td>
<td>ipsum</td>
<td>Praesent</td>
<td>mauris</td>
</tr>
<tr>
<td>1,008</td>
<td>Fusce</td>
<td>nec</td>
<td>tellus</td>
<td>sed</td>
</tr>
<tr>
<td>1,009</td>
<td>augue</td>
<td>semper</td>
<td>porta</td>
<td>Mauris</td>
</tr>
<tr>
<td>1,010</td>
<td>massa</td>
<td>Vestibulum</td>
<td>lacinia</td>
<td>arcu</td>
</tr>
<tr>
<td>1,011</td>
<td>eget</td>
<td>nulla</td>
<td>Class</td>
<td>aptent</td>
</tr>
<tr>
<td>1,012</td>
<td>taciti</td>
<td>sociosqu</td>
<td>ad</td>
<td>litora</td>
</tr>
<tr>
<td>1,013</td>
<td>torquent</td>
<td>per</td>
<td>conubia</td>
<td>nostra</td>
</tr>
<tr>
<td>1,014</td>
<td>per</td>
<td>inceptos</td>
<td>himenaeos</td>
<td>Curabitur</td>
</tr>
<tr>
<td>1,015</td>
<td>sodales</td>
<td>ligula</td>
<td>in</td>
<td>libero</td>
</tr>
<% @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>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -1,4 +1,4 @@
<h2>Sign up</h2>
<h2>Sign up!</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>