mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-06-01 12:49:59 -04:00
* Implement activities * Add activities to timeline * Add factory * Add coverage * Fix misc issues * Activities display * Add activities to garden and plantings * Add activities to garden and plantings * Add planting * Add to planting, harvest show * More CRUD * More CRUD * index * index * Extract card view * Permissions * Add edit * Remove workaround fro vs code * Fix title * CSV * CSV * Add RSS, ical * Extend ical slightly * Cleanup * Rubocop * Remove doubled form * Change icon * Fix short description * Add menus * Put homepage widget in * Add activity icon - MIT licenced - https://www.svgrepo.com/svg/336823/plan * Naming * Missing files * Revert VS Code lag induced change * Update app/views/home/_harvests.html.haml * Update activities_controller.rb * Update activities_controller.rb * Update app/controllers/activities_controller.rb * Update index.html.haml * Apply suggestions from code review * Apply suggestions from code review * Typo * Translation * Apply suggestions from code review * Update app/views/plantings/index.ics.erb * Update app/models/activity.rb * Update plantings_spec.rb * Update plantings_spec.rb * We are now rendering an extra event, so check the next one for the old behaviour
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
<%
|
|
# TODO Refactor to a Activity <-> Ical view class?
|
|
cal = Icalendar::Calendar.new
|
|
cal.description = "Activities by #{@owner.login_name}"
|
|
@activities.each do |activity|
|
|
|
|
event = Icalendar::Event.new
|
|
|
|
lines = []
|
|
lines << "Garden: #{activity['garden_name'] ? activity['garden_name'] : 'N/A' }"
|
|
lines << "Planting: #{activity['planting_name'] ? activity['planting_name'] : 'N/A' }"
|
|
|
|
lines << activity.description
|
|
finish_date = Date.parse(activity['due_date']) rescue nil
|
|
|
|
event.dtstart = Time.at(activity['created_at'])
|
|
event.dtend = finish_date || 1.day.from_now
|
|
event.summary = "#{activity['name']} - #{activity['category']}"
|
|
event.description = lines.join("\n")
|
|
event.ip_class = "PUBLIC"
|
|
event.url = activity_url(slug: activity['slug'])
|
|
|
|
cal.add_event(event)
|
|
|
|
if finish_date && finish_date > Date.today
|
|
todo = Icalendar::Todo.new
|
|
todo.dtstart = finish_date || Date.today
|
|
todo.due = finish_date
|
|
todo.summary = "#{activity['name']} - #{activity['category']}"
|
|
todo.description = lines.join("\n")
|
|
|
|
cal.add_todo(todo)
|
|
end
|
|
end
|
|
cal.publish
|
|
%>
|
|
<%= cal.to_ical %>
|