Skip to content

Commit 8009685

Browse files
Release OpenProject 17.1.1
2 parents 627e323 + 3f17a45 commit 8009685

File tree

133 files changed

+4333
-918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+4333
-918
lines changed

app/components/users/edit_page_header_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ See COPYRIGHT and LICENSE files for more details.
8080
end
8181
end
8282

83-
if Setting.users_deletable_by_admins?
83+
if Users::DeleteContract.deletion_allowed?(@user, User.current)
8484
header.with_action_button(
8585
tag: :a,
8686
scheme: :danger,

app/contracts/users/delete_contract.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class DeleteContract < ::DeleteContract
4040
# @param user [User] User to be deleted.
4141
# @param actor [User] User who wants to delete the given user.
4242
def self.deletion_allowed?(user, actor)
43+
return false if user.admin? && User.admin.active.where.not(id: user.id).empty?
44+
4345
if actor == user
4446
Setting.users_deletable_by_self?
4547
else

app/controllers/external_link_warning_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def parse_external_url
6363
def parse_url(url)
6464
return nil if url.blank?
6565

66-
uri = URI.parse(url)
67-
return url if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
66+
uri = Addressable::URI.parse(url)
67+
return url if %w[http https].include?(uri.scheme&.downcase)
6868

6969
nil
70-
rescue URI::InvalidURIError
70+
rescue Addressable::URI::InvalidURIError
7171
nil
7272
end
7373
end

app/controllers/users_controller.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,13 @@ def destroy
226226
# true if the user deletes him/herself
227227
self_delete = (@user == User.current)
228228

229-
Users::DeleteService.new(model: @user, user: User.current).call
229+
result = Users::DeleteService.new(model: @user, user: User.current).call
230230

231-
flash[:notice] = I18n.t("account.deletion_pending")
231+
if result.success?
232+
flash[:notice] = I18n.t("account.deletion_pending")
233+
else
234+
flash[:error] = result.errors.full_messages.join(", ")
235+
end
232236

233237
respond_to do |format|
234238
format.html do
@@ -283,7 +287,12 @@ def authorize_for_user
283287
end
284288

285289
def check_if_deletion_allowed
286-
render_404 unless Users::DeleteContract.deletion_allowed? @user, User.current
290+
return if Users::DeleteContract.deletion_allowed?(@user, User.current)
291+
292+
render_error_flash_message_via_turbo_stream(message: I18n.t("user.error_cannot_delete_user"))
293+
respond_with_turbo_streams(status: :not_found) do |format|
294+
format.html { render_404 }
295+
end
287296
end
288297

289298
def my_or_admin_layout
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module BrowserAware
32+
extend ActiveSupport::Concern
33+
34+
included do
35+
include BrowserHelper
36+
end
37+
38+
# N.B. This is an inelegant, and very likely brittle solution.
39+
#
40+
# The Browser gem uses `helper_method(:browser)` to declare a
41+
# controller method as a helper. This helper is available in classic
42+
# Rails views, but since upgrading to ViewComponent 4.0, no longer
43+
# works with Primer Forms.
44+
def browser
45+
@view_context.controller.send(:browser)
46+
end
47+
end

app/forms/projects/life_cycle/form.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#++
3030
module Projects::LifeCycle
3131
class Form < ApplicationForm
32+
include BrowserAware
33+
3234
form do |f|
3335
f.group(layout: :horizontal) do |horizontal_form|
3436
start_date_input(horizontal_form)
@@ -152,15 +154,5 @@ def field_type
152154
def placeholder
153155
browser.device.mobile? ? "yyyy-mm-dd" : nil
154156
end
155-
156-
# N.B. This is an inelegant, and very likely brittle solution.
157-
#
158-
# The Browser gem uses `helper_method(:browser)` to declare a
159-
# controller method as a helper. This helper is available in classic
160-
# Rails views, but since upgrading to ViewComponent 4.0, no longer
161-
# works with Primer Forms.
162-
def browser
163-
@view_context.controller.send(:browser)
164-
end
165157
end
166158
end

app/forms/projects/settings/creation_wizard/submission_form.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ class SubmissionForm < ApplicationForm
100100
label: I18n.t("settings.project_initiation_request.submission.work_package_comment"),
101101
caption: I18n.t("settings.project_initiation_request.submission.work_package_comment_caption"),
102102
required: false,
103-
value: model.project_creation_wizard_work_package_comment.presence || I18n.t(
104-
"settings.project_initiation_request.submission.work_package_comment_default", project_name: model.name
105-
),
106103
rich_text_options: {
107104
showAttachments: false,
108105
editorType: "constrained"

app/models/exports/pdf/components/cover.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,24 @@ def cover_background_image
185185
[image_obj, image_info, image_opts, height]
186186
end
187187

188-
def custom_cover_image
188+
def custom_cover_image_file
189189
return unless CustomStyle.current.present? &&
190-
CustomStyle.current.export_cover.present? && CustomStyle.current.export_cover.local_file.present?
190+
CustomStyle.current.export_cover.present? && CustomStyle.current.export_cover.local_file.present?
191+
192+
CustomStyle.current.export_cover.local_file.path
193+
end
194+
195+
def custom_cover_image
196+
image_file = custom_cover_image_file
197+
return unless image_file
191198

192-
image_file = CustomStyle.current.export_cover.local_file.path
193199
content_type = OpenProject::ContentTypeDetector.new(image_file).detect
194200
return unless pdf_embeddable?(content_type)
195201

196202
image_file
203+
rescue StandardError => e
204+
Rails.logger.error "Failed to access custom PDF cover file: #{e}"
205+
nil # Fallback to default cover
197206
end
198207

199208
def write_background_image

app/models/projects/creation_wizard.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ def project_creation_wizard_status_when_submitted_id
6666
super.presence || project_creation_wizard_default_status_when_submitted&.id
6767
end
6868

69+
def project_creation_wizard_work_package_comment
70+
super.presence ||
71+
I18n.t(
72+
"settings.project_initiation_request.submission.work_package_comment_default",
73+
project_name: name
74+
)
75+
end
76+
6977
def project_creation_wizard_default_work_package_type
7078
types.first
7179
end

app/services/mcp_tools.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ def all
3535
McpTools::CurrentUser,
3636
McpTools::ListStatuses,
3737
McpTools::ListTypes,
38+
McpTools::SearchPortfolios,
39+
McpTools::SearchPrograms,
3840
McpTools::SearchProjects,
3941
McpTools::SearchUsers,
42+
McpTools::SearchVersions,
4043
McpTools::SearchWorkPackages
4144
]
4245
end

0 commit comments

Comments
 (0)