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
51f5ac51
Verified
Commit
51f5ac51
authored
Jan 30, 2018
by
Kaspar Vollenweider
👻
Browse files
fix only reasonable group_offers have end link
parent
6818d9dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models/concerns/group_assignment_and_assignment_common.rb
View file @
51f5ac51
...
...
@@ -34,6 +34,7 @@ module GroupAssignmentAndAssignmentCommon
scope
:started_ca_six_weeks_ago
,
lambda
{
start_at_or_after
(
8
.
weeks
.
ago
).
start_at_or_before
(
6
.
weeks
.
ago
)
}
scope
:no_start_and_end
,
(
->
{
no_start
.
no_end
})
scope
:with_hours
,
(
->
{
joins
(
:hours
)
})
...
...
@@ -42,7 +43,7 @@ module GroupAssignmentAndAssignmentCommon
}
scope
:active
,
(
->
{
not_ended
.
started
.
or
(
no_start
.
end_in_future
)
})
scope
:stay_active
,
(
->
{
active
.
no_end
})
scope
:inactive
,
(
->
{
ended
.
or
(
no_start
.
no
_end
).
or
(
will_start
)
})
scope
:inactive
,
(
->
{
ended
.
or
(
no_start
_and
_end
).
or
(
will_start
)
})
scope
:active_between
,
lambda
{
|
start_date
,
end_date
|
no_end
.
start_before
(
end_date
)
.
or
(
start_before
(
end_date
).
end_after
(
start_date
))
...
...
app/models/group_offer.rb
View file @
51f5ac51
...
...
@@ -33,11 +33,10 @@ class GroupOffer < ApplicationRecord
validates
:necessary_volunteers
,
numericality:
{
greater_than:
0
},
allow_nil:
true
validates
:period_end
,
absence:
{
message:
lambda
{
|
object
,
_
|
'Dieses Gruppenangebot kann noch nicht beendet werden, da es noch '
\
"
#{
object
.
group_assignments
.
running
.
count
}
laufende Gruppeneinsätze hat."
}
},
if: :running_assignments?
'Dieses Gruppenangebot kann noch nicht beendet werden, da es noch '
\
"
#{
object
.
group_assignments
.
running
.
count
}
laufende Gruppeneinsätze hat."
}
},
if: :running_assignments?
scope
:active
,
(
->
{
where
(
active:
true
)
})
scope
:inactive
,
(
->
{
where
(
active:
false
)
})
...
...
@@ -52,6 +51,10 @@ class GroupOffer < ApplicationRecord
group_assignments
.
active_between
(
start_date
,
end_date
).
any?
end
def
endable?
group_assignments
.
have_start
.
any?
||
group_assignment_logs
.
any?
end
def
all_group_assignments_ended_within?
(
date_range
)
ended_within
=
group_assignments
.
end_within
(
date_range
).
ids
not_end_before
=
group_assignments
.
end_after
(
date_range
.
last
).
ids
...
...
app/views/group_offers/index.html.slim
View file @
51f5ac51
...
...
@@ -93,7 +93,7 @@ table.table.table-striped
=
link_to
t_action
(
:show
),
group_offer_path
(
offer
)
=
link_to
t
(
'download'
),
group_offer_path
(
offer
,
format: :pdf
)
=
link_to
t_action
(
:edit
),
edit_group_offer_path
(
offer
)
-
if
offer
.
period_end
.
blank?
-
if
offer
.
period_end
.
blank?
&&
offer
.
endable?
=
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?
,
'Beenden'
,
initiate_termination_group_offer_path
(
offer
))
{
''
}
...
...
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