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
5b255d83
Commit
5b255d83
authored
Oct 18, 2017
by
Tugce Nur Tas
Committed by
Tuğçe Nur Taş
Oct 18, 2017
Browse files
add assignments started method for hours
parent
b7e377da
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/models/group_assignment.rb
View file @
5b255d83
...
...
@@ -6,6 +6,7 @@ class GroupAssignment < ApplicationRecord
after_update
:save_group_assignment_logs
,
if: :dates_updated?
before_destroy
:save_group_assignment_logs
scope
:started
,
(
->
{
where
(
'period_start < ?'
,
Time
.
zone
.
today
)
})
scope
:ongoing
,
(
->
{
where
(
'group_assignments.period_end > ?'
,
Time
.
zone
.
today
)
})
scope
:no_end
,
(
->
{
where
(
period_end:
nil
)
})
...
...
app/models/volunteer.rb
View file @
5b255d83
...
...
@@ -157,6 +157,14 @@ class Volunteer < ApplicationRecord
assignments
.
size
.
positive?
end
def
assignment_started?
assignments
.
started
.
size
.
positive?
end
def
group_assignment_stared?
group_assignments
.
started
.
size
.
positive?
end
def
external?
external
end
...
...
@@ -165,8 +173,8 @@ class Volunteer < ApplicationRecord
!
external
end
def
internal_and_assignments?
internal?
&&
assignment
s
?
def
internal_and_
started_
assignments?
internal?
&&
assignment
_started?
||
group_assignment_stared
?
end
def
self_applicant?
...
...
app/views/volunteers/show.html.slim
View file @
5b255d83
...
...
@@ -23,7 +23,7 @@ nav.navbar.section-navigation
-
elsif
@volunteer
.
certificates
.
size
>
1
li
=
button_link
t
(
'.show_certificates'
),
volunteer_certificates_path
(
@volunteer
)
ul
.list-inline
-
if
@volunteer
.
internal_and_assignments?
-
if
@volunteer
.
internal_and_
started_
assignments?
li
=
button_link
t
(
'.report_hours'
),
new_volunteer_hour_url
(
@volunteer
)
li
=
button_link
t
(
'.hour_reports'
),
volunteer_hours_path
(
@volunteer
)
li
=
button_link
current_user
.
volunteer?
?
t
(
'edit_profile'
)
:
t_title
(
:edit
),
edit_volunteer_path
(
@volunteer
)
...
...
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