Skip to content

Commit

Permalink
Addint left over functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanil Puri committed Sep 27, 2014
1 parent 5f840b0 commit 269e952
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 49 deletions.
10 changes: 8 additions & 2 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ def create
private

def update_new_user user, new_user_hash
role_hash = new_user_hash["role"]
new_user_hash = new_user_hash.slice!("role")
puts "##############################################################################################################\n"
puts new_user_hash
puts "##############################################################################################################"
user.update_attributes(new_user_hash)



if user.errors.blank?
user.save!
# user.roles << Role.find(assigned_role[:id])
user.roles << Role.find(role_hash[:id])
else
@errors = user.errors.full_messages
@errors.each do |e|
Expand All @@ -38,7 +44,7 @@ def update_new_user user, new_user_hash
end

def user_params
params.require(:user).permit(:name, :phone, :email, :password, :password_confirmation, {:role => [:id, :name]})
params.require(:user).permit(:name, :phone, :email, :password, :password_confirmation, {:role => [:id, :role]})
end

# def role_params
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/job_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ def show
@job = Job.find(params[:id])
end

def my_jobs
if current_user.is_employer?
@jobs = Job.where(:owner_id => current_user.id)
puts @jobs
elsif current_user.is_jobseeker?
@jobs = current_user.jobs
else
puts"this should be called"
flash[:notice] = "You are the ADMIN. Please remember: With great power comes great responsibility :)"
@jobs = Job.all
end
end

def create
job = Job.new

Expand Down
4 changes: 0 additions & 4 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class SessionsController < Devise::SessionsController
def after_sign_in_path_for(resource)
puts "#################\n\n"
puts resource
if resource.is_a?(User)
puts "#################"
puts "this should be called"
resource.is_admin? ? admin_home_index_path : root_path
else
super
Expand Down
40 changes: 40 additions & 0 deletions app/views/job/_jobs_table.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<span>*Click on Jobs to view details</span>
<div class="data_container">
<table id = "jobs_table" class="display data_table">
<thead>
<tr class="even">
<th>Owner Name</th>
<th>Job Title</th>
<th>Application Deadline</th>
</tr>
</thead>
<tbody>
<% @jobs.each do |job| %>
<tr>
<td><%= User.find(job.owner_id).name %></td>
<td><%= link_to job.title, job_path(:id => job.id), :class => "job_body_link" %></td>
<td class = "job_body_link"><%= job.deadline %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('#jobs_table').dataTable({
sPaginationType: "full_numbers",
"sDom": '<"top"if>rt<"bottom"lp><"clear">;', // add the 'f' in top tag to enable searching like <"top"f>
"bJQueryUI": true,
"aoColumns": [
null,
null,
null
]});
$(".job_body_link").on("click", function(e){
e.preventDefault();
var path = $(this).attr("href");
show_common_popup(path, '');
});
});
</script>
40 changes: 1 addition & 39 deletions app/views/job/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,6 @@
<% if can_post_new_job? %>
<%= link_to "Post New Job", new_job_path %>
<% end %>
<span>*Click on Job to apply</span>
</div>
<div class="data_container">
<table id = "jobs_table" class="display data_table">
<thead>
<tr class="even">
<th>Owner Name</th>
<th>Job Title</th>
<th>Application Deadline</th>
</tr>
</thead>
<tbody>
<% @jobs.each do |job| %>
<tr>
<td><%= User.find(job.owner_id).name %></td>
<td><%= link_to job.title, job_path(:id => job.id), :class => "job_body_link" %></td>
<td class = "job_body_link"><%= job.deadline %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('#jobs_table').dataTable({
sPaginationType: "full_numbers",
"sDom": '<"top"if>rt<"bottom"lp><"clear">;', // add the 'f' in top tag to enable searching like <"top"f>
"bJQueryUI": true,
"aoColumns": [
null,
null,
null
]});
$(".job_body_link").on("click", function(e){
e.preventDefault();
var path = $(this).attr("href");
show_common_popup(path, '');
});
});
</script>
<%= render :partial => "jobs_table.html.erb" %>
8 changes: 8 additions & 0 deletions app/views/job/my_jobs.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="create_header">
<h1>My Jobs</h1>
<% if can_post_new_job? %>
<%= link_to "Post New Job", new_job_path %>
<% end %>
</div>

<%= render :partial => "jobs_table.html.erb" %>
8 changes: 5 additions & 3 deletions app/views/job/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<div class="job_deadline">
<%= @job.deadline %>
</div>
<div class="jomb_apply">
<%= link_to "Apply", job_apply_path(:job_id=>@job.id), :confirm => "Your profile information will be used for this job application. Are you sure you wish to proceed?" %>
</div>
<% if current_user.is_jobseeker? %>
<div class="job_apply">
<%= link_to "Apply", job_apply_path(:job_id=>@job.id), :confirm => "Your profile information will be used for this job application. Are you sure you wish to proceed?" %>
</div>
<% end %>
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
devise_for :users, :controllers => {:registrations => "registrations", :sessions=>"sessions"}

root :to => "home#index"

resources :job do
get "/my_jobs" => :my_jobs, :on => :collection
get :autocomplete_category_name, :on => :collection
get "/apply" => :apply
end


namespace :admin do
resources :home , :only => [:index]
resources :users do
Expand Down

0 comments on commit 269e952

Please sign in to comment.