Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
f5cbd687
Commit
f5cbd687
authored
May 26, 2017
by
Chrysanthi Lagodimou
Committed by
Tuğçe Nur Taş
Jun 02, 2017
Browse files
introduction of rejection
parent
a19beea7
Changes
11
Hide whitespace changes
Inline
Side-by-side
app/controllers/concerns/nested_attributes.rb
View file @
f5cbd687
...
...
@@ -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
...
...
app/controllers/volunteers_controller.rb
View file @
f5cbd687
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
...
...
app/models/volunteer.rb
View file @
f5cbd687
...
...
@@ -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
app/views/volunteers/_form.html.slim
View file @
f5cbd687
...
...
@@ -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
...
...
app/views/volunteers/show.html.slim
View file @
f5cbd687
...
...
@@ -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?
...
...
config/locales/de.yml
View file @
f5cbd687
...
...
@@ -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
...
...
config/locales/en.yml
View file @
f5cbd687
...
...
@@ -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
...
...
db/migrate/20170526205852_add_rejection_type_to_volunteers.rb
0 → 100644
View file @
f5cbd687
class
AddRejectionTypeToVolunteers
<
ActiveRecord
::
Migration
[
5.1
]
def
change
add_column
:volunteers
,
:rejection_type
,
:string
end
end
db/migrate/20170526205943_add_rejection_text_to_volunteers.rb
0 → 100644
View file @
f5cbd687
class
AddRejectionTextToVolunteers
<
ActiveRecord
::
Migration
[
5.1
]
def
change
add_column
:volunteers
,
:rejection_text
,
:text
end
end
db/schema.rb
View file @
f5cbd687
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20170526
132032
)
do
ActiveRecord
::
Schema
.
define
(
version:
20170526
205943
)
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
...
...
test/application_system_test_case.rb
View file @
f5cbd687
require
'test_helper'
require
'capybara/poltergeist'
DIMENSIONS
=
[
1400
,
3
0
00
].
freeze
DIMENSIONS
=
[
1400
,
3
2
00
].
freeze
Capybara
.
register_driver
:poltergeist_debug
do
|
app
|
Capybara
::
Poltergeist
::
Driver
.
new
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment