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
d6b7b0ae
Commit
d6b7b0ae
authored
May 17, 2017
by
Chrysanthi Lagodimou
Browse files
schedule as schedulable in views and controller
parent
aff62930
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/controllers/volunteers_controller.rb
View file @
d6b7b0ae
...
...
@@ -9,6 +9,7 @@ class VolunteersController < ApplicationController
def
new
@volunteer
=
Volunteer
.
new
@volunteer
.
schedules
<<
Schedule
.
build
end
def
edit
;
end
...
...
@@ -52,6 +53,9 @@ class VolunteersController < ApplicationController
],
relatives_attributes:
[
:id
,
:first_name
,
:last_name
,
:date_of_birth
,
:relation
,
:_destroy
],
schedules_attributes:
[
:id
,
:day
,
:time
,
:available
])
end
end
app/views/volunteers/_form.html.slim
View file @
d6b7b0ae
...
...
@@ -132,6 +132,28 @@
.col-xs-12
=
f
.
input
:region
,
collection:
Volunteer
.
region_collection
,
as: :radio_buttons
,
label:
false
.row
.col-xs-12
h3
=
t
(
'schedule'
)
.row
.col-xs-12
table
.table.table-striped
thead
tr
th
=
t
(
'when'
)
-
Schedule
.
days
.
each
do
|
day
|
th
.days
=
t
(
"weekdays.
#{
day
}
"
)
tbody
-
@volunteer
.
schedules
.
group_by
(
&
:time
).
each
do
|
time
,
schedules
|
tr
td
=
t
(
"times.
#{
time
}
"
)
=
f
.
simple_fields_for
:schedules
,
schedules
do
|
schedule
|
td
=
schedule
.
input
:day
,
as: :hidden
=
schedule
.
input
:time
,
as: :hidden
=
schedule
.
input
:available
,
as: :boolean
,
label:
false
.row
.col-xs-12
=
f
.
button
:submit
,
class:
'btn btn-success'
app/views/volunteers/show.html.slim
View file @
d6b7b0ae
...
...
@@ -113,6 +113,30 @@
-
else
i
.glyphicon.glyphicon-remove.text-danger
.row
.col-xs-12
h3
=
t
(
'schedule'
)
.row
.col-xs-12
table
.table.table-striped
thead
tr
th
=
t
(
'when'
)
-
Schedule
.
days
.
each
do
|
day
|
th
.text-center
=
t
(
"weekdays.
#{
day
}
"
)
tbody
-
@client
.
schedules
.
group_by
(
&
:time
).
each
do
|
time
,
schedules
|
tr
td
=
t
(
"times.
#{
time
}
"
)
-
schedules
.
each
do
|
schedule
|
td
.text-center
-
if
schedule
.
available
i
.glyphicon.glyphicon-ok.text-success
-
else
i
.glyphicon.glyphicon-remove.text-danger
.row
.col-xs-12
=
link_to
t_action
(
:edit
),
edit_volunteer_path
(
@volunteer
),
class:
'btn btn-default'
...
...
test/factories/schedules.rb
View file @
d6b7b0ae
FactoryGirl
.
define
do
factory
:schedule
do
client
day
' '
time
' '
end
...
...
test/system/volunteers_test.rb
View file @
d6b7b0ae
...
...
@@ -43,6 +43,7 @@ class VolunteersTest < ApplicationSystemTestCase
page
.
check
(
'volunteer_training'
)
page
.
check
(
'volunteer_adults'
)
page
.
choose
(
'volunteer_region_canton'
)
page
.
check
(
'volunteer_schedules_attributes_17_available'
)
click_button
'Create Volunteer'
assert
page
.
has_text?
'Volunteer was successfully created.'
...
...
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