mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Remove Registrar from User
This commit is contained in:
parent
9c8fed999d
commit
2c35aa1471
14 changed files with 12 additions and 72 deletions
|
@ -53,7 +53,7 @@ class Admin::UsersController < AdminController
|
|||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id,
|
||||
:admin, :registrar_typeahead, :country_id)
|
||||
params.require(:user).permit(:username, :password, :identity_code, :email,
|
||||
:admin, :country_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@ class Registrar < ActiveRecord::Base
|
|||
has_many :domains, dependent: :restrict_with_error
|
||||
has_many :contacts, dependent: :restrict_with_error
|
||||
has_many :epp_users, dependent: :restrict_with_error
|
||||
has_many :users, dependent: :restrict_with_error
|
||||
has_many :messages
|
||||
|
||||
validates :name, :reg_no, :address, :country, presence: true
|
||||
|
|
|
@ -7,29 +7,19 @@ class User < ActiveRecord::Base
|
|||
# TODO: Estonian id validation
|
||||
|
||||
belongs_to :role
|
||||
belongs_to :registrar
|
||||
belongs_to :country
|
||||
|
||||
validates :username, :password, presence: true
|
||||
validates :identity_code, uniqueness: true, allow_blank: true
|
||||
validates :identity_code, presence: true, if: -> { country.iso == 'EE' }
|
||||
validates :email, presence: true, if: -> { country.iso != 'EE' }
|
||||
validates :registrar, presence: true, if: -> { !admin }
|
||||
|
||||
validate :validate_identity_code
|
||||
|
||||
before_save -> { self.registrar = nil if admin? }
|
||||
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_identity_code
|
||||
|
|
|
@ -44,26 +44,6 @@
|
|||
|
||||
%dt= t('shared.billing_address')
|
||||
%dd= @registrar.billing_address
|
||||
.row
|
||||
.col-md-12
|
||||
#users.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
= t('shared.users')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-3'}= t('shared.username')
|
||||
%th{class: 'col-xs-3'}= t('shared.email')
|
||||
%th{class: 'col-xs-3'}= t('shared.identity_code')
|
||||
%th{class: 'col-xs-3'}= t('shared.admin')
|
||||
%tbody
|
||||
- @registrar.users.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, [:admin, x])
|
||||
%td= x.email
|
||||
%td= x.identity_code
|
||||
%td= x.admin
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
|
|
|
@ -25,13 +25,6 @@
|
|||
.form-group
|
||||
= f.label :email
|
||||
= f.text_field(:email, class: 'form-control')
|
||||
.form-group
|
||||
.form-group.has-feedback.js-typeahead-container
|
||||
= f.label :registrar_typeahead, t('shared.registrar')
|
||||
= f.text_field(:registrar_typeahead, class: 'form-control js-registrar-typeahead', placeholder: t('shared.registrar'), autocomplete: 'off')
|
||||
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
|
||||
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
|
||||
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
|
||||
.form-group
|
||||
.checkbox
|
||||
%label{for: 'user_admin'}
|
||||
|
@ -41,19 +34,3 @@
|
|||
.row
|
||||
.col-md-12.text-right
|
||||
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
||||
|
||||
:javascript
|
||||
Autocomplete.bindAdminRegistrarSearch();
|
||||
toggleRegistrar();
|
||||
|
||||
$('#user_admin').click(function() {
|
||||
toggleRegistrar();
|
||||
});
|
||||
|
||||
function toggleRegistrar() {
|
||||
if($('.js-admin').is(':checked')) {
|
||||
$('.js-registrar-typeahead, .js-registrar-id').attr('disabled', true);
|
||||
} else {
|
||||
$('.js-registrar-typeahead, .js-registrar-id').attr('disabled', false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
= sort_link(@q, 'identity_code', t('shared.identity_code'))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'admin', t('shared.admin'))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'registrar', t('shared.registrar'))
|
||||
%tbody
|
||||
- @users.each do |x|
|
||||
%tr
|
||||
|
@ -28,7 +26,6 @@
|
|||
%td= x.email
|
||||
%td= x.identity_code
|
||||
%td= x.admin
|
||||
%td= x.registrar
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @users
|
||||
|
|
|
@ -39,8 +39,5 @@
|
|||
%dt= t('shared.email')
|
||||
%dd= @user.email
|
||||
|
||||
%dt= t('shared.registrar')
|
||||
%dd= @user.registrar
|
||||
|
||||
%dt= t('shared.admin')
|
||||
%dd= @user.admin
|
||||
|
|
5
db/migrate/20141216133831_remove_registrar_from_user.rb
Normal file
5
db/migrate/20141216133831_remove_registrar_from_user.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RemoveRegistrarFromUser < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :users, :registrar_id
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20141215085117) do
|
||||
ActiveRecord::Schema.define(version: 20141216133831) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -326,7 +326,6 @@ ActiveRecord::Schema.define(version: 20141215085117) do
|
|||
t.inet "last_sign_in_ip"
|
||||
t.boolean "admin", default: false
|
||||
t.string "identity_code"
|
||||
t.integer "registrar_id"
|
||||
t.integer "country_id"
|
||||
end
|
||||
|
||||
|
|
|
@ -5,5 +5,4 @@ Fabricator(:user) do
|
|||
identity_code '37810013108'
|
||||
admin true
|
||||
country
|
||||
registrar
|
||||
end
|
||||
|
|
|
@ -6,8 +6,8 @@ feature 'Sessions', type: :feature do
|
|||
|
||||
background do
|
||||
create_settings
|
||||
Fabricate(:user, registrar: nil, identity_code: '37810013261')
|
||||
Fabricate(:user, registrar: zone, username: 'zone', admin: false, identity_code: '37810013087')
|
||||
Fabricate(:user, identity_code: '37810013261')
|
||||
Fabricate(:user, username: 'zone', admin: false, identity_code: '37810013087')
|
||||
Fabricate.times(2, :domain, registrar: zone)
|
||||
Fabricate.times(2, :domain, registrar: elkdata)
|
||||
end
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
feature 'Setting management', type: :feature do
|
||||
let(:zone) { Fabricate(:registrar) }
|
||||
let(:zone_user) { Fabricate(:user, registrar: zone, username: 'user1', admin: true, identity_code: '37810013087') }
|
||||
let(:user) { Fabricate(:user, username: 'user1', admin: true, identity_code: '37810013087') }
|
||||
|
||||
background { create_settings }
|
||||
|
||||
scenario 'User changes a setting' do
|
||||
sign_in zone_user
|
||||
sign_in user
|
||||
visit admin_settings_path
|
||||
|
||||
val_min = find_field('_settings_ns_min_count').value
|
||||
|
|
|
@ -4,6 +4,5 @@ describe Registrar do
|
|||
it { should belong_to(:country) }
|
||||
it { should have_many(:domains) }
|
||||
it { should have_many(:epp_users) }
|
||||
it { should have_many(:users) }
|
||||
it { should have_many(:messages) }
|
||||
end
|
||||
|
|
|
@ -2,5 +2,4 @@ require 'rails_helper'
|
|||
|
||||
describe User do
|
||||
it { should belong_to(:role) }
|
||||
it { should belong_to(:registrar) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue