Update registration settings
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
084835f06a
commit
b7bf957dd2
@ -3,7 +3,36 @@ class Admin::Settings::RegistrationsController < Admin::SettingsController
|
||||
def index
|
||||
end
|
||||
|
||||
def update
|
||||
def create
|
||||
@errors = ActiveModel::Errors.new(Setting.new)
|
||||
|
||||
setting_params.keys.each do |key|
|
||||
next if setting_params[key].nil?
|
||||
|
||||
setting = Setting.new(var: key)
|
||||
setting.value = setting_params[key].strip
|
||||
unless setting.valid?
|
||||
@errors.merge!(setting.errors)
|
||||
end
|
||||
end
|
||||
|
||||
if @errors.any?
|
||||
render :index
|
||||
end
|
||||
|
||||
setting_params.keys.each do |key|
|
||||
Setting.send("#{key}=", setting_params[key].strip) unless setting_params[key].nil?
|
||||
end
|
||||
|
||||
redirect_to admin_settings_registrations_path, flash: {
|
||||
success: "Settings saved"
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setting_params
|
||||
params.require(:setting).permit(:reserved_usernames)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,13 +3,7 @@ class Setting < RailsSettings::Base
|
||||
cache_prefix { "v1" }
|
||||
|
||||
field :reserved_usernames, type: :array, default: %w[
|
||||
account
|
||||
accounts
|
||||
admin
|
||||
donations
|
||||
mail
|
||||
webmaster
|
||||
support
|
||||
account accounts admin donations mail webmaster support
|
||||
]
|
||||
|
||||
field :lndhub_enabled, default: (ENV["LNDHUB_API_URL"].present?.to_s || "false"), type: :boolean
|
||||
|
@ -1,9 +1,9 @@
|
||||
<%= render HeaderComponent.new(title: "Settings") %>
|
||||
|
||||
<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %>
|
||||
<section>
|
||||
<h3>Registrations</h3>
|
||||
<%= form_for(Setting.new, url: admin_settings_services_path) do |f| %>
|
||||
<%= form_for(Setting.new, url: admin_settings_registrations_path) do |f| %>
|
||||
<section>
|
||||
<h3>Registrations</h3>
|
||||
<% if @errors && @errors.any? %>
|
||||
<div>
|
||||
<ul>
|
||||
@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<label>
|
||||
<label class="block">
|
||||
<p class="font-bold mb-1">Reserved usernames</p>
|
||||
<p class="text-gray-500">
|
||||
These usernames cannot be registered as accounts:
|
||||
@ -22,10 +22,16 @@
|
||||
<%= f.text_area :reserved_usernames,
|
||||
value: Setting.reserved_usernames.join("\n"),
|
||||
class: "h-44 mb-2" %>
|
||||
<p class="text-sm text-gray-500">
|
||||
<p class="mb-0 text-sm text-gray-500">
|
||||
One username per line
|
||||
</p>
|
||||
</label>
|
||||
<% end %>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p class="mb-0 pt-6 border-t border-gray-200">
|
||||
<%= f.submit 'Save', class: "btn-md btn-blue w-full md:w-auto" %>
|
||||
</p>
|
||||
</section>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -45,8 +45,8 @@ Rails.application.routes.draw do
|
||||
get 'lightning', to: 'lightning#index'
|
||||
|
||||
namespace :settings do
|
||||
resources 'registrations', only: ['index', 'update']
|
||||
resources 'services', only: ['index', 'update']
|
||||
resources 'registrations', only: ['index', 'create']
|
||||
resources 'services', only: ['index', 'create']
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user