ソースを参照

finish calendar route

Maarten van den Berg 6 年 前
コミット
e2a5021a27
共有2 個のファイルを変更した19 個の追加0 個の削除を含む
  1. 7 0
      app/controllers/people_controller.rb
  2. 12 0
      app/models/participant.rb

+ 7 - 0
app/controllers/people_controller.rb

@@ -94,6 +94,8 @@ class PeopleController < ApplicationController
94 94
     cal = Icalendar::Calendar.new
95 95
 
96 96
     @person.participants.joins(:activity).where('end > ?', 3.months.ago).each do |p|
97
+      next if !p.attending && params[:skipcancel]
98
+
97 99
       a = p.activity
98 100
       description_items = [a.description]
99 101
       orgi = a.organizer_names
@@ -118,10 +120,15 @@ class PeopleController < ApplicationController
118 120
 
119 121
       cal.event do |e|
120 122
         e.uid = group_activity_url a.group, a
123
+        e.ip_class = "PRIVATE"
121 124
         e.dtstart = a.start
122 125
         e.dtend = a.end
126
+
127
+        e.status = p.ical_attending
128
+
123 129
         e.summary = a.name
124 130
         e.location = a.location
131
+
125 132
         e.description = description_items.join "\n"
126 133
 
127 134
         e.url = group_activity_url a.group, a

+ 12 - 0
app/models/participant.rb

@@ -39,6 +39,18 @@ class Participant < ApplicationRecord
39 39
     HUMAN_ATTENDING[self.attending]
40 40
   end
41 41
 
42
+  ICAL_ATTENDING = {
43
+    true => 'ATTENDING',
44
+    false => 'CANCELLED',
45
+    nil => 'TENTATIVE'
46
+  }
47
+
48
+  # @return [String]
49
+  #   the ICal attending response.
50
+  def ical_attending
51
+    ICAL_ATTENDING[self.attending]
52
+  end
53
+
42 54
   # TODO: Move to a more appropriate place
43 55
   # @return [String]
44 56
   #   the class for a row containing this activity.