Skip to content

Commit

Permalink
Merge branch 'dev' into 25_4.1_LetterOfAgreement
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaidd-Drwg committed Nov 29, 2016
2 parents 26f7ff6 + bdd0e79 commit bf64e6f
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -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 .
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Expand Up @@ -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
*/
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Expand Up @@ -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
3 changes: 1 addition & 2 deletions app/models/profile.rb
Expand Up @@ -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
Expand All @@ -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?()
Expand Down
23 changes: 13 additions & 10 deletions app/views/profiles/_form.html.erb
Expand Up @@ -15,20 +15,16 @@
</div>
<% end %>
<div class="form-group">
<%= f.label :cv, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.text_field :cv, :class => 'form-control' %>
</div>
<%=f.error_span(:cv) %>
</div>

<%# 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| %>
<div class="form-group">
<%= f.label attr_name, :class => 'control-label col-lg-2 required'%>
<div class="col-lg-10">
<%= f.text_field attr_name, :class => 'form-control' %>
<% unless attr_name == :birth_date %>
<%= f.text_field attr_name, :class => 'form-control' %>
<% else %>
<input id="profile_birth_date" class="form-control datepicker" data-provide="datepicker" value="<%=I18n.l @profile.public_send(attr_name) if @profile.public_send(attr_name)%>" name="profile[birth_date]" type="text">
<% end %>
</div>
<%=f.error_span(attr_name) %>
</div>
Expand All @@ -53,3 +49,10 @@
</div>

<% end %>

<script>
$('.datepicker').datepicker({
language:"<%= I18n.locale %>",
format: "<%= I18n.t('date.formats.datepicker')%>",
});
</script>
2 changes: 0 additions & 2 deletions app/views/profiles/index.html.erb
Expand Up @@ -6,7 +6,6 @@
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:cv) %></th>
<th><%= model_class.human_attribute_name(:user_id) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
<th><%=t '.actions', :default => t("helpers.actions") %></th>
Expand All @@ -17,7 +16,6 @@
<% if can? :destroy, profile %>
<tr>
<td><%= link_to profile.id, profile_path(profile) %></td>
<td><%= profile.cv %></td>
<td><%= profile.user_id %></td>
<td><%= profile.created_at %></td>
<td>
Expand Down
2 changes: 0 additions & 2 deletions app/views/profiles/show.html.erb
Expand Up @@ -4,8 +4,6 @@
</div>

<dl class="dl-horizontal">
<dt><strong><%= model_class.human_attribute_name(:cv) %>:</strong></dt>
<dd><%= @profile.cv %></dd>
<dt><strong><%= model_class.human_attribute_name(:user_id) %>:</strong></dt>
<dd><%= @profile.user_id %></dd>
<dt><strong><%= model_class.human_attribute_name(:graduates_school_in) %>:</strong></dt>
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.default.yml
Expand Up @@ -43,6 +43,7 @@ de:
default: "%d.%m.%Y"
long: "%e. %B %Y"
short: "%e. %b"
datepicker: "dd.mm.yyyy"
month_names:
-
- Januar
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.default.yml
Expand Up @@ -42,6 +42,7 @@ en:
default: "%Y-%m-%d"
long: "%B %d, %Y"
short: "%b %d"
datepicker: "yyyy-mm-dd"
month_names:
-
- January
Expand Down
6 changes: 6 additions & 0 deletions 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
4 changes: 1 addition & 3 deletions db/schema.rb
Expand Up @@ -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
Expand Down Expand Up @@ -57,15 +57,13 @@
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
t.string "first_name"
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"
Expand Down
42 changes: 36 additions & 6 deletions db/seeds.rb
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions spec/controllers/profiles_controller_spec.rb
Expand Up @@ -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",
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions spec/factories/profiles.rb
Expand Up @@ -3,20 +3,17 @@
# 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
#

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"
Expand Down
1 change: 0 additions & 1 deletion spec/features/profile_spec.rb
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions spec/models/profile_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/views/profiles/edit.html.erb_spec.rb
Expand Up @@ -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]"
Expand Down
2 changes: 1 addition & 1 deletion spec/views/profiles/new.html.erb_spec.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/views/profiles/show.html.erb_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit bf64e6f

Please sign in to comment.