diff --git a/.gitignore b/.gitignore index d3d7cab..9109974 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ doc/ /public/system # Ignore sample images -/sampleimages \ No newline at end of file +/sampleimages + +# Ignore application configuration (from figaro gem) +/config/application.yml diff --git a/Gemfile b/Gemfile index 0042fd0..119c44b 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index d2b5b0c..7ca2eaf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -60,6 +61,9 @@ 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) @@ -67,6 +71,10 @@ GEM 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) @@ -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) diff --git a/app/assets/images/logo.png b/app/assets/images/logo.png new file mode 100644 index 0000000..e9b65a6 Binary files /dev/null and b/app/assets/images/logo.png differ diff --git a/app/assets/images/logo1.png b/app/assets/images/logo1.png new file mode 100644 index 0000000..bbc6978 Binary files /dev/null and b/app/assets/images/logo1.png differ diff --git a/app/assets/javascripts/pins.js.coffee b/app/assets/javascripts/pins.js.coffee index 7d0be3f..838a15f 100644 --- a/app/assets/javascripts/pins.js.coffee +++ b/app/assets/javascripts/pins.js.coffee @@ -4,4 +4,13 @@ jQuery -> $('#pins').imagesLoaded -> - $('#pins').masonry itemSelector: ".box" \ No newline at end of file + $('#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() \ No newline at end of file diff --git a/app/assets/stylesheets/styles.css.scss b/app/assets/stylesheets/styles.css.scss index 97f536f..cda4e42 100644 --- a/app/assets/stylesheets/styles.css.scss +++ b/app/assets/stylesheets/styles.css.scss @@ -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 { @@ -49,4 +50,27 @@ body { .description { margin: 10px 0 5px; -} \ No newline at end of file +} + +.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; +} +*/ \ No newline at end of file diff --git a/app/controllers/job_applications_controller.rb b/app/controllers/job_applications_controller.rb index 9a3e20b..6494039 100644 --- a/app/controllers/job_applications_controller.rb +++ b/app/controllers/job_applications_controller.rb @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/app/controllers/job_postings_controller.rb b/app/controllers/job_postings_controller.rb index 4231756..4df37f5 100644 --- a/app/controllers/job_postings_controller.rb +++ b/app/controllers/job_postings_controller.rb @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/app/controllers/pins_controller.rb b/app/controllers/pins_controller.rb index 56d1f74..2e862a5 100644 --- a/app/controllers/pins_controller.rb +++ b/app/controllers/pins_controller.rb @@ -15,6 +15,7 @@ def index respond_to do |format| format.html # index.html.erb format.json { render json: @pins } + format.js end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 57ca9ef..fa0bc7d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/mailers/recieve_application_mailer.rb b/app/mailers/recieve_application_mailer.rb new file mode 100644 index 0000000..2bde5da --- /dev/null +++ b/app/mailers/recieve_application_mailer.rb @@ -0,0 +1,12 @@ +class RecieveApplicationMailer < ActionMailer::Base + default from: "andrew@skillchest.com" + + 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 diff --git a/app/models/job_application.rb b/app/models/job_application.rb index 0c2762b..8ae4511 100644 --- a/app/models/job_application.rb +++ b/app/models/job_application.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index e7e62c1..6e2d58f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 @@ -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 diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index c5c9a28..2230556 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -10,7 +10,20 @@ <%= f.input :current_password %>
You have not entered any job experiences yet.
+ <% 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" } %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 2c5e780..4de697c 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -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 %> diff --git a/app/views/job_applications/_form.html.erb b/app/views/job_applications/_form.html.erb index d1c439a..d195ba8 100644 --- a/app/views/job_applications/_form.html.erb +++ b/app/views/job_applications/_form.html.erb @@ -1,10 +1,68 @@ -<%= simple_form_for(@job_application) do |f| %> - <%= f.error_notification %> ++ <%= job_application.user_id %> +
++ <%= job_application.job_posting_id %> + <%= job_application %> +
+ + <% if current_user.id == job_application.user_id %> + +<%= link_to 'Edit', edit_job_application_path(job_application) %> + <%= link_to 'Destroy', job_application, method: :delete, data: { confirm: 'Are you sure?' } %> +
+ <% end %> +- | - | - |
---|---|---|
<%= link_to 'Show', job_application %> | -<%= link_to 'Edit', edit_job_application_path(job_application) %> | -<%= link_to 'Destroy', job_application, method: :delete, data: { confirm: 'Are you sure?' } %> | -
<%= notice %>
+<%= params %> +<%= @job_application1 = JobApplication.find(params[:id]) %> +<%= @job_application1.job_posting_id %> +<%= @job_application1.id %> <%= link_to 'Edit', edit_job_application_path(@job_application) %> | <%= link_to 'Back', job_applications_path %> diff --git a/app/views/job_experiences/_form.html.erb b/app/views/job_experiences/_form.html.erb index 105e001..578ddd2 100644 --- a/app/views/job_experiences/_form.html.erb +++ b/app/views/job_experiences/_form.html.erb @@ -8,7 +8,9 @@ <%= f.input :start_date %> +job experiences form
+ <%= job_posting.title %> +
++ <%= job_posting.description %> +
<% if current_user == job_posting.user %> -<%= link_to 'Edit', edit_job_posting_path(job_posting) %> + <%= link_to 'Destroy', job_posting, method: :delete, data: { confirm: 'Are you sure?' } %> +
<% end %> -<%= @job_posting.description %>
- <%= link_to 'Apply', "#{}" %> | +<%= params %>
<% if current_user == @job_posting.user %> <%= link_to 'Edit', edit_job_posting_path(@job_posting) %> | + <%= link_to 'Destroy', @job_posting, method: :delete, data: { confirm: 'Are you sure?' } %> | + <%= link_to 'View Applications', job_posting_applications_path(:job_application => { :job_posting_id => @job_posting.id }) %> | + <% else %> + <%= link_to 'Apply', new_job_application_path(:job_application => { :job_posting_id => @job_posting.id }) %> | <% end %> <%= link_to 'Back', job_postings_path %> + +<%= @usertest.name %>
+ <%= @usertest.job_experience.company %> + <%= @usertest.job_experience.job_title %> + <%= @usertest.job_experience.description %> + <%= @usertest.job_experience.start_date %> +