From 6def16fd45f28a1ed26789059de05fd59162b15b Mon Sep 17 00:00:00 2001 From: Andreas Treubert Date: Thu, 12 Sep 2024 09:56:55 +0200 Subject: [PATCH] ical feature --- app/controllers/calendar_controller.rb | 8 +++++++- init.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/calendar_controller.rb b/app/controllers/calendar_controller.rb index 7d06d84..c5852a3 100644 --- a/app/controllers/calendar_controller.rb +++ b/app/controllers/calendar_controller.rb @@ -82,7 +82,13 @@ def export ical = Vpim::Icalendar.create({ 'METHOD' => 'REQUEST', 'CHARSET' => 'UTF-8' }) time_start = params['time_start'] time_end = params['time_end'] - Issue.where(["(issues.start_date IS NOT NULL OR issues.due_date IS NOT NULL) AND ((issues.start_date >= ? AND issues.start_date <= ?) OR (issues.due_date >= ? AND issues.due_date <= ?))", time_start, time_end, time_start, time_end]).each do |issue| + time_start = Date.today.to_s if time_start.nil? + time_end = (Date.today + 2.years).to_s if time_end.nil? + issues = Issue.where(["(issues.start_date IS NOT NULL OR issues.due_date IS NOT NULL) AND ((issues.start_date >= ? AND issues.start_date <= ?) OR (issues.due_date >= ? AND issues.due_date <= ?))", time_start, time_end, time_start, time_end]) + unless params['assigned_to'].blank? + issues = issues.where(["(issues.assigned_to_id = ? OR issues.assigned_to_id IN (SELECT user_id FROM groups_users WHERE group_id = ?))",params['assigned_to'],params['assigned_to']]) + end + issues.each do |issue| ical.add_event do |e| ticket_time = TicketTime.where({:issue_id => issue.id}).first rescue nil tbegin = ticket_time.time_begin.strftime(" %H:%M") rescue '' diff --git a/init.rb b/init.rb index 051e965..9e0f999 100644 --- a/init.rb +++ b/init.rb @@ -103,7 +103,7 @@ name 'Mega Calendar plugin' author 'Andreas Treubert' description 'Better calendar for redmine' - version '1.9.9' + version '2.0.0' url 'https://github.com/berti92/mega_calendar' author_url 'https://github.com/berti92' requires_redmine :version_or_higher => '5.1.1'