forked from shanil-puri/blogger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shanil Puri
committed
Sep 27, 2014
1 parent
f1caf4c
commit 5f840b0
Showing
23 changed files
with
289 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
class HomeController < ApplicationController | ||
def index | ||
if current_user.is_employer | ||
redirect_to employer_home_path | ||
if current_user.is_admin? | ||
redirect_to admin_home_index_path | ||
else | ||
redirect_to root_path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class JobController < ApplicationController | ||
|
||
skip_before_filter :authenticate_job!, :only => [:index] | ||
|
||
autocomplete :category, :name, :full => true | ||
|
||
def index | ||
@jobs = Job.all | ||
end | ||
|
||
def new | ||
@job = Job.new | ||
end | ||
|
||
def show | ||
@job = Job.find(params[:id]) | ||
end | ||
|
||
def create | ||
job = Job.new | ||
|
||
update_params = job_params | ||
update_params[:owner_id] = current_user.id | ||
|
||
update_new_job job, update_params | ||
end | ||
|
||
def apply | ||
if current_user.is_jobseeker? | ||
current_user.jobs << Job.find(params[:job_id]) | ||
redirect_to job_index_path | ||
else | ||
flash[:notice] = "You are not allowed to apply for the job. Please create a new jobseeker account." | ||
redirect_to root_path | ||
end | ||
end | ||
|
||
def destroy | ||
|
||
end | ||
|
||
private | ||
|
||
def update_new_job job, new_job_hash | ||
job.update_attributes(new_job_hash) | ||
if job.errors.blank? | ||
job.save! | ||
redirect_to job_index_path | ||
else | ||
@errors = job.errors.full_messages | ||
@errors.each do |e| | ||
flash[:error] = e | ||
end | ||
redirect_to new_job_path | ||
end | ||
end | ||
|
||
def job_params | ||
params.require(:job).permit(:title, :description, :category_id, :deadline, :salary) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module JobHelper | ||
|
||
def can_post_new_job? | ||
current_user.can_publish? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class Job < ActiveRecord::Base | ||
has_and_belongs_to_many :tags | ||
has_and_belongs_to_many :users | ||
has_one :category | ||
|
||
validates :owner_id, :title, :description, :category, :deadline, presence: true | ||
validates :owner_id, :title, :description, :category_id, :deadline, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class RoleUser < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div><%= link_to "Create New Editor", "#" %></div> | ||
<div><%= link_to "View All Users", "#" %></div> | ||
<div><%= link_to "Create New Editor", new_admin_user_path %></div> | ||
<div><%= link_to "View All Users", admin_users_path %></div> | ||
<div><%= link_to "View All Drafted Posts", "#" %></div> | ||
<div><%= link_to "View All Published Posts", "#" %></div> | ||
<div><%= link_to "Create new resume", "#" %></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="create_header"> | ||
<h1>All Users</h1> | ||
<%= link_to "Create User", new_admin_user_path if current_user.is_admin? %> | ||
</div> | ||
<div class="data_container"> | ||
<table id = "application_users_list" class="display data_table"> | ||
<thead> | ||
<tr class="even"> | ||
<th>User Id</th> | ||
<th>User Name</th> | ||
<th>User Email</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @users.each do |user| %> | ||
<tr> | ||
<td><%= user.id %></td> | ||
<td><%= user.name %></td> | ||
<!--<td><%#= user.posts.count %></td>--> | ||
<td><%= user.email %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
$(document).ready(function() { | ||
$('#application_users_list').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, | ||
// { "bSearchable": false }, | ||
null | ||
] } ); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div class="create_header"> | ||
<h1>All Published Posts</h1> | ||
<% 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> |
Oops, something went wrong.