Skip to content

Commit

Permalink
Aug 25
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcockerham committed Aug 25, 2013
1 parent 8ee3c81 commit 6f912f3
Show file tree
Hide file tree
Showing 42 changed files with 431 additions and 65 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ doc/
/public/system

# Ignore sample images
/sampleimages
/sampleimages

# Ignore application configuration (from figaro gem)
/config/application.yml
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ gem 'aws-sdk'
gem 'faker'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'figaro'

gem "letter_opener", :group => :development

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GEM
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.5)
arel (3.0.2)
aws-sdk (1.11.2)
json (~> 1.4)
Expand Down Expand Up @@ -60,13 +61,20 @@ GEM
multi_json (~> 1.0)
faker (1.1.2)
i18n (~> 0.5)
figaro (0.7.0)
bundler (~> 1.0)
rails (>= 3, < 5)
hike (1.2.2)
i18n (0.6.4)
journey (1.0.4)
jquery-rails (2.2.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
launchy (2.3.0)
addressable (~> 2.3)
letter_opener (1.1.2)
launchy (~> 2.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -146,7 +154,9 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
faker
figaro
jquery-rails
letter_opener
paperclip (~> 3.0)
pg
rails (= 3.2.12)
Expand Down
Binary file added app/assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion app/assets/javascripts/pins.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@

jQuery ->
$('#pins').imagesLoaded ->
$('#pins').masonry itemSelector: ".box"
$('#pins').masonry itemSelector: ".box"

if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page a').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
# What to do at the bottom of the page
$('.pagination').text("Fetching more pins...")
$.getScript(url)
$(window).scroll()
28 changes: 26 additions & 2 deletions app/assets/stylesheets/styles.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ body {
font-size: 11px;
line-height: 1.4em;
float: left;
text-align: left;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 1px 1px 10px #444;
width: 214px;
/*width: 214px;*/
}

.box img {
Expand All @@ -49,4 +50,27 @@ body {

.description {
margin: 10px 0 5px;
}
}

.navbar .brand img {
width: 25px;
padding: 0px;
margin: 0px;
}

/*
.navbar .brand {
width: 5%;
/*position: fixed;
max-height: 40px;
overflow: visible;
padding-left: 0;
padding-top: 0;
}
*/
/*
.brand {
width: 5%;
padding-left: 0;
}
*/
30 changes: 25 additions & 5 deletions app/controllers/job_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class JobApplicationsController < ApplicationController
# GET /job_applications
# GET /job_applications.json
def index
@job_applications = JobApplication.all
#@job_applications = JobApplication.all
@job_applications = current_user.job_applications.all

respond_to do |format|
format.html # index.html.erb
Expand All @@ -13,7 +14,10 @@ def index
# GET /job_applications/1
# GET /job_applications/1.json
def show
@job_application = JobApplication.find(params[:id])
#@job_application = JobApplication.find(params[:id])

#@user = User.find(params[:id])
@job_application = current_user.job_applications #.page(params[:page]).per_page(10)

respond_to do |format|
format.html # show.html.erb
Expand All @@ -24,7 +28,13 @@ def show
# GET /job_applications/new
# GET /job_applications/new.json
def new
@job_application = JobApplication.new
#@job_application = JobApplication.new
@job_application = JobApplication.new(params[:job_application])
@job_posting = JobPosting.find(params[:job_application][:job_posting_id])
#@job_application.job_posting_id = @job_posting.id
#@job_application.job_posting_id = params[:job_application][:job_posting_id]
#@job_application.job_posting_id = @job_posting.id
#@job_application = JobApplication.find(params[:job_posting_id])

respond_to do |format|
format.html # new.html.erb
Expand All @@ -34,16 +44,26 @@ def new

# GET /job_applications/1/edit
def edit
@job_application = JobApplication.find(params[:id])
@job_application = current_user.job_applications.find(params[:id])
end

# POST /job_applications
# POST /job_applications.json
def create
@job_application = JobApplication.new(params[:job_application])
#@job_application = JobApplication.new(params[:job_application])
@job_application = current_user.job_applications.new(params[:job_application])
#@job_application.job_posting_id = JobPostings.find(params[:job_posting_id]) # job_posting.id
#@job_posting = JobPosting.find(params[:job_posting_id])
#@job_application.job_posting_id = @job_posting.id
#@job_application.job_posting_id = params[:job_application][:job_posting_id]

respond_to do |format|
if @job_application.save
# send email to HR person who posted the job
@job_posting = JobPosting.find(@job_application.job_posting_id)
@HR_person = User.find(@job_posting.user_id)
RecieveApplicationMailer.recieve_application_email(@HR_person, @job_application).deliver

format.html { redirect_to @job_application, notice: 'Job application was successfully created.' }
format.json { render json: @job_application, status: :created, location: @job_application }
else
Expand Down
23 changes: 22 additions & 1 deletion app/controllers/job_postings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class JobPostingsController < ApplicationController
before_filter :authenticate_user!

before_filter :is_admin?, except: [:index, :show]
# GET /job_postings
# GET /job_postings.json
def index
Expand All @@ -12,6 +12,11 @@ def index
end
end

def my_index
@my_job_postings = current_user.job_postings.all

end

# GET /job_postings/1
# GET /job_postings/1.json
def show
Expand All @@ -23,9 +28,17 @@ def show
end
end

def show_applications
@applications = JobApplication.find_all_by_job_posting_id(params[:job_application][:job_posting_id])
@user = User.find(@applications[0].user_id)
@application1 = @applications[0]
@application2 = @applications[1]
end

# GET /job_postings/new
# GET /job_postings/new.json
def new

@job_posting = current_user.job_postings.new
#@job_posting = JobPosting.new

Expand Down Expand Up @@ -89,4 +102,12 @@ def destroy
format.json { head :no_content }
end
end

def is_admin?
if current_user.hirer
true
else
render :text => "You must have hiring privelages to post a job"
end
end
end
1 change: 1 addition & 0 deletions app/controllers/pins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def index
respond_to do |format|
format.html # index.html.erb
format.json { render json: @pins }
format.js
end
end

Expand Down
8 changes: 7 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@pins = @user.pins.page(params[:page]).per_page(20)
@pins = @user.pins.page(params[:page]).per_page(10)

respond_to do |format|
format.html # index.html.erb
#format.json { render json: @pins }
format.js
end
end

def new
Expand Down
12 changes: 12 additions & 0 deletions app/mailers/recieve_application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RecieveApplicationMailer < ActionMailer::Base
default from: "[email protected]"

def recieve_application_email(user, job_application)
@user = user
@job_application = job_application
@url = 'http://www.skillchest.com'

mail(to: @user.email, subject: 'Someone has applied for your job posting')

end
end
3 changes: 2 additions & 1 deletion app/models/job_application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class JobApplication < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :job_posting_id
belongs_to :user
belongs_to :job_posting

has_many :job_experiences

Expand Down
7 changes: 3 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class User < ActiveRecord::Base
:rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hirer, :job_experience_attributes
# attr_accessible :title, :body
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :hirer, :job_experiences_attributes

# Validations
validates_uniqueness_of :email
Expand All @@ -16,10 +15,10 @@ class User < ActiveRecord::Base
has_many :pins, :dependent => :destroy
has_many :job_postings, :dependent => :destroy
has_many :job_applications, :dependent => :destroy
has_one :job_experience, :dependent => :destroy
has_many :job_experiences, :dependent => :destroy

# Nested Attributes
accepts_nested_attributes_for :job_experience
accepts_nested_attributes_for :job_experiences
# :allow_destroy => true,
# :reject_if => :all_blank
end
15 changes: 14 additions & 1 deletion app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@
<%= f.input :current_password %>

<h2> Job Experience </h2>
<%= f.fields_for :job_experience_attributes do |j| %>
<% job_experiences = JobExperience.find_all_by_user_id(current_user.id) %>
<% if job_experiences.length == 0 %>
<p>You have not entered any job experiences yet.</p>
<% elsif job_experiences.length == 1 %>
<%= job_experiences[0].company %>
<%= job_experiences[0].job_title %>
<% elsif job_experiences.length > 1 %>
<% for x in job_experiences.length %>
<%= job_experiences[x].company %>
<%= job_experiences[x].job_title %>
<% end %>
<% end %>

<%= f.fields_for :job_experiences_attributes do |j| %>
<%= j.input :company %>
<%= j.input :job_title %>
<%= j.input :description, as: :text, input_html: { rows: "10" } %>
Expand Down
3 changes: 1 addition & 2 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<%= f.input :password_confirmation %>
<%= f.input :hirer, as: :boolean %>


<%= f.fields_for :job_experience_attributes do |j| %>
<%= f.fields_for :job_experiences_attributes do |j| %>
<%= j.input :company %>

<% end %>
Expand Down
Loading

0 comments on commit 6f912f3

Please sign in to comment.