Commit f5cbd687 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou Committed by Tuğçe Nur Taş
Browse files

introduction of rejection

parent a19beea7
......@@ -4,11 +4,11 @@ module NestedAttributes
included do
def volunteer_attributes
[:first_name, :last_name, :date_of_birth, :gender, :avatar, :street,
:zip, :city, :nationality, :additional_nationality, :email, :phone,
:profession, :education, :motivation, :experience, :expectations,
:strengths, :skills, :interests, :state, :duration, :man, :woman,
:family, :kid, :sport, :creative, :music, :culture, :training,
:german_course, :adults, :teenagers, :children, :region]
:zip, :city, :nationality, :additional_nationality, :email, :phone,
:profession, :education, :motivation, :experience, :expectations,
:strengths, :skills, :interests, :state, :rejection_type, :rejection_text,
:duration, :man, :woman, :family, :kid, :sport, :creative, :music, :culture,
:training, :german_course, :adults, :teenagers, :children, :region]
end
def language_skills_attributes
......
class VolunteersController < ApplicationController
include NestedAttributes
before_action :set_volunteer, only: [:show, :edit, :update, :destroy]
before_action :set_state, only: [:update]
def index
@volunteers = Volunteer.all
......@@ -26,7 +27,7 @@ class VolunteersController < ApplicationController
def update
if @volunteer.update(volunteer_params)
if @volunteer.state == 'accepted'
if @state == Volunteer::INTERESTED && @volunteer.state == Volunteer::ACCEPTED
new_user = User.new(email: @volunteer.email,
password: Devise.friendly_token, role: 'volunteer')
new_user.save
......@@ -47,6 +48,10 @@ class VolunteersController < ApplicationController
private
def set_state
@state = @volunteer.state
end
def set_volunteer
@volunteer = Volunteer.find(params[:id])
end
......
......@@ -27,6 +27,10 @@ class Volunteer < ApplicationRecord
state == Volunteer::INTERESTED
end
def rejected?
state == Volunteer::REJECTED
end
def self.duration_collection
[:short, :long]
end
......@@ -54,4 +58,8 @@ class Volunteer < ApplicationRecord
STATES_FOR_REVIEWED.map(&:to_sym)
end
end
def self.rejection_collection
[:us, :her, :other]
end
end
......@@ -62,6 +62,10 @@
.row
.col-xs-12
= f.input :state, collection: Volunteer.state_collection(@volunteer)
.col-xs-12
= f.input :rejection_type, collection: Volunteer.rejection_collection, as: :radio_buttons
.col-xs-12
= f.input :rejection_text
.row
.col-xs-12
......
......@@ -69,6 +69,13 @@
tr
td= t_attr(:state)
td= t("state.#{@volunteer.state}")
- if @volunteer.rejected?
tr
td= t_attr(:rejection_type)
td= t("rejection_type.#{@volunteer.rejection_type}")
tr
td= t_attr(:rejection_text)
td= @volunteer.rejection_text
tr
td= t_attr(:duration)
td= t("duration.#{@volunteer.duration}") unless @volunteer.duration.blank?
......
......@@ -114,6 +114,8 @@ de:
nationality: Nationalität
phone: Telefonnummer
profession: Beruf
rejection_text: Erläuterung zur Ablehnung
rejection_type: Grund für die Ablehnung
skills: Kompetenzen
sport: Sport
state: Status
......@@ -338,6 +340,10 @@ de:
personal_background: Persönlicher Hintergrund
profile_created: Profil wurde erfolgreich erstellt.
profile_updated: Profil wurde erfolgreich aktualisiert.
rejection_type:
her: von Freiwillige vor / nach Erstgespräch
other: Anderer Grund
us: durch uns vor / nach Gespräch
region:
canton: Kanton
city: Stadt
......@@ -420,6 +426,10 @@ de:
canton: Kanton
city: Stadt
region: Region
rejection_type:
her: von Freiwillige vor / nach Erstgespräch
other: Anderer Grund
us: durch uns vor / nach Gespräch
state:
accepted: Akzeptiert
inactive: Inaktiv
......
......@@ -35,6 +35,8 @@ en:
email: Email
volunteer:
duration: Duration of the accompaniment
rejection_text: Explanation for rejection
rejection_type: Reason for rejection
models:
client: Client
contact: Contact
......@@ -212,6 +214,10 @@ en:
city: City
region: Region
registered_by: Responsible Volunteer
rejection_type:
her: by volunteer before / after the first call
other: Other
us: by us before / after conversation
relatives: Family members
remember_me: Remember me
remove_language: Remove language
......@@ -267,6 +273,10 @@ en:
canton: Canton
city: City
region: Region
rejection_type:
her: by volunteer before / after the first call
other: Other
us: by us before / after conversation
state:
accepted: Accepted
inactive: Inactive
......
class AddRejectionTypeToVolunteers < ActiveRecord::Migration[5.1]
def change
add_column :volunteers, :rejection_type, :string
end
end
class AddRejectionTextToVolunteers < ActiveRecord::Migration[5.1]
def change
add_column :volunteers, :rejection_text, :text
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170526132032) do
ActiveRecord::Schema.define(version: 20170526205943) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -216,6 +216,8 @@ ActiveRecord::Schema.define(version: 20170526132032) do
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.bigint "user_id"
t.string "rejection_type"
t.text "rejection_text"
t.index ["deleted_at"], name: "index_volunteers_on_deleted_at"
t.index ["user_id"], name: "index_volunteers_on_user_id"
end
......
require 'test_helper'
require 'capybara/poltergeist'
DIMENSIONS = [1400, 3000].freeze
DIMENSIONS = [1400, 3200].freeze
Capybara.register_driver :poltergeist_debug do |app|
Capybara::Poltergeist::Driver.new(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment