Skip to content

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

Correct routing for PATCH and cleanup

Inga Mai00665e791355
diff --git a/app/controllers/settings/display_controller.rb b/app/controllers/settings/display_controller.rb
index 479b4d52d5a..f7501da764a 100644
--- a/app/controllers/settings/display_controller.rb
+++ b/app/controllers/settings/display_controller.rb
@@ -28,6 +28,8 @@
#++
class Settings::DisplayController < SettingsController
+ include AdminSettingsUpdater
+
menu_item :settings_display
def show
diff --git a/app/controllers/settings/general_controller.rb b/app/controllers/settings/general_controller.rb
index a80195eae8d..11f05fcfb1d 100644
--- a/app/controllers/settings/general_controller.rb
+++ b/app/controllers/settings/general_controller.rb
@@ -28,6 +28,8 @@
#++
class Settings::GeneralController < SettingsController
+ include AdminSettingsUpdater
+
menu_item :settings_general
def show
diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb
index 2c3f1d6111b..3309760084f 100644
--- a/app/controllers/settings/projects_controller.rb
+++ b/app/controllers/settings/projects_controller.rb
@@ -28,6 +28,8 @@
#++
class Settings::ProjectsController < SettingsController
+ include AdminSettingsUpdater
+
menu_item :settings_projects
def show
diff --git a/app/controllers/settings/repositories_controller.rb b/app/controllers/settings/repositories_controller.rb
index 6a1ebffc33e..c2d2ce18f35 100644
--- a/app/controllers/settings/repositories_controller.rb
+++ b/app/controllers/settings/repositories_controller.rb
@@ -28,6 +28,8 @@
#++
class Settings::RepositoriesController < SettingsController
+ include AdminSettingsUpdater
+
menu_item :settings_repositories
def show
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index a928ec8f732..12f7155ce77 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -45,9 +45,7 @@ class SettingsController < ApplicationController
end
def show
- @guessed_host = request.host_with_port.dup
-
- @custom_style = CustomStyle.current || CustomStyle.new
+ redirect_to general_settings_path
end
def plugin
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 4c538077516..ebd6c6c9b6b 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -58,14 +58,6 @@ module SettingsHelper
]
end
- def general_settings_path(opts = {})
- if opts[:tab]
- url_for controller: "settings/#{opts[:tab]}", action: 'show', only_path: true
- else
- url_for controller: "settings/general", action: 'show', only_path: true
- end
- end
-
def setting_select(setting, choices, options = {})
if blank_text = options.delete(:blank)
choices = [[blank_text.is_a?(Symbol) ? I18n.t(blank_text) : blank_text, '']] + choices
diff --git a/app/views/settings/_display.html.erb b/app/views/settings/_display.html.erb
index 1b6ee2c6a26..7c1dd0f1863 100644
--- a/app/views/settings/_display.html.erb
+++ b/app/views/settings/_display.html.erb
@@ -33,7 +33,7 @@ See docs/COPYRIGHT.rdoc for more details.
<%= toolbar title: t(:label_display) %>
-<%= styled_form_tag(general_settings_path(tab: 'display'), method: :patch) do %>
+<%= styled_form_tag(update_display_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field" id="setting_available_languages"><%= setting_multiselect :available_languages, all_lang_options_for_select(false) %></div>
diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb
index f8e893e90df..6bbe31359ed 100644
--- a/app/views/settings/_general.html.erb
+++ b/app/views/settings/_general.html.erb
@@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_general) %>
-<%= styled_form_tag(general_settings_path, method: :patch) do %>
+<%= styled_form_tag(update_general_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field"><%= setting_text_field :app_title, size: 30, container_class: '-middle' %></div>
<div class="form--field">
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb
index 98bc41ad265..63954400d5d 100644
--- a/app/views/settings/_projects.html.erb
+++ b/app/views/settings/_projects.html.erb
@@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_project_plural) %>
-<%= styled_form_tag(general_settings_path(tab: 'projects'), method: :patch) do %>
+<%= styled_form_tag(update_projects_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field"><%= setting_check_box :default_projects_public %></div>
<div class="form--field"><%= setting_multiselect(:default_projects_modules,
diff --git a/app/views/settings/_repositories.html.erb b/app/views/settings/_repositories.html.erb
index cad9f662aa5..c9ce9d95124 100644
--- a/app/views/settings/_repositories.html.erb
+++ b/app/views/settings/_repositories.html.erb
@@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= toolbar title: t(:label_repository_plural) %>
-<%= styled_form_tag(general_settings_path(tab: 'repositories'), method: :patch) do %>
+<%= styled_form_tag(update_repositories_settings_path, method: :patch) do %>
<section class="form--section">
<div class="form--field">
<%= setting_check_box :autofetch_changesets %>
diff --git a/app/views/settings/show.html.erb b/app/views/settings/show.html.erb
deleted file mode 100644
index 1f7f759410b..00000000000
--- a/app/views/settings/show.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-<%#-- copyright
-OpenProject is an open source project management software.
-Copyright (C) 2012-2020 the OpenProject GmbH
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 3.
-
-OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-Copyright (C) 2006-2017 Jean-Philippe Lang
-Copyright (C) 2010-2013 the ChiliProject Team
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-See docs/COPYRIGHT.rdoc for more details.
-
-++#%>
-
-<% html_title t(:label_administration), t(:label_system_settings) -%>
-
-<%= toolbar title: t(:label_system_settings) %>
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index fd85bd55dcd..f216212ef3d 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -217,7 +217,7 @@ Redmine::MenuManager.map :admin_menu do |menu|
icon: 'icon2 icon-enumerations'
menu.push :settings,
- { controller: '/settings', action: 'show' },
+ { controller: '/settings/general', action: 'show' },
caption: :label_system_settings,
icon: 'icon2 icon-settings2'
diff --git a/config/routes.rb b/config/routes.rb
index 9e612d3aa22..1fea06c6073 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -394,10 +394,10 @@ OpenProject::Application.routes.draw do
resource :mail_notifications, only: %i[show update]
end
- get "settings", controller: "settings/general", action: 'show', as: "settings"
resource :settings, only: %i(update show) do
SettingsHelper.system_settings_tabs.each do |tab|
- get "#{tab[:name]}", controller: "settings/#{tab[:name]}", action: 'show', as: "settings_#{tab[:name]}"
+ get tab[:name], controller: "settings/#{tab[:name]}", action: 'show', as: "#{tab[:name]}"
+ patch tab[:name], controller: "settings/#{tab[:name]}", action: 'update', as: "update_#{tab[:name]}"
end
# We should fix this crappy routing (split up and rename controller methods)
@@ -408,7 +408,7 @@ OpenProject::Application.routes.draw do
resource :workflows, only: %i[edit update show] do
member do
- # We should fix this crappy routing (split upΩand rename controller methods)
+ # We should fix this crappy routing (split up and rename controller methods)
match 'copy', action: 'copy', via: %i[get post]
end
end