diff --git a/Gemfile b/Gemfile index a014b639..514719f6 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ gem 'devise-bootstrap-views' # Integrates Bootstrap Tooltip library with Rails asset pipeline # gem 'bootstrap-tooltip-rails' # Integrates a bootstrap-style datepicker with Rails asset pipeline -# gem 'bootstrap-datepicker-rails' +gem 'bootstrap-datepicker-rails' # Select2 dropdown replacement featuring autocomplete # gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index fbdf5a2a..bf19d0ac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,8 @@ GEM rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bootstrap-datepicker-rails (1.6.4.1) + railties (>= 3.0) builder (3.2.2) byebug (9.0.6) cancancan (1.15.0) @@ -259,6 +261,7 @@ DEPENDENCIES annotate better_errors (~> 2.1.1) binding_of_caller (~> 0.7.2) + bootstrap-datepicker-rails byebug cancancan capybara (~> 2.5) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index bcb49bf3..92f57fb3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,5 +13,7 @@ //= require jquery //= require jquery_ujs //= require twitter/bootstrap +//= require bootstrap-datepicker/core +//= require bootstrap-datepicker/locales/bootstrap-datepicker.de.js //= require turbolinks //= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9cd5b34..d1619b6d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,6 +10,7 @@ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * + *= require bootstrap-datepicker *= require_tree . *= require_self */ diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 73e5410d..f4e79b8f 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -56,6 +56,6 @@ def set_profile # Only allow a trusted parameter "white list" through. def profile_params - params.require(:profile).permit(:cv, :first_name, :last_name, :gender, :birth_date, :email, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in) + params.require(:profile).permit(:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in) end end diff --git a/app/models/profile.rb b/app/models/profile.rb index c854448a..48c21e09 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -3,7 +3,6 @@ # Table name: profiles # # id :integer not null, primary key -# cv :string # user_id :integer not null # created_at :datetime not null # updated_at :datetime not null @@ -12,7 +11,7 @@ class Profile < ActiveRecord::Base belongs_to :user validates :user, presence: true - validates_presence_of :first_name, :last_name, :gender, :birth_date, :email, :school, :street_name, :zip_code, :city, :state, :country + validates_presence_of :first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country def adult?() diff --git a/app/views/profiles/_form.html.erb b/app/views/profiles/_form.html.erb index 81ea18e9..2add2322 100644 --- a/app/views/profiles/_form.html.erb +++ b/app/views/profiles/_form.html.erb @@ -15,20 +15,16 @@ <% end %> -
- <%= f.label :cv, :class => 'control-label col-lg-2' %> -
- <%= f.text_field :cv, :class => 'form-control' %> -
- <%=f.error_span(:cv) %> -
- <%# Create an input field for each of the mandatory attributes%> - <% [:first_name, :last_name, :gender, :birth_date, :email, :school, :street_name, :zip_code, :city, :state, :country].each do |attr_name| %> + <% [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country].each do |attr_name| %>
<%= f.label attr_name, :class => 'control-label col-lg-2 required'%>
- <%= f.text_field attr_name, :class => 'form-control' %> + <% unless attr_name == :birth_date %> + <%= f.text_field attr_name, :class => 'form-control' %> + <% else %> + + <% end %>
<%=f.error_span(attr_name) %>
@@ -53,3 +49,10 @@ <% end %> + + \ No newline at end of file diff --git a/app/views/profiles/index.html.erb b/app/views/profiles/index.html.erb index ca7f959c..abb5f3d4 100644 --- a/app/views/profiles/index.html.erb +++ b/app/views/profiles/index.html.erb @@ -6,7 +6,6 @@ <%= model_class.human_attribute_name(:id) %> - <%= model_class.human_attribute_name(:cv) %> <%= model_class.human_attribute_name(:user_id) %> <%= model_class.human_attribute_name(:created_at) %> <%=t '.actions', :default => t("helpers.actions") %> @@ -17,7 +16,6 @@ <% if can? :destroy, profile %> <%= link_to profile.id, profile_path(profile) %> - <%= profile.cv %> <%= profile.user_id %> <%= profile.created_at %> diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index e10c27ff..3b40771c 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -4,8 +4,6 @@
-
<%= model_class.human_attribute_name(:cv) %>:
-
<%= @profile.cv %>
<%= model_class.human_attribute_name(:user_id) %>:
<%= @profile.user_id %>
<%= model_class.human_attribute_name(:graduates_school_in) %>:
diff --git a/config/locales/de.default.yml b/config/locales/de.default.yml index 533663a2..6b80d60f 100644 --- a/config/locales/de.default.yml +++ b/config/locales/de.default.yml @@ -43,6 +43,7 @@ de: default: "%d.%m.%Y" long: "%e. %B %Y" short: "%e. %b" + datepicker: "dd.mm.yyyy" month_names: - - Januar diff --git a/config/locales/en.default.yml b/config/locales/en.default.yml index b8b3ec95..1ab093f3 100644 --- a/config/locales/en.default.yml +++ b/config/locales/en.default.yml @@ -42,6 +42,7 @@ en: default: "%Y-%m-%d" long: "%B %d, %Y" short: "%b %d" + datepicker: "yyyy-mm-dd" month_names: - - January diff --git a/db/migrate/20161129121741_remove_c_vand_email_from_profile.rb b/db/migrate/20161129121741_remove_c_vand_email_from_profile.rb new file mode 100644 index 00000000..d1ca6af2 --- /dev/null +++ b/db/migrate/20161129121741_remove_c_vand_email_from_profile.rb @@ -0,0 +1,6 @@ +class RemoveCVandEmailFromProfile < ActiveRecord::Migration + def change + remove_column :profiles, :cv, :string + remove_column :profiles, :email, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 0aff5ff6..d3993502 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161125164958) do +ActiveRecord::Schema.define(version: 20161129121741) do create_table "agreement_letters", force: :cascade do |t| t.integer "user_id", null: false @@ -57,7 +57,6 @@ end create_table "profiles", force: :cascade do |t| - t.string "cv" t.integer "user_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false @@ -65,7 +64,6 @@ t.string "last_name" t.string "gender" t.date "birth_date" - t.string "email" t.string "school" t.string "street_name" t.string "zip_code" diff --git a/db/seeds.rb b/db/seeds.rb index ec71cfaf..70f21905 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -40,20 +40,50 @@ # Pupil's profile Profile.find_or_create_by!( - cv: "Ich habe mich zu keiner Veranstaltung beworben", - user: pupil + user: pupil, + first_name: "Karl", + last_name: "Doe", + gender: "männlich", + birth_date: Date.parse('2000.11.29'), + school: "Schule am Griebnitzsee", + street_name: "Rudolf-Breitscheid-Str. 52", + zip_code: "14482", + city: "Potsdam", + state: "Brandenburg", + country: "Deutschland", + graduates_school_in: "2019" ) # Teacher's profile Profile.find_or_create_by!( - cv: "Ich bin ein Lehrer. Ich frage Veranstaltungen für meine Schüler an.", - user: teacher + user: teacher, + first_name: "Ernst", + last_name: "Teacher", + gender: "männlich", + birth_date: Date.parse('1970.1.1'), + school: "Schule am Griebnitzsee", + street_name: "Domstraße 14", + zip_code: "14482", + city: "Potsdam", + state: "Brandenburg", + country: "Deutschland", + graduates_school_in: "Bereits Abitur" ) # Applicant's profile Profile.find_or_create_by!( - cv: "Ich bin ein Schüler, der an Veranstaltungen teilnehmen möchte.", - user: applicant + user: applicant, + first_name: "Erika", + last_name: "Mustermann", + gender: "weiblich", + birth_date: Date.parse('1999.08.14'), + school: "Schule am Griebnitzsee", + street_name: "Rudolf-Breitscheid-Str. 52", + zip_code: "14482", + city: "Potsdam", + state: "Brandenburg", + country: "Deutschland", + graduates_school_in: "2017" ) # Teacher's event request diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 0788b83a..e06a4aa0 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -109,14 +109,12 @@ context "with valid params" do let(:new_attributes) { { - cv: "Awesome new CV", first_name: "Karl", last_name: "Doe", gender: "männlich", birth_date: 15.years.ago, - email: "karl@doe.com", school: "Schule am Griebnitzsee", - street_name: "Rudolf-Breitscheid-Str. 52", + street_name: "August-Bebel-Str. 88", zip_code: "14482", city: "Potsdam", state: "Babelsberg", @@ -130,7 +128,7 @@ sign_in profile.user put :update, id: profile.to_param, profile: new_attributes, session: valid_session profile.reload - expect(profile.cv).to eq(new_attributes[:cv]) + expect(profile.street_name).to eq(new_attributes[:street_name]) end it "assigns the requested profile as @profile" do diff --git a/spec/factories/profiles.rb b/spec/factories/profiles.rb index 11cff916..bcb2df7b 100644 --- a/spec/factories/profiles.rb +++ b/spec/factories/profiles.rb @@ -3,7 +3,6 @@ # Table name: profiles # # id :integer not null, primary key -# cv :string # user_id :integer not null # created_at :datetime not null # updated_at :datetime not null @@ -11,12 +10,10 @@ FactoryGirl.define do factory :profile do - cv "MyString" first_name "Karl" last_name "Doe" gender "männlich" birth_date 15.years.ago - email "karl@doe.com" school "Schule am Griebnitzsee" street_name "Rudolf-Breitscheid-Str. 52" zip_code "14482" diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index 7096abbd..137a13a8 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -56,7 +56,6 @@ fill_in "profile_last_name", with: "Doe" fill_in "profile_gender", with: "männlich" fill_in "profile_birth_date", with: "" - fill_in "profile_email", with: "karl@doe.com" fill_in "profile_school", with: "" fill_in "profile_street_name", with: "Rudolf-Breitscheid-Str. 52" fill_in "profile_zip_code", with: "14482" diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index fee74ea6..7cd8f7b3 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -3,7 +3,6 @@ # Table name: profiles # # id :integer not null, primary key -# cv :string # user_id :integer not null # created_at :datetime not null # updated_at :datetime not null @@ -24,7 +23,7 @@ end it "cannot create Profile without mandatory fields" do - [:first_name, :last_name, :gender, :birth_date, :email, :school, :street_name, :zip_code, :city, :state, :country].each do |attr| + [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country].each do |attr| profile = FactoryGirl.build(:profile, attr => nil) expect(profile).to_not be_valid end diff --git a/spec/views/profiles/edit.html.erb_spec.rb b/spec/views/profiles/edit.html.erb_spec.rb index 13ffb431..6bebc23b 100644 --- a/spec/views/profiles/edit.html.erb_spec.rb +++ b/spec/views/profiles/edit.html.erb_spec.rb @@ -9,12 +9,10 @@ render assert_select "form[action=?][method=?]", profile_path(@profile), "post" do - assert_select "input#profile_cv[name=?]", "profile[cv]" assert_select "input#profile_first_name[name=?]", "profile[first_name]" assert_select "input#profile_last_name[name=?]", "profile[last_name]" assert_select "input#profile_gender[name=?]", "profile[gender]" assert_select "input#profile_birth_date[name=?]", "profile[birth_date]" - assert_select "input#profile_email[name=?]", "profile[email]" assert_select "input#profile_school[name=?]", "profile[school]" assert_select "input#profile_street_name[name=?]", "profile[street_name]" assert_select "input#profile_zip_code[name=?]", "profile[zip_code]" diff --git a/spec/views/profiles/new.html.erb_spec.rb b/spec/views/profiles/new.html.erb_spec.rb index 16b12b17..fd8bfead 100644 --- a/spec/views/profiles/new.html.erb_spec.rb +++ b/spec/views/profiles/new.html.erb_spec.rb @@ -9,7 +9,7 @@ render assert_select "form[action=?][method=?]", profiles_path, "post" do - assert_select "input#profile_cv[name=?]", "profile[cv]" + assert_select "input#profile_first_name[name=?]", "profile[first_name]" end end end diff --git a/spec/views/profiles/show.html.erb_spec.rb b/spec/views/profiles/show.html.erb_spec.rb index ee0677ca..0163dbea 100644 --- a/spec/views/profiles/show.html.erb_spec.rb +++ b/spec/views/profiles/show.html.erb_spec.rb @@ -7,7 +7,7 @@ it "renders attributes" do render - expect(rendered).to have_text(@profile.cv) + expect(rendered).to have_text(@profile.graduates_school_in) end it "renders the events table" do