Skip to content

[WIP] Task/30-2 デフォルトで新しいプロジェクトは公開にするをデフォルトオフにする #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def plugins
# (roles, trackers, statuses, workflow, enumerations)
def default_configuration
if request.post?
options = {}
options[:default_projects_public] = params[:default_projects_public].presence || 'private'

begin
Redmine::DefaultData::Loader::load(params[:lang])
Redmine::DefaultData::Loader::load(params[:lang], options)
flash[:notice] = l(:notice_default_data_loaded)
rescue => e
flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/_no_data.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<%= form_tag({:action => 'default_configuration'}) do %>
<%= simple_format(l(:text_no_configuration_data)) %>
<p><%= l(:field_language) %>:
<%= select_tag 'lang', options_for_select(lang_options_for_select(false), current_language.to_s) %>
<%= select_tag 'lang', options_for_select(lang_options_for_select(false), current_language.to_s) %><br/>
<label class="inline"><%= check_box_tag :default_projects_public, 'public', true %> <%= l(:setting_default_projects_public) %></label><br/>
<%= submit_tag l(:text_load_default_configuration) %></p>
<% end %>
</div>
5 changes: 5 additions & 0 deletions lib/redmine/default_data/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ def load(lang=nil, options={})
support.id.to_s
]

# set new project as private if default_projects_public option is exist
if options[:default_projects_public] == 'private'
Setting.default_projects_public = 0
end

if workflow
# Workflow
Tracker.all.each do |t|
Expand Down
5 changes: 4 additions & 1 deletion lib/tasks/load_default_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ namespace :redmine do
puts "===================================="
end

options = {}
options[:default_projects_public] = ENV['REDMINE_DEFAULT_PROJECTS_PUBLIC'].presence

begin
Redmine::DefaultData::Loader.load(current_language)
Redmine::DefaultData::Loader.load(current_language, options)
puts "Default configuration data loaded."
rescue Redmine::DefaultData::DataAlreadyLoaded => error
puts error.message
Expand Down