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
[34901] Set timezone when switching to user
Oliver Günther4fa5e38c3d37
diff --git a/app/models/user.rb b/app/models/user.rbindex ad33ae26a6d..7c4ab0170a4 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -543,10 +543,10 @@ class User < PrincipalRequestStore[:current_user] || User.anonymousend- def self.execute_as(user)+ def self.execute_as(user, &block)previous_user = User.currentUser.current = user- yield+ OpenProject::LocaleHelper.with_locale_for(user, &block)ensureUser.current = previous_userenddiff --git a/modules/meeting/app/mailers/meeting_mailer.rb b/modules/meeting/app/mailers/meeting_mailer.rbindex 9bd6e1358c5..48f1e0b62ea 100644--- a/modules/meeting/app/mailers/meeting_mailer.rb+++ b/modules/meeting/app/mailers/meeting_mailer.rb@@ -37,7 +37,7 @@ class MeetingMailer < UserMaileropen_project_headers 'Project' => @meeting.project.identifier,'Meeting-Id' => @meeting.id- with_locale_for(user) do+ User.execute_as(user) dosubject = "[#{@meeting.project.name}] #{I18n.t(:"label_#{content_type}")}: #{@meeting.title}"mail to: user.mail, subject: subjectend@@ -58,7 +58,7 @@ class MeetingMailer < UserMailer# Create a calendar with an event (standard method)entry = ::Icalendar::Calendar.new- with_locale_for(user) do+ User.execute_as(user) dosubject = "[#{@meeting.project.name}] #{I18n.t(:"label_#{@content_type}")}: #{@meeting.title}"tzid = @meeting.start_time.zonetz = TZInfo::Timezone.get tziddiff --git a/modules/meeting/app/views/meeting_mailer/icalendar_notification.html.erb b/modules/meeting/app/views/meeting_mailer/icalendar_notification.html.erbindex 919f5c4dc07..d687dfbbb59 100644--- a/modules/meeting/app/views/meeting_mailer/icalendar_notification.html.erb+++ b/modules/meeting/app/views/meeting_mailer/icalendar_notification.html.erb@@ -8,4 +8,4 @@<li><%=Meeting.human_attribute_name(:location) %>: <%= @meeting.location %></li><li><%=Meeting.human_attribute_name(:participants_invited) %>: <%= @meeting.participants.invited.sort.join("; ") %></li><li><%=Meeting.human_attribute_name(:participants_attended) %>: <%= @meeting.participants.attended.sort.join("; ") %></li>-</ul>\ No newline at end of file+</ul>