Browse Source

finish calendar route

Maarten van den Berg 6 years ago
parent
commit
e2a5021a27
2 changed files with 19 additions and 0 deletions
  1. 7 0
      app/controllers/people_controller.rb
  2. 12 0
      app/models/participant.rb

+ 7 - 0
app/controllers/people_controller.rb

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

+ 12 - 0
app/models/participant.rb

39
     HUMAN_ATTENDING[self.attending]
39
     HUMAN_ATTENDING[self.attending]
40
   end
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
   # TODO: Move to a more appropriate place
54
   # TODO: Move to a more appropriate place
43
   # @return [String]
55
   # @return [String]
44
   #   the class for a row containing this activity.
56
   #   the class for a row containing this activity.