diff --git a/app/controllers/staffs/contact_networks_controller.rb b/app/controllers/staffs/contact_networks_controller.rb
new file mode 100644
index 0000000..1807fc4
--- /dev/null
+++ b/app/controllers/staffs/contact_networks_controller.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class Staffs::ContactNetworksController < ApplicationController
+ # GET /staff/contact_networks
+ def index
+ authorize %i[staff contact_network]
+ @contact_networks = policy_scope(
+ ContactNetwork,
+ policy_scope_class: Staff::ContactNetworkPolicy::Scope,
+ )
+ end
+end
diff --git a/app/policies/staff/contact_network_policy.rb b/app/policies/staff/contact_network_policy.rb
new file mode 100644
index 0000000..168488c
--- /dev/null
+++ b/app/policies/staff/contact_network_policy.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class Staff::ContactNetworkPolicy < ApplicationPolicy
+ def index?
+ account&.superuser?
+ end
+
+ class Scope < Scope
+ def resolve
+ return scope.all if account&.superuser?
+
+ scope.none
+ end
+ end
+end
diff --git a/app/views/staffs/contact_networks/index.html.erb b/app/views/staffs/contact_networks/index.html.erb
new file mode 100644
index 0000000..2ede95d
--- /dev/null
+++ b/app/views/staffs/contact_networks/index.html.erb
@@ -0,0 +1,29 @@
+
+ <%= nav_breadcrumb(
+ [translate(:staff_services), staff_root_path],
+ ContactNetwork.model_name.human(count: 0),
+ ) %>
+
+
+
+
+
+ <%= ContactNetwork.human_attribute_name :nickname %>
+ |
+
+ <%= ContactNetwork.human_attribute_name :public_name %>
+ |
+ |
+
+
+
+
+ <% @contact_networks.each do |contact_network| %>
+
+ <%= contact_network.nickname %> |
+ <%= contact_network.public_name %> |
+
+ <% end %>
+
+
+
diff --git a/app/views/staffs/home/show.html.erb b/app/views/staffs/home/show.html.erb
index 6740744..df36cdb 100644
--- a/app/views/staffs/home/show.html.erb
+++ b/app/views/staffs/home/show.html.erb
@@ -13,5 +13,12 @@
<%= link_to Person.model_name.human(count: 0), staff_people_path %>
<% end %>
+
+ <% if policy(%i[staff contact_network]).index? %>
+
+ <%= link_to ContactNetwork.model_name.human(count: 0),
+ staff_contact_networks_path %>
+
+ <% end %>
diff --git a/config/locales/activerecord/en.yml b/config/locales/activerecord/en.yml
index d0afa2c..fdae4a5 100644
--- a/config/locales/activerecord/en.yml
+++ b/config/locales/activerecord/en.yml
@@ -4,6 +4,9 @@ en:
account:
one: Account
many: Accounts
+ contact_network:
+ one: Contact network
+ many: Contact networks
federal_subject:
one: State
many: States
@@ -33,6 +36,10 @@ en:
biography: Bio
avatar: Avatar
person: Person
+ contact_network:
+ id: ID
+ nickname: Nickname
+ public_name: Public name
federal_subject:
id: ID
regional_office: Regional department
diff --git a/config/locales/activerecord/ru.yml b/config/locales/activerecord/ru.yml
index 274f7a0..4db0086 100644
--- a/config/locales/activerecord/ru.yml
+++ b/config/locales/activerecord/ru.yml
@@ -4,6 +4,9 @@ ru:
account:
one: Аккаунт
many: Аккаунты
+ contact_network:
+ one: Сеть контактов
+ many: Сети контактов
federal_subject:
one: Регион
many: Регионы
@@ -33,6 +36,10 @@ ru:
biography: Биография
avatar: Аватар
person: Человек
+ contact_network:
+ id: ID
+ nickname: Имя пользователя
+ public_name: Публичное имя
federal_subject:
id: ID
regional_office: Региональное отделение
diff --git a/config/routes.rb b/config/routes.rb
index d8d933b..27890ec 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -48,6 +48,8 @@ Rails.application.routes.draw do
get '/sidekiq', to: redirect('/', status: 307), as: :forbidden_sidekiq
+ resources :contact_networks, only: :index
+
resources :accounts, param: :nickname, only: %i[index show]
resources :people, only: %i[index show] do
diff --git a/spec/policies/staff/contact_network_policy_spec.rb b/spec/policies/staff/contact_network_policy_spec.rb
new file mode 100644
index 0000000..c7fab96
--- /dev/null
+++ b/spec/policies/staff/contact_network_policy_spec.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe Staff::ContactNetworkPolicy do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/requests/staff/contact_networks/index_spec.rb b/spec/requests/staff/contact_networks/index_spec.rb
new file mode 100644
index 0000000..0996314
--- /dev/null
+++ b/spec/requests/staff/contact_networks/index_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+RSpec.describe 'GET /staff/contact_networks' do
+ before do
+ sign_in current_account.user if current_account&.user
+
+ create_list :contact_network, rand(1..5)
+
+ get '/staff/contact_networks'
+ end
+
+ for_account_types nil, :guest, :usual do
+ specify do
+ expect(response).to have_http_status :forbidden
+ end
+ end
+
+ for_account_types :superuser do
+ specify do
+ expect(response).to have_http_status :ok
+ end
+ end
+end