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
0e50d5c0
Verified
Commit
0e50d5c0
authored
Jan 31, 2018
by
Kaspar Vollenweider
👻
Browse files
fix some stuff from review
parent
6e5e46b4
Pipeline
#13815
failed with stage
in 19 minutes and 41 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/group_assignments_controller.rb
View file @
0e50d5c0
...
...
@@ -22,12 +22,9 @@ class GroupAssignmentsController < ApplicationController
def
update
@group_assignment
.
assign_attributes
(
group_assignment_params
)
if
@group_assignment
.
will_save_change_to_period_end?
&&
@group_assignment
.
ended?
@group_assignment
.
period_end_set_by
=
current_user
period_end_set_notice
=
'Einsatzende wurde erfolgreich gesetzt.'
end
period_end_set_notice
,
redirect_action
=
handle_period_end
if
@group_assignment
.
save
create_redirect_to
(
period_end_set_notice
)
create_redirect_to
(
period_end_set_notice
,
action:
redirect_action
)
else
render
:edit
end
...
...
@@ -78,9 +75,20 @@ class GroupAssignmentsController < ApplicationController
private
def
create_redirect_to
(
notice_text
=
nil
)
def
handle_period_end
if
@group_assignment
.
will_save_change_to_period_end?
(
from:
nil
)
&&
@group_assignment
.
ending?
@group_assignment
.
period_end_set_by
=
current_user
[
'Einsatzende wurde erfolgreich gesetzt.'
,
params
[
:redirect_to
]
||
:terminated_group_assignments_index
]
end
end
def
create_redirect_to
(
notice_text
=
nil
,
action:
nil
)
action
||=
params
[
:redirect_to
]
unless
params
[
:redirect_to
]
==
'show'
redirect_to
(
polymorphic_path
(
@group_assignment
.
group_offer
,
action:
params
[
:redirect_to
]
),
polymorphic_path
(
@group_assignment
.
group_offer
,
action:
action
),
notice:
notice_text
||
make_notice
[
:notice
]
)
end
...
...
app/controllers/group_offers_controller.rb
View file @
0e50d5c0
...
...
@@ -84,7 +84,7 @@ class GroupOffersController < ApplicationController
def
submit_initiate_termination
if
@group_offer
.
update
(
period_end:
group_offer_params
[
:period_end
],
period_end_set_by:
current_user
)
redirect_to
group_offers_path
,
notice:
'Gruppenangebots
b
eendigung erfolgreich eingeleitet.'
redirect_to
group_offers_path
,
notice:
'Gruppenangebots
B
eendigung erfolgreich eingeleitet.'
else
render
:initiate_termination
end
...
...
app/models/concerns/group_assignment_and_assignment_common.rb
View file @
0e50d5c0
...
...
@@ -104,7 +104,11 @@ module GroupAssignmentAndAssignmentCommon
end
def
ended?
period_start
.
present?
&&
period_end
.
present?
&&
period_end
<=
Time
.
zone
.
today
ending?
&&
period_end
<=
Time
.
zone
.
today
end
def
ending?
period_start
.
present?
&&
period_end
.
present?
end
end
end
app/models/group_offer.rb
View file @
0e50d5c0
...
...
@@ -51,7 +51,7 @@ class GroupOffer < ApplicationRecord
group_assignments
.
active_between
(
start_date
,
end_date
).
any?
end
def
end
able?
def
terminat
able?
group_assignments
.
have_start
.
any?
||
group_assignment_logs
.
any?
end
...
...
app/views/group_offers/index.html.slim
View file @
0e50d5c0
...
...
@@ -96,7 +96,7 @@ table.table.table-striped
-
if
offer
.
period_end
.
blank?
=
link_to
"
#{
offer
.
active?
?
t
(
'.deactivate'
)
:
t
(
'.activate'
)
}
"
,
change_active_state_group_offer_path
(
offer
),
method: :put
,
remote: :true
=
link_to_if
(
policy
(
offer
).
initiate_termination?
&&
offer
.
end
able?
,
=
link_to_if
(
policy
(
offer
).
initiate_termination?
&&
offer
.
terminat
able?
,
'Beenden'
,
initiate_termination_group_offer_path
(
offer
))
{
''
}
...
...
app/views/group_offers/show.html.slim
View file @
0e50d5c0
...
...
@@ -73,7 +73,7 @@ h2= @group_offer.title
-
if
@group_offer
.
group_assignments
.
any?
h2
Aktuelle
Gruppeneinsä
tze
=
render
'group_assignments_index',
group_assignments:
@group_offer
.group_assignments
=
render
'group_assignments_index',
group_assignments:
@group_offer
.group_assignments
,
redirect_to_action:
:show
-
if
@group_offer
.
group_assignment_logs
.
any?
h2
Archivierte
Gruppeneinsätze
...
...
Write
Preview
Supports
Markdown
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