Add settings for member statuses
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
0b4bc4ef5c
commit
f313686b13
23
app/controllers/admin/settings/membership_controller.rb
Normal file
23
app/controllers/admin/settings/membership_controller.rb
Normal file
@ -0,0 +1,23 @@
|
||||
class Admin::Settings::MembershipController < Admin::SettingsController
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
update_settings
|
||||
|
||||
redirect_to admin_settings_membership_path, flash: {
|
||||
success: "Settings saved"
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setting_params
|
||||
params.require(:setting).permit([
|
||||
:member_status_contributor,
|
||||
:member_status_sustainer,
|
||||
:user_index_show_contributors,
|
||||
:user_index_show_sustainers
|
||||
])
|
||||
end
|
||||
end
|
@ -6,18 +6,20 @@ class Admin::UsersController < Admin::BaseController
|
||||
def index
|
||||
ldap = LdapService.new
|
||||
ou = Setting.primary_domain
|
||||
@show_contributors = Setting.user_index_show_contributors
|
||||
@show_sustainers = Setting.user_index_show_sustainers
|
||||
|
||||
@contributors = ldap.search_users(:memberStatus, :contributor, :cn) if @show_contributors
|
||||
@sustainers = ldap.search_users(:memberStatus, :sustainer, :cn) if @show_sustainers
|
||||
@admins = ldap.search_users(:admin, true, :cn)
|
||||
@contributors = ldap.search_users(:memberStatus, :contributor, :cn)
|
||||
@sustainers = ldap.search_users(:memberStatus, :sustainer, :cn)
|
||||
@pagy, @users = pagy(User.where(ou: ou).order(cn: :asc))
|
||||
|
||||
@stats = {
|
||||
users_confirmed: User.where(ou: ou).confirmed.count,
|
||||
users_pending: User.where(ou: ou).pending.count,
|
||||
users_contributing: @contributors.size,
|
||||
users_paying: @sustainers.size
|
||||
users_pending: User.where(ou: ou).pending.count
|
||||
}
|
||||
@stats[:users_contributing] = @contributors.size if @show_contributors
|
||||
@stats[:users_paying] = @sustainers.size if @show_sustainers
|
||||
end
|
||||
|
||||
# GET /admin/users/:username
|
||||
|
@ -1,10 +0,0 @@
|
||||
module Settings
|
||||
module MemberSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :member_default_status, type: :string,
|
||||
default: ENV["MEMBER_DEFAULT_STATUS"].presence
|
||||
end
|
||||
end
|
||||
end
|
18
app/models/concerns/settings/membership_settings.rb
Normal file
18
app/models/concerns/settings/membership_settings.rb
Normal file
@ -0,0 +1,18 @@
|
||||
module Settings
|
||||
module MembershipSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :member_status_contributor, type: :string,
|
||||
default: "Contributor"
|
||||
field :member_status_sustainer, type: :string,
|
||||
default: "Sustainer"
|
||||
|
||||
# Admin panel
|
||||
field :user_index_show_contributors, type: :boolean,
|
||||
default: false
|
||||
field :user_index_show_sustainers, type: :boolean,
|
||||
default: false
|
||||
end
|
||||
end
|
||||
end
|
@ -16,6 +16,7 @@ class Setting < RailsSettings::Base
|
||||
include Settings::LightningNetworkSettings
|
||||
include Settings::MastodonSettings
|
||||
include Settings::MediaWikiSettings
|
||||
include Settings::MembershipSettings
|
||||
include Settings::NostrSettings
|
||||
include Settings::OpenCollectiveSettings
|
||||
include Settings::RemoteStorageSettings
|
||||
|
53
app/views/admin/settings/membership/show.html.erb
Normal file
53
app/views/admin/settings/membership/show.html.erb
Normal file
@ -0,0 +1,53 @@
|
||||
<%= render HeaderComponent.new(title: "Settings") %>
|
||||
|
||||
<%= render MainWithSidenavComponent.new(sidenav_partial: 'shared/admin_sidenav_settings') do %>
|
||||
<%= form_for(Setting.new, url: admin_settings_membership_path, method: :put) do |f| %>
|
||||
<section>
|
||||
<h3>Membership</h3>
|
||||
|
||||
<% if @errors && @errors.any? %>
|
||||
<%= render partial: "admin/settings/errors", locals: { errors: @errors } %>
|
||||
<% end %>
|
||||
|
||||
<ul role="list">
|
||||
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||
key: :member_status_contributor,
|
||||
title: "Status name for contributing users",
|
||||
description: "A contributing member of your organization/group"
|
||||
) %>
|
||||
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||
key: :member_status_sustainer,
|
||||
title: "Status name for paying users",
|
||||
description: "A paying/donating member or customer"
|
||||
) %>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>Admin panel</h3>
|
||||
|
||||
<ul role="list">
|
||||
<%= render FormElements::FieldsetToggleComponent.new(
|
||||
form: f,
|
||||
attribute: :user_index_show_contributors,
|
||||
enabled: Setting.user_index_show_contributors?,
|
||||
title: "Show #{Setting.member_status_contributor.downcase} status in user list",
|
||||
description: "Can slow down page rendering with large user base"
|
||||
) %>
|
||||
<%= render FormElements::FieldsetToggleComponent.new(
|
||||
form: f,
|
||||
attribute: :user_index_show_sustainers,
|
||||
enabled: Setting.user_index_show_sustainers?,
|
||||
title: "Show #{Setting.member_status_sustainer.downcase} status in user list",
|
||||
description: "Can slow down page rendering with large user base"
|
||||
) %>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<p class="pt-6 border-t border-gray-200 text-right">
|
||||
<%= f.submit 'Save', class: "btn-md btn-blue w-full md:w-auto" %>
|
||||
</p>
|
||||
</section>
|
||||
<% end %>
|
||||
<% end %>
|
@ -13,16 +13,20 @@
|
||||
title: 'Pending',
|
||||
value: @stats[:users_pending],
|
||||
) %>
|
||||
<% if @show_contributors %>
|
||||
<%= render QuickstatsItemComponent.new(
|
||||
type: :number,
|
||||
title: 'Contributors',
|
||||
title: Setting.member_status_contributor.pluralize,
|
||||
value: @stats[:users_contributing],
|
||||
) %>
|
||||
<% end %>
|
||||
<% if @show_sustainers %>
|
||||
<%= render QuickstatsItemComponent.new(
|
||||
type: :number,
|
||||
title: 'Sustainers',
|
||||
title: Setting.member_status_sustainer.pluralize,
|
||||
value: @stats[:users_paying],
|
||||
) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</section>
|
||||
|
||||
@ -41,8 +45,8 @@
|
||||
<td><%= link_to(user.cn, admin_user_path(user.cn), class: 'ks-text-link') %></td>
|
||||
<td>
|
||||
<%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %>
|
||||
<%= @contributors.include?(user.cn) ? badge("contributor", :green) : "" %>
|
||||
<%= @sustainers.include?(user.cn) ? badge("sustainer", :green) : "" %>
|
||||
<% if @show_contributors %><%= @contributors.include?(user.cn) ? badge("contributor", :green) : "" %><% end %>
|
||||
<% if @show_sustainers %><%= @sustainers.include?(user.cn) ? badge("sustainer", :green) : "" %><% end %>
|
||||
</td>
|
||||
<td><%= @admins.include?(user.cn) ? badge("admin", :red) : "" %></td>
|
||||
</tr>
|
||||
|
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-server"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-server <%= custom_class %>"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>
|
||||
|
Before Width: | Height: | Size: 431 B After Width: | Height: | Size: 452 B |
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-users"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-users <%= custom_class %>"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
|
||||
|
Before Width: | Height: | Size: 400 B After Width: | Height: | Size: 421 B |
@ -3,7 +3,11 @@
|
||||
active: current_page?(admin_settings_registrations_path)
|
||||
) %>
|
||||
<%= render SidenavLinkComponent.new(
|
||||
name: "Services", path: admin_settings_services_path, icon: "grid",
|
||||
name: "Membership", path: admin_settings_membership_path, icon: "users",
|
||||
active: current_page?(admin_settings_membership_path)
|
||||
) %>
|
||||
<%= render SidenavLinkComponent.new(
|
||||
name: "Services", path: admin_settings_services_path, icon: "server",
|
||||
active: controller_name == "services"
|
||||
) %>
|
||||
<% if controller_name == "services" %>
|
||||
|
@ -109,6 +109,7 @@ Rails.application.routes.draw do
|
||||
|
||||
namespace :settings do
|
||||
resource 'registrations', only: ['show', 'update']
|
||||
resource 'membership', only: ['show', 'update'], controller: 'membership'
|
||||
resources 'services', param: 'service', only: ['index', 'show', 'update']
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user