Compare commits
	
		
			No commits in common. "f313686b138a716f67c190ea1ecd3eade46c7817" and "393f85e45ce71f7b5fe847c55bbbc15e9eeb2e27" have entirely different histories.
		
	
	
		
			f313686b13
			...
			393f85e45c
		
	
		
@ -29,7 +29,7 @@ class SidenavLinkComponent < ViewComponent::Base
 | 
			
		||||
 | 
			
		||||
  def class_names_icon(path)
 | 
			
		||||
    if @active
 | 
			
		||||
      "text-teal-600 group-hover:text-teal-600 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
 | 
			
		||||
      "text-teal-500 group-hover:text-teal-500 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
 | 
			
		||||
    elsif @disabled
 | 
			
		||||
      "text-gray-300 group-hover:text-gray-300 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
 | 
			
		||||
    else
 | 
			
		||||
 | 
			
		||||
@ -1,23 +0,0 @@
 | 
			
		||||
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,20 +6,18 @@ 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_pending: User.where(ou: ou).pending.count,
 | 
			
		||||
      users_contributing: @contributors.size,
 | 
			
		||||
      users_paying: @sustainers.size
 | 
			
		||||
    }
 | 
			
		||||
    @stats[:users_contributing] = @contributors.size if @show_contributors
 | 
			
		||||
    @stats[:users_paying] = @sustainers.size if @show_sustainers
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # GET /admin/users/:username
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								app/models/concerns/settings/member_settings.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/models/concerns/settings/member_settings.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
module Settings
 | 
			
		||||
  module MemberSettings
 | 
			
		||||
    extend ActiveSupport::Concern
 | 
			
		||||
 | 
			
		||||
    included do
 | 
			
		||||
      field :member_default_status, type: :string,
 | 
			
		||||
        default: ENV["MEMBER_DEFAULT_STATUS"].presence
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@ -1,18 +0,0 @@
 | 
			
		||||
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,7 +16,6 @@ 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
 | 
			
		||||
 | 
			
		||||
@ -1,53 +0,0 @@
 | 
			
		||||
<%= 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,21 +13,17 @@
 | 
			
		||||
          title: 'Pending',
 | 
			
		||||
          value: @stats[:users_pending],
 | 
			
		||||
      ) %>
 | 
			
		||||
      <% if @show_contributors %>
 | 
			
		||||
      <%= render QuickstatsItemComponent.new(
 | 
			
		||||
          type: :number,
 | 
			
		||||
          title: Setting.member_status_contributor.pluralize,
 | 
			
		||||
          title: 'Contributors',
 | 
			
		||||
          value: @stats[:users_contributing],
 | 
			
		||||
      ) %>
 | 
			
		||||
      <% end %>
 | 
			
		||||
      <% if @show_sustainers %>
 | 
			
		||||
      <%= render QuickstatsItemComponent.new(
 | 
			
		||||
          type: :number,
 | 
			
		||||
          title: Setting.member_status_sustainer.pluralize,
 | 
			
		||||
          title: 'Sustainers',
 | 
			
		||||
          value: @stats[:users_paying],
 | 
			
		||||
      ) %>
 | 
			
		||||
    <% end %>
 | 
			
		||||
    <% end %>
 | 
			
		||||
  </section>
 | 
			
		||||
 | 
			
		||||
  <section>
 | 
			
		||||
@ -45,8 +41,8 @@
 | 
			
		||||
          <td><%= link_to(user.cn, admin_user_path(user.cn), class: 'ks-text-link') %></td>
 | 
			
		||||
          <td>
 | 
			
		||||
            <%= user.confirmed_at.nil? ? badge("pending", :yellow) : "" %>
 | 
			
		||||
            <% if @show_contributors %><%= @contributors.include?(user.cn) ? badge("contributor", :green) : "" %><% end %>
 | 
			
		||||
            <% if @show_sustainers %><%= @sustainers.include?(user.cn) ? badge("sustainer", :green) : "" %><% end %>
 | 
			
		||||
            <%= @contributors.include?(user.cn) ? badge("contributor", :green) : "" %>
 | 
			
		||||
            <%= @sustainers.include?(user.cn) ? badge("sustainer", :green) : "" %>
 | 
			
		||||
          </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 <%= 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>
 | 
			
		||||
<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>
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 431 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 <%= 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>
 | 
			
		||||
<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>
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 400 B  | 
@ -3,11 +3,7 @@
 | 
			
		||||
  active: current_page?(admin_settings_registrations_path)
 | 
			
		||||
) %>
 | 
			
		||||
<%= render SidenavLinkComponent.new(
 | 
			
		||||
  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",
 | 
			
		||||
  name: "Services", path: admin_settings_services_path, icon: "grid",
 | 
			
		||||
  active: controller_name == "services"
 | 
			
		||||
) %>
 | 
			
		||||
<% if controller_name == "services" %>
 | 
			
		||||
 | 
			
		||||
@ -109,7 +109,6 @@ 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