Skip to content

Commit

Permalink
Added Flag Job Post and View Count
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnetdev committed Jun 28, 2008
1 parent 0d6e18b commit 4a7c4cf
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 21 deletions.
16 changes: 14 additions & 2 deletions app/controllers/jobs_controller.rb
Expand Up @@ -15,6 +15,7 @@ def index
# GET /jobs/1.xml
def show
@job = Job.find(params[:id])
@job.increment!(:view_count)

respond_to do |format|
format.html # show.html.erb
Expand All @@ -27,14 +28,25 @@ def apply

@job_applicant = @job.job_applicants.build(params[:job_applicant])
if @job_applicant.save
# flash[:success] = " Congratulations, your application has been sent! Best of luck to you!"
session[:applied_id] = @job.id
redirect_to job_url(@job)
else
render :action => "show"
end
end


def report_spam
@job = Job.find(params[:id])

if @job.id == session[:reported_id]
render :text => "<em>Your vote has already been registered. Thanks for voting.</em>"
else
@job.increment!(:report_count)
session[:reported_id] = @job.id
render :text => "Thank you, your vote was registered and is highly appreciated!"
end
end

# GET /jobs/new
# GET /jobs/new.xml
def new
Expand Down
18 changes: 18 additions & 0 deletions app/views/jobs/parts/_details.html.haml
Expand Up @@ -53,3 +53,21 @@
#apply_online_now= link_to "&raquo; Apply now", "#"
#apply_online{hidden_unless(@job_applicant)}
= partial "jobs/parts/apply_form", :job => job, :job_applicant => @job_applicant

#job_bottom
#job_post_utils
= link_to "&laquo; go back to the homepage", root_url
= br
Is this job ad fake?
= link_to "Report it!", "#", :onclick => "Jobber.ReportSpam('/jobs/#{job.id}/report_spam/', #{job.id}); return false;"
= nbsp*2
%span#report_spam_response
= br
#number_views
Published at:
%strong= job.created_at.to_s(:post_listing_date)
= br
Viewed:
%strong= pluralize(job.view_count, "time")
= clear

6 changes: 5 additions & 1 deletion app/views/layouts/_footer.html.haml
Expand Up @@ -6,13 +6,16 @@

= link_to "Post a new job", new_job_url
= br

= link_to "Site widget", "#widget"
= br

= link_to "RSS Feeds", "#feeds"
= br

= link_to "The Ideal Job", new_job_request_url
= br


.footer-mid
Find out more:
Expand All @@ -23,6 +26,7 @@

= link_to "Contact", "#contact"
= br


.footer-right
Misc:
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Expand Up @@ -3,7 +3,8 @@
map.resources :jobs, :member => {
:verify => :any,
:apply => :post,
:confirm => :any
:confirm => :any,
:report_spam => :post
}

map.resources :job_requests, :collection => {:success => :get}
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20080628140740_add_view_count_to_jobs.rb
@@ -0,0 +1,11 @@
class AddViewCountToJobs < ActiveRecord::Migration
def self.up
add_column :jobs, :view_count, :integer, :default => 0
add_column :jobs, :report_count, :integer, :default => 0
end

def self.down
remove_column :jobs, :view_count
remove_column :jobs, :report_count
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20080628140339) do
ActiveRecord::Schema.define(:version => 20080628140740) do

create_table "categories", :force => true do |t|
t.string "name"
Expand Down Expand Up @@ -92,6 +92,8 @@
t.text "description_html"
t.string "formatting_type"
t.integer "job_applicants_count", :limit => 11, :default => 0
t.integer "view_count", :limit => 11, :default => 0
t.integer "report_count", :limit => 11, :default => 0
end

create_table "locations", :force => true do |t|
Expand Down
14 changes: 2 additions & 12 deletions public/javascripts/common/jobber.js
Expand Up @@ -88,18 +88,8 @@
url: url,
data: "job_id=" + job_id,
success: function(msg) {
if (msg == "0")
{
var status = "Thank you for your intention, but your vote could not be registered.";
$("#report-spam-response").css({ color: "red" });
}
else
{
var status = "Thank you, your vote was registered and is highly appreciated!";
$("#frm-send-to-friend").clearForm();
$("#report-spam-response").css({ color: "green" });
}
$("#report-spam-response").html(status);
$("#report_spam_response").html(msg);
$("#report_spam_response").css({ color: "green" });
}
});
},
Expand Down
13 changes: 9 additions & 4 deletions public/stylesheets/styles.css
Expand Up @@ -377,27 +377,32 @@ table/job-posts td.time-posted img, table/job-posts td.applicants img {
list-style-type: disc;
}

#job-bottom {
#job_bottom {
background-color: #f0f0f0;
padding: 2px;
padding:15px 8px 0px;
font-size: 14px;
height: 50px;
}

#number-views {
#number_views {
float: right;
display: inline;
font-size: 11px;
color: #777;
}

#job-post-utils {
#job_post_utils {
float: left;
display: inline;
font-size: 11px;
color: #888;
}

#job_post_utils #report_spam_response em{
font-style: normal;
color: orange;
}

#apply_online_now {
font-size: 14px;
margin-bottom: 7px;
Expand Down

0 comments on commit 4a7c4cf

Please sign in to comment.