diff --git a/app/controllers/internal/organizations_controller.rb b/app/controllers/internal/organizations_controller.rb
new file mode 100644
index 000000000..91de90e15
--- /dev/null
+++ b/app/controllers/internal/organizations_controller.rb
@@ -0,0 +1,18 @@
+class Internal::OrganizationsController < Internal::ApplicationController
+ layout "internal"
+
+ def index
+ @organizations = Organization.order("name DESC").page(params[:page]).per(50)
+
+ return if params[:search].blank?
+
+ @organizations = @organizations.where(
+ "name ILIKE ?",
+ "%#{params[:search].strip}%",
+ )
+ end
+
+ def show
+ @organization = Organization.find(params[:id])
+ end
+end
diff --git a/app/views/internal/organizations/_activity.html.erb b/app/views/internal/organizations/_activity.html.erb
new file mode 100644
index 000000000..9f870e8df
--- /dev/null
+++ b/app/views/internal/organizations/_activity.html.erb
@@ -0,0 +1,7 @@
+
+
Activity
+
+ - <%= @organization.articles.size %> articles
+ - <%= @organization.followers.size %> followers
+
+
diff --git a/app/views/internal/organizations/index.html.erb b/app/views/internal/organizations/index.html.erb
new file mode 100644
index 000000000..01a003470
--- /dev/null
+++ b/app/views/internal/organizations/index.html.erb
@@ -0,0 +1,28 @@
+
+<%= form_tag("/internal/organizations", method: "get") do %>
+ <%= label_tag(:search, "Find by name:") %>
+ <%= text_field_tag(:search, params[:search]) %>
+ <%= submit_tag("Search") %>
+<% end %>
+
+
+
Name
+
ID
+
Twitter
+
GitHub
+
URL
+
+
+<%= paginate @organizations %>
+
+<% @organizations.each do |organization| %>
+
+
+
<%= organization.id %>
+
<%= organization.twitter_username || "N/A" %>
+
<%= organization.github_username || "N/A" %>
+
<%= organization.url || "N/A" %>
+
+<% end %>
+
+<%= paginate @organizations %>
diff --git a/app/views/internal/organizations/show.html.erb b/app/views/internal/organizations/show.html.erb
new file mode 100644
index 000000000..fd8420fb0
--- /dev/null
+++ b/app/views/internal/organizations/show.html.erb
@@ -0,0 +1,32 @@
+
+
+
+
Created <%= @organization.created_at.strftime("%b %e '%y") %>
+
General Info
+
+ - ID:
+ - <%= @organization.id %>
+ - name:
+ - <%= @organization.name %>
+ - Membership Count:
+ - <%= @organization.organization_memberships.size %>
+ - Email:
+ - <%= @organization.email || "N/A" %>
+ - Twitter:
+ - <%= @organization.twitter_username || "N/A" %>
+ - GitHub:
+ - <%= @organization.github_username || "N/A" %>
+
+
+<%= render "activity" %>
diff --git a/app/views/internal/shared/_navbar.html.erb b/app/views/internal/shared/_navbar.html.erb
index f62b669eb..5ec1f1faa 100644
--- a/app/views/internal/shared/_navbar.html.erb
+++ b/app/views/internal/shared/_navbar.html.erb
@@ -1,4 +1,4 @@
-<% menu_items = %w[comments articles users tags welcome broadcasts reports pages tools chat_channels growth mods config badges].each_with_object({}) { |v, h| h[v] = v } %>
+<% menu_items = %w[comments articles users tags welcome broadcasts reports pages tools chat_channels growth mods config badges organizations].each_with_object({}) { |v, h| h[v] = v } %>
<% menu_items[:listings] = "classified_listings" %>
<% menu_items[:podcasts] = "podcasts" %>
<% menu_items[:webhooks] = "webhook_endpoints" %>
diff --git a/config/routes.rb b/config/routes.rb
index 62fb0b6f0..b39667d9a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -69,6 +69,7 @@ Rails.application.routes.draw do
end
end
resources :organization_memberships, only: %i[update destroy create]
+ resources :organizations, only: %i[index show]
resources :welcome, only: %i[index create]
resources :growth, only: %i[index]
resources :tools, only: %i[index create] do
@@ -236,7 +237,7 @@ Rails.application.routes.draw do
get "/async_info/base_data", controller: "async_info#base_data", defaults: { format: :json }
get "/async_info/shell_version", controller: "async_info#shell_version", defaults: { format: :json }
-
+
get "/future", to: redirect("devteam/the-future-of-dev-160n")
# Settings
@@ -342,7 +343,6 @@ Rails.application.routes.draw do
get "/shell_top" => "shell#top"
get "/shell_bottom" => "shell#bottom"
-
get "/new" => "articles#new"
get "/new/:template" => "articles#new"
diff --git a/spec/requests/internal/organizations_spec.rb b/spec/requests/internal/organizations_spec.rb
new file mode 100644
index 000000000..fb3cde2ee
--- /dev/null
+++ b/spec/requests/internal/organizations_spec.rb
@@ -0,0 +1,34 @@
+require "rails_helper"
+
+RSpec.describe "internal/organizations", type: :request do
+ let(:admin) { create(:user, :super_admin) }
+ let(:organization) { Organization.first }
+
+ before do
+ create_list :organization, 5
+ sign_in(admin)
+ end
+
+ describe "GETS /internal/organizations" do
+ let(:organizations) { Organization.all.map { |o| CGI.escapeHTML(o.name) } }
+ let(:another_organization) { create(:organization, name: "T-800") }
+
+ it "lists all organizations" do
+ get "/internal/organizations"
+ expect(response.body).to include(*organizations)
+ end
+
+ it "allows searching" do
+ get "/internal/organizations?search=#{organization.name}"
+ expect(response.body).to include(organization.name)
+ expect(response.body).not_to include(another_organization.name)
+ end
+ end
+
+ describe "GET /internal/orgnaizations/:id" do
+ it "renders the correct organization" do
+ get "/internal/organizations/#{organization.id}"
+ expect(response.body).to include(organization.name)
+ end
+ end
+end
diff --git a/spec/system/internal/admin_manages_organizations_spec.rb b/spec/system/internal/admin_manages_organizations_spec.rb
new file mode 100644
index 000000000..706f35bc6
--- /dev/null
+++ b/spec/system/internal/admin_manages_organizations_spec.rb
@@ -0,0 +1,18 @@
+require "rails_helper"
+
+RSpec.describe "Admin manages organizations", type: :system do
+ let(:admin) { create(:user, :super_admin) }
+ let(:organization) { create(:organization) }
+
+ before do
+ create_list :organization, 5
+ sign_in admin
+ visit "/internal/organizations"
+ end
+
+ it "searches for organizations" do
+ fill_in "search", with: organization.name.to_s
+ click_on "Search"
+ expect(page.body).to have_link(organization.name)
+ end
+end