mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Let registrar users change registrar account
This commit is contained in:
parent
207c2a704c
commit
37249a24f7
8 changed files with 104 additions and 9 deletions
|
@ -2,16 +2,23 @@ class Registrar
|
|||
class AccountController < BaseController
|
||||
skip_authorization_check
|
||||
|
||||
helper_method :linked_users
|
||||
def show; end
|
||||
|
||||
def show
|
||||
@user = current_registrar_user
|
||||
def edit
|
||||
@registrar = current_registrar_user.registrar
|
||||
end
|
||||
|
||||
def update
|
||||
@registrar = current_registrar_user.registrar
|
||||
@registrar.update!(registrar_params)
|
||||
|
||||
redirect_to registrar_account_path, notice: t('.saved')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def linked_users
|
||||
current_registrar_user.linked_users
|
||||
def registrar_params
|
||||
params.require(:registrar).permit(:billing_email)
|
||||
end
|
||||
end
|
||||
end
|
16
app/views/registrar/account/_details.html.erb
Normal file
16
app/views/registrar/account/_details.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<%= t '.header' %>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
|
||||
<dd><%= registrar.billing_email %></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="panel-footer text-right">
|
||||
<%= link_to t('.edit_btn'), edit_registrar_account_path, class: 'btn btn-default btn-sm' %>
|
||||
</div>
|
||||
</div>
|
21
app/views/registrar/account/_form.html.erb
Normal file
21
app/views/registrar/account/_form.html.erb
Normal file
|
@ -0,0 +1,21 @@
|
|||
<%= form_for @registrar, url: registrar_account_path, method: :patch, html: { class: 'form-horizontal' } do |f| %>
|
||||
<%= render 'form_errors', target: @registrar %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 control-label">
|
||||
<%= f.label :billing_email %>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
<%= f.email_field :billing_email, autofocus: true, class: 'form-control' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-right">
|
||||
<%= f.submit t('.submit_btn'), class: 'btn btn-success' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
10
app/views/registrar/account/edit.html.erb
Normal file
10
app/views/registrar/account/edit.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<ol class="breadcrumb">
|
||||
<li><%= link_to t('registrar.account.show.header'), registrar_account_path %></li>
|
||||
<li><%= t '.header' %></li>
|
||||
</ol>
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= t '.header' %></h1>
|
||||
</div>
|
||||
|
||||
<%= render 'form' %>
|
|
@ -3,7 +3,13 @@
|
|||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<%= render 'linked_users', linked_users: linked_users %>
|
||||
<div class="col-sm-5">
|
||||
<%= render 'details', registrar: current_registrar_user.registrar %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<%= render 'linked_users', linked_users: current_registrar_user.linked_users %>
|
||||
</div>
|
||||
</div>
|
|
@ -4,6 +4,19 @@ en:
|
|||
show:
|
||||
header: Your account
|
||||
|
||||
edit:
|
||||
header: Edit your account
|
||||
|
||||
form:
|
||||
submit_btn: Save changes
|
||||
|
||||
update:
|
||||
saved: Your account has been updated
|
||||
|
||||
details:
|
||||
header: Details
|
||||
edit_btn: Edit
|
||||
|
||||
linked_users:
|
||||
header: Linked users
|
||||
switch_btn: Switch
|
||||
|
|
|
@ -66,7 +66,7 @@ Rails.application.routes.draw do
|
|||
resources :account_activities
|
||||
|
||||
put 'current_user/switch/:new_user_id', to: 'current_user#switch', as: :switch_current_user
|
||||
resource :account, controller: :account, only: :show
|
||||
resource :account, controller: :account, only: %i[show edit update]
|
||||
|
||||
resources :domains do
|
||||
collection do
|
||||
|
|
22
test/system/registrar_area/account_test.rb
Normal file
22
test/system/registrar_area/account_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarAccountTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@registrar = registrars(:bestnames)
|
||||
sign_in users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_updates_account
|
||||
new_billing_email = 'new@registrar.test'
|
||||
assert_not_equal new_billing_email, @registrar.billing_email
|
||||
|
||||
visit registrar_account_path
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'Billing email', with: new_billing_email
|
||||
click_on 'Save changes'
|
||||
|
||||
assert_text 'Your account has been updated'
|
||||
assert_text new_billing_email
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue