OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
using OpenProject::StaticRouting::StaticRouter instead of doing it manually as suggested by @ulferts
Jonas Jabaric267892b0f85
diff --git a/modules/calendar/app/services/calendar/create_ical_service.rb b/modules/calendar/app/services/calendar/create_ical_service.rbindex 35aaaba09b6..7616b850ed8 100644--- a/modules/calendar/app/services/calendar/create_ical_service.rb+++ b/modules/calendar/app/services/calendar/create_ical_service.rb@@ -30,7 +30,6 @@ require 'icalendar'module Calendarclass CreateIcalService < ::BaseServices::BaseCallable- include OpenProject::StaticRouting::UrlHelpersdef perform(work_packages:, calendar_name: "OpenProject Calendar")ical_string = create_ical_string(work_packages, calendar_name)@@ -108,36 +107,16 @@ module Calendarenddef location_value(work_package)- url_for(- controller: :work_packages,- action: :show,- id: work_package.id,- only_path: false,- protocol:,- host:- )+ OpenProject::StaticRouting::StaticRouter.new.url_helpers+ .work_package_url(+ id: work_package.id+ )end- # implementation taken from application_mailerdef host- if OpenProject::Configuration.rails_relative_url_root.blank?- Setting.host_name- else- Setting.host_name.to_s.gsub(%r{/.*\z}, '')- end+ OpenProject::StaticRouting::UrlHelpers.hostend- # implementation taken from application_mailer- def protocol- Setting.protocol- end-- # # url_for wants to access the controller method, which we do not have in our service class.- # # see: http://stackoverflow.com/questions/3659455/is-there-a-new-syntax-for-url-for-in-rails-3- # def controller- # nil- # end-def description_value(work_package)# TODO: translate keysproject = "Project: #{work_package.project.name}"diff --git a/modules/calendar/app/services/calendar/generate_ical_url.rb b/modules/calendar/app/services/calendar/generate_ical_url.rbindex 9d6f878bb1f..a837b31b33e 100644--- a/modules/calendar/app/services/calendar/generate_ical_url.rb+++ b/modules/calendar/app/services/calendar/generate_ical_url.rb@@ -28,7 +28,6 @@module Calendarclass GenerateIcalUrl < ::BaseServices::BaseCallable- include OpenProject::StaticRouting::UrlHelpersdef perform(user:, query_id:, project_id:)new_ical_token = create_ical_token(user)@@ -44,36 +43,12 @@ module Calendarenddef create_ical_url(query_id, project_id, ical_token)- url_for(- controller: "calendar/ical",- action: :ical,- id: query_id,- project_id:,- ical_token:,- only_path: false,- protocol:,- host:- )+ OpenProject::StaticRouting::StaticRouter.new.url_helpers+ .ical_project_calendar_url(+ id: query_id,+ project_id:,+ ical_token:+ )end-- # implementation taken from application_mailer- def host- if OpenProject::Configuration.rails_relative_url_root.blank?- Setting.host_name- else- Setting.host_name.to_s.gsub(%r{/.*\z}, '')- end- end-- # implementation taken from application_mailer- def protocol- Setting.protocol- end-- # # url_for wants to access the controller method, which we do not have in our service class.- # # see: http://stackoverflow.com/questions/3659455/is-there-a-new-syntax-for-url-for-in-rails-3- # def controller- # nil- # endendend