|
@@ -18,47 +18,40 @@ class Api::ActivitiesController < ApiController
|
18
|
18
|
end
|
19
|
19
|
|
20
|
20
|
# GET /api/activities/1
|
21
|
|
- def show
|
22
|
|
- end
|
|
21
|
+ def show; end
|
23
|
22
|
|
24
|
23
|
# GET /api/activities/1/response_summary
|
25
|
24
|
def response_summary
|
26
|
25
|
as = @activity
|
27
|
|
- .participants
|
28
|
|
- .joins(:person)
|
29
|
|
- .order('people.first_name ASC')
|
|
26
|
+ .participants
|
|
27
|
+ .joins(:person)
|
|
28
|
+ .order('people.first_name ASC')
|
30
|
29
|
|
31
|
|
- present = as
|
32
|
|
- .where(attending: true)
|
|
30
|
+ present = as.where(attending: true)
|
33
|
31
|
|
34
|
|
- unknown = as
|
35
|
|
- .where(attending: nil)
|
|
32
|
+ unknown = as.where(attending: nil)
|
36
|
33
|
|
37
|
|
- absent = as
|
38
|
|
- .where(attending: false)
|
|
34
|
+ absent = as.where(attending: false)
|
39
|
35
|
|
40
|
|
- presentnames = present
|
41
|
|
- .map{|p| p.person.first_name }
|
|
36
|
+ presentnames = present.map{|p| p.person.first_name }
|
42
|
37
|
|
43
|
|
- unknownnames = unknown
|
44
|
|
- .map{|p| p.person.first_name }
|
|
38
|
+ unknownnames = unknown.map{|p| p.person.first_name }
|
45
|
39
|
|
46
|
|
- absentnames = absent
|
47
|
|
- .map{|p| p.person.first_name }
|
|
40
|
+ absentnames = absent.map{|p| p.person.first_name }
|
48
|
41
|
|
49
|
|
- if presentnames.count > 0
|
|
42
|
+ if presentnames.positive?
|
50
|
43
|
present_mess = I18n.t('activities.participant.these_present', count: present.count, names: presentnames.join(', '))
|
51
|
44
|
else
|
52
|
45
|
present_mess = I18n.t('activities.participant.none_present')
|
53
|
46
|
end
|
54
|
47
|
|
55
|
|
- if unknownnames.count > 0
|
|
48
|
+ if unknownnames.positive?
|
56
|
49
|
unknown_mess = I18n.t('activities.participant.these_unknown', count: unknown.count, names: unknownnames.join(', '))
|
57
|
50
|
else
|
58
|
51
|
unknown_mess = I18n.t('activities.participant.none_unknown')
|
59
|
52
|
end
|
60
|
53
|
|
61
|
|
- if absentnames.count > 0
|
|
54
|
+ if absentnames.positive?
|
62
|
55
|
absent_mess = I18n.t('activities.participant.these_absent', count: absent.count, names: absentnames.join(', '))
|
63
|
56
|
else
|
64
|
57
|
absent_mess = I18n.t('activities.participant.none_absent')
|
|
@@ -83,6 +76,16 @@ class Api::ActivitiesController < ApiController
|
83
|
76
|
}
|
84
|
77
|
end
|
85
|
78
|
|
|
79
|
+ def presence
|
|
80
|
+ participant = Participant.find_by(
|
|
81
|
+ person_id: params[:person_id],
|
|
82
|
+ activity: @activity
|
|
83
|
+ )
|
|
84
|
+
|
|
85
|
+ participant.update_attributes(params.permit(:attending))
|
|
86
|
+ head :no_content
|
|
87
|
+ end
|
|
88
|
+
|
86
|
89
|
private
|
87
|
90
|
|
88
|
91
|
# Set activity from the :id-parameter
|