diff --git a/app/controllers/staffs/people/resident_registrations_controller.rb b/app/controllers/staffs/people/resident_registrations_controller.rb deleted file mode 100644 index 9cee37f..0000000 --- a/app/controllers/staffs/people/resident_registrations_controller.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -class Staffs::People::ResidentRegistrationsController < ApplicationController - before_action :set_person - - # GET /staff/people/:person_id/resident_registrations - def index - authorize [:staff, @person, :resident_registration] - @resident_registrations = policy_scope( - @person.resident_registrations, - policy_scope_class: Staff::Person::ResidentRegistrationPolicy::Scope, - ) - end - -private - - def set_person - @person = Person.find params[:person_id] - end -end diff --git a/app/models/person.rb b/app/models/person.rb index 660b3f4..a4c6557 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,8 +27,6 @@ class Person < ApplicationRecord has_many :passports, dependent: :restrict_with_exception - has_many :resident_registrations, dependent: :restrict_with_exception - ############### # Validations # ############### diff --git a/app/models/resident_registration.rb b/app/models/resident_registration.rb deleted file mode 100644 index aa5d8b3..0000000 --- a/app/models/resident_registration.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -class ResidentRegistration < ApplicationRecord - ################ - # Associations # - ################ - - belongs_to :person, optional: true -end diff --git a/app/policies/staff/person/resident_registration_policy.rb b/app/policies/staff/person/resident_registration_policy.rb deleted file mode 100644 index 3cd4292..0000000 --- a/app/policies/staff/person/resident_registration_policy.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -class Staff::Person::ResidentRegistrationPolicy < ApplicationPolicy - def index? - account&.is_superuser? - end - - class Scope < Scope - def resolve - return scope.all if account&.is_superuser? - - scope.none - end - end -end diff --git a/app/views/staffs/people/_nav_tabs.html.erb b/app/views/staffs/people/_nav_tabs.html.erb index 5c9783f..8f1c6e8 100644 --- a/app/views/staffs/people/_nav_tabs.html.erb +++ b/app/views/staffs/people/_nav_tabs.html.erb @@ -5,6 +5,5 @@ overview: [:staff, person], person_comments: staff_person_person_comments_path(person), passports: staff_person_passports_path(person), - resident_registrations: staff_person_resident_registrations_path(person), ) %> diff --git a/app/views/staffs/people/resident_registrations/index.html.erb b/app/views/staffs/people/resident_registrations/index.html.erb deleted file mode 100644 index 179cdf5..0000000 --- a/app/views/staffs/people/resident_registrations/index.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -
- <%= render partial: 'staffs/people/nav_tabs', - locals: { person: @person, tab: :resident_registrations } %> - - - - - - - - - - - <% @resident_registrations.each do |resident_registration| %> - - - - - <% end %> - -
- <%= ResidentRegistration.human_attribute_name :id %> -
<%= resident_registration.id %>
-
diff --git a/config/locales/activerecord/en.yml b/config/locales/activerecord/en.yml index 3bdcb93..89db9cc 100644 --- a/config/locales/activerecord/en.yml +++ b/config/locales/activerecord/en.yml @@ -16,9 +16,6 @@ en: person_comment: one: Comment many: Comments - resident_registration: - one: Resident registration - many: Resident registrations roles: one: Role many: Roles @@ -69,8 +66,6 @@ en: person/sex: male: Male female: Female - resident_registration: - id: ID role: id: ID name: Name diff --git a/config/locales/activerecord/ru.yml b/config/locales/activerecord/ru.yml index b20d0b5..a809f39 100644 --- a/config/locales/activerecord/ru.yml +++ b/config/locales/activerecord/ru.yml @@ -16,9 +16,6 @@ ru: person_comment: one: Комментарий many: Комментарии - resident_registration: - one: Прописка - many: Прописки roles: one: Роль many: Роли @@ -69,8 +66,6 @@ ru: person/sex: male: Мужской female: Женский - resident_registration: - id: ID role: id: ID name: Название diff --git a/config/locales/nav_tabs/en.yml b/config/locales/nav_tabs/en.yml index 51948cc..69166d0 100644 --- a/config/locales/nav_tabs/en.yml +++ b/config/locales/nav_tabs/en.yml @@ -4,7 +4,6 @@ en: overview: Overview person_comments: Comments passports: Passports - resident_registrations: Resident registrations settings: credentials: Credentials profile: Public profile diff --git a/config/locales/nav_tabs/ru.yml b/config/locales/nav_tabs/ru.yml index 09b695b..a9af764 100644 --- a/config/locales/nav_tabs/ru.yml +++ b/config/locales/nav_tabs/ru.yml @@ -4,7 +4,6 @@ ru: overview: Обзор person_comments: Комментарии passports: Паспорта - resident_registrations: Прописки settings: credentials: Данные для входа profile: Публичный профиль diff --git a/config/routes.rb b/config/routes.rb index a2d1624..389aa5a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -58,10 +58,6 @@ Rails.application.routes.draw do resources :passports, controller: 'people/passports', only: :index - - resources :resident_registrations, - controller: 'people/resident_registrations', - only: :index end end end diff --git a/factories/resident_registrations.rb b/factories/resident_registrations.rb deleted file mode 100644 index 13b94f9..0000000 --- a/factories/resident_registrations.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :empty_resident_registration, class: ResidentRegistration do - association :person, factory: :initial_person - end -end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 77fcbcb..3aa7287 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -41,12 +41,6 @@ RSpec.describe Person do .dependent(:restrict_with_exception) end - it do - is_expected.to \ - have_many(:resident_registrations) - .dependent(:restrict_with_exception) - end - it { is_expected.not_to validate_presence_of :regional_office } describe '#relationships' do diff --git a/spec/models/resident_registration_spec.rb b/spec/models/resident_registration_spec.rb deleted file mode 100644 index 6b2f5e0..0000000 --- a/spec/models/resident_registration_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe ResidentRegistration do - subject { create :empty_resident_registration } - - it { is_expected.to belong_to(:person).optional } -end diff --git a/spec/policies/staff/person/resident_registration_policy_spec.rb b/spec/policies/staff/person/resident_registration_policy_spec.rb deleted file mode 100644 index 5cc205a..0000000 --- a/spec/policies/staff/person/resident_registration_policy_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe Staff::Person::ResidentRegistrationPolicy do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/requests/staff/people/resident_registrations/index_spec.rb b/spec/requests/staff/people/resident_registrations/index_spec.rb deleted file mode 100644 index 5ecf6e5..0000000 --- a/spec/requests/staff/people/resident_registrations/index_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'GET /staff/people/:person_id/resident_registrations' do - let(:person) { create :initial_person } - - before do - sign_in current_account.user if current_account&.user - - create :empty_resident_registration, person: person - create :empty_resident_registration, person: person - create :empty_resident_registration, person: person - - get "/staff/people/#{person.to_param}/resident_registrations" - 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