Skip to content

Commit

Permalink
added projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Systho committed Aug 19, 2012
1 parent 84eb454 commit c514976
Show file tree
Hide file tree
Showing 24 changed files with 196 additions and 31 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ gem "slim"
gem 'wicked_pdf'
gem 'responders'
gem 'strong_parameters'
gem 'nested_form'
gem 'acts-as-taggable-on'
gem 'rails3-jquery-autocomplete'

group :assets do
gem 'sass-rails'
Expand All @@ -32,6 +35,8 @@ group :test, :development do
gem "rspec-rails"
gem "factory_girl_rails"
gem "faker"
gem 'capybara-webkit'
gem 'database_cleaner'
end

group :production do
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ GEM
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
acts-as-taggable-on (2.3.3)
rails (~> 3.0)
addressable (2.3.2)
arel (3.0.2)
bootstrap-sass (2.0.4.0)
Expand All @@ -39,6 +41,9 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
capybara-webkit (0.12.1)
capybara (>= 1.0.0, < 1.2)
json
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
coffee-rails (3.2.2)
Expand All @@ -48,6 +53,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.3)
database_cleaner (0.8.0)
diff-lcs (1.1.3)
erubis (2.7.0)
excon (0.15.5)
Expand Down Expand Up @@ -86,6 +92,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
nested_form (0.2.2)
netrc (0.7.5)
nokogiri (1.5.5-x86-mingw32)
pg (0.13.1-x86-mingw32)
Expand All @@ -105,6 +112,8 @@ GEM
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
rails3-jquery-autocomplete (1.0.7)
rails (~> 3.0)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
Expand Down Expand Up @@ -181,15 +190,20 @@ PLATFORMS
x86-mingw32

DEPENDENCIES
acts-as-taggable-on
bootstrap-sass (>= 2.0.4.0)
capybara
capybara-webkit
coffee-rails
database_cleaner
factory_girl_rails
faker
heroku
jquery-rails
nested_form
pg
rails (= 3.2.1)
rails3-jquery-autocomplete
responders
rspec-rails
sass-rails
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap
//= require jquery_nested_form
//= require autocomplete-rails-uncompressed
//= require_tree .
6 changes: 6 additions & 0 deletions app/assets/javascripts/resumes.js.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

#$(document).on('nested:fieldAdded', (event) ->
# console.log(event.field.find('input[data-autocomplete]'))
# #event.field.find('input[data-autocomplete]').railsAutocomplete()
#)

3 changes: 3 additions & 0 deletions app/assets/stylesheets/bootstrap_and_overrides.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import "bootstrap";
body { padding-top: 60px; }
input, textarea {
width: 80%;
}
@import "bootstrap-responsive";
8 changes: 8 additions & 0 deletions app/assets/stylesheets/pdf.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h1{
font-weight: normal;
}

h2 {
font-weight: 100;
font-size: xx-large;
}
4 changes: 4 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ProjectsController < ApplicationController
autocomplete :technology, :name, :class_name => 'ActsAsTaggableOn::Tag'

end
5 changes: 3 additions & 2 deletions app/controllers/resumes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ResumesController < ApplicationController
respond_to :html
respond_to :html, :except => [:show]
respond_to :pdf, :only => [:show]

def index
Expand Down Expand Up @@ -44,9 +44,10 @@ def destroy
respond_with(@resume)
end


protected

def resume_params
params.require(:resume).permit(:first_name, :last_name, :intro)
params.require(:resume).permit(:first_name, :last_name, :intro, :projects_attributes)
end
end
4 changes: 4 additions & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Project < ActiveRecord::Base
acts_as_taggable_on :technologies

end
2 changes: 2 additions & 0 deletions app/models/resume.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Resume < ActiveRecord::Base
has_many :projects, :dependent => :destroy
accepts_nested_attributes_for :projects

validates :first_name, :presence => true
validates :last_name, :presence => true
Expand Down
2 changes: 2 additions & 0 deletions app/models/technology.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Technology < ActiveRecord::Base
end
7 changes: 5 additions & 2 deletions app/views/resumes/_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
= simple_form_for @resume do |f|
= simple_nested_form_for @resume do |f|
= f.input :first_name
= f.input :last_name
= f.input :intro
= f.button :submit

= f.fields_for :projects, :class => "project_fields"
p
= f.link_to_add "Add Project", :projects
= f.button :submit
6 changes: 6 additions & 0 deletions app/views/resumes/_project_fields.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
= field_set_tag "Project Details", :class => "project_fields" do
= f.input :title
= f.input :description
= f.input :duration
= f.input :technology_list, :url => autocomplete_technology_name_projects_path, :as => :autocomplete, :input_html => {:"data-delimiter" => ', '}
= f.link_to_remove "Remove this project"
12 changes: 6 additions & 6 deletions app/views/resumes/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ table
tr
th First name
th Last name
th Intro
th
th
th
Expand All @@ -14,11 +13,12 @@ table
tr
td = resume.first_name
td = resume.last_name
td = resume.intro
td = link_to 'Show', resume
td = link_to 'Pdf version', resume_path(resume, :format => :pdf)
td = link_to 'Edit', edit_resume_path(resume)
td = link_to 'Destroy', resume, :confirm => 'Are you sure?', :method => :delete
td = link_to resume_path(resume, :format => :pdf) do
i.icon-eye-open
td = link_to edit_resume_path(resume) do
i.icon-edit
td = link_to resume, :confirm => 'Are you sure?', :method => :delete do
i.icon-trash

br

Expand Down
13 changes: 0 additions & 13 deletions app/views/resumes/show.html.slim

This file was deleted.

24 changes: 21 additions & 3 deletions app/views/resumes/show.pdf.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@ html
meta charset="utf-8"
= wicked_pdf_stylesheet_link_tag "pdf"
body
h2
= "#{@resume.first_name} #{@resume.last_name}"
h1
= @resume.first_name
strong
= " #{@resume.last_name}"

p
= @resume.intro
= simple_format @resume.intro

section.projects
h2 Projets réalisés

- @resume.projects.each do |project|
section.project
h3 = project.title
p
= simple_format project.description
p
span Durée :&nbsp;
= project.duration
p
span Technologies :&nbsp;
= project.technology_list


3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


resources :resumes
resources :projects, :only => [] do
get :autocomplete_technology_name, :on => :collection
end

root :to => redirect("/resumes")

Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20120819120824_create_projects.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateProjects < ActiveRecord::Migration
def change
create_table :projects do |t|
t.string :title
t.text :description
t.string :duration
t.references :resume

t.timestamps
end
end
end
30 changes: 30 additions & 0 deletions db/migrate/20120819135805_acts_as_taggable_on_migration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
end

create_table :taggings do |t|
t.references :tag

# You should make sure that the column created is
# long enough to store the required class names.
t.references :taggable, :polymorphic => true
t.references :tagger, :polymorphic => true

# Limit is created to prevent MySQL error on index
# length for MyISAM table type: http://bit.ly/vgW2Ql
t.string :context, :limit => 128

t.datetime :created_at
end

add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end

def self.down
drop_table :taggings
drop_table :tags
end
end
28 changes: 27 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120813195820) do
ActiveRecord::Schema.define(:version => 20120819135805) do

create_table "projects", :force => true do |t|
t.string "title"
t.text "description"
t.string "duration"
t.integer "resume_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

create_table "resumes", :force => true do |t|
t.string "first_name"
Expand All @@ -21,4 +30,21 @@
t.datetime "updated_at", :null => false
end

create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.string "tagger_type"
t.string "context", :limit => 128
t.datetime "created_at"
end

add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"

create_table "tags", :force => true do |t|
t.string "name"
end

end
9 changes: 9 additions & 0 deletions spec/factories/projects.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do
factory :project do
title { Faker::Lorem.words(3)}
description { Faker::Lorem.paragraphs(3)}
duration "20 days"
end
end
6 changes: 3 additions & 3 deletions spec/factories/resumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

FactoryGirl.define do
factory :resume do
first_name Faker::Name.first_name
last_name Faker::Name.last_name
intro Faker::Lorem.paragraphs(3)
first_name {Faker::Name.first_name}
last_name {Faker::Name.last_name}
intro {Faker::Lorem.paragraphs(3)}
end

factory :resume_filled_with_data, :parent => :resume do
Expand Down
5 changes: 5 additions & 0 deletions spec/models/project_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe Project do

end
Loading

0 comments on commit c514976

Please sign in to comment.