diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb
index 87d1aad23..a5be3626a 100644
--- a/app/controllers/admin/organizations_controller.rb
+++ b/app/controllers/admin/organizations_controller.rb
@@ -9,7 +9,7 @@ class Admin::OrganizationsController < Admin::BaseController
end
def search
- @organizations = Organization.search(params[:term]).page(params[:page])
+ @organizations = Organization.includes(:user).search(params[:term]).page(params[:page])
end
def verify
diff --git a/app/views/admin/organizations/index.html.erb b/app/views/admin/organizations/index.html.erb
index 85f75cf34..51a8dd959 100644
--- a/app/views/admin/organizations/index.html.erb
+++ b/app/views/admin/organizations/index.html.erb
@@ -18,7 +18,9 @@
<%= page_entries_info @organizations %>
+ <% hidden = 0 %>
<% @organizations.each do |organization| %>
+ <% hidden += 1 and next if organization.user.nil? || organization.user.hidden? %>
| <%= organization.name %> |
<%= organization.email %> |
@@ -54,4 +56,6 @@
<% end %>
+<%= t("admin.organizations.index.hidden_count", count: hidden) if hidden > 0 %>
+
<%= paginate @organizations %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 023be82fe..8d52dc1bf 100644
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -34,6 +34,9 @@ en:
pending: Pending
verified: Verified
rejected: Rejected
+ hidden_count:
+ one: "There is %{count} organization without user or with the user banned"
+ other: "There is %{count} organizations without user or with the user banned"
search:
title: "Search Organizations"
actions:
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index ab894241a..f7fc12e14 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -34,6 +34,9 @@ es:
pending: Pendientes
verified: Verificadas
rejected: Rechazadas
+ hidden_count:
+ one: "Hay además una organización sin usuario o con el usuario bloqueado"
+ other: "Hay %{count} organizaciones sin usuario o con el usuario bloqueado"
search:
title: "Buscar Organizaciones"
actions:
diff --git a/spec/features/admin/organizations_spec.rb b/spec/features/admin/organizations_spec.rb
index 868464620..2acce362b 100644
--- a/spec/features/admin/organizations_spec.rb
+++ b/spec/features/admin/organizations_spec.rb
@@ -9,6 +9,23 @@ feature 'Admin::Organizations' do
login_as(administrator)
end
+ context "Index" do
+ scenario "shows info on organizations with hidden users" do
+ troll = create(:user, email: "trol@troller.com")
+ create(:organization, user: troll, name: "Greentroll")
+ org = create(:organization, name: "Human Rights")
+ troll.hide
+
+ visit admin_organizations_path
+
+ expect(page).to have_content("Human Rights")
+ expect(page).to have_content(org.user.email)
+ expect(page).to_not have_content("Greentroll")
+ expect(page).to_not have_content("trol@troller.com")
+ expect(page).to have_content("There is 1 organization without user or with the user banned")
+ end
+ end
+
context "Search" do
background do