More CSS simplification
Edit domain names, updates credentials and virtuals Model domain tests for length and valid characters
This commit is contained in:
parent
781b2bb9f0
commit
dcd4efdd4e
@ -135,3 +135,16 @@ footer {
|
|||||||
footer ul, footer h3 , footer li {
|
footer ul, footer h3 , footer li {
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a, a:visited {
|
||||||
|
color:blue;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color:red;
|
||||||
|
background-color:yellow;
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,21 @@ class DomainsController < ApplicationController
|
|||||||
|
|
||||||
# PATCH/PUT /domains/1 or /domains/1.json
|
# PATCH/PUT /domains/1 or /domains/1.json
|
||||||
def update
|
def update
|
||||||
|
pre_domain_name = @domain.domain
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @domain.update(domain_params)
|
if @domain.update(domain_params)
|
||||||
|
# now we need to update the credentials and virtuals
|
||||||
|
|
||||||
|
@domain.credentials.each do |credential|
|
||||||
|
credential.email.sub! pre_domain_name, @domain.domain
|
||||||
|
credential.save
|
||||||
|
end
|
||||||
|
|
||||||
|
@domain.virtuals.each do |virtual|
|
||||||
|
virtual.email.sub! pre_domain_name, @domain.domain
|
||||||
|
virtual.save
|
||||||
|
end
|
||||||
|
|
||||||
format.html { redirect_to domain_url(@domain), notice: "Domain was successfully updated." }
|
format.html { redirect_to domain_url(@domain), notice: "Domain was successfully updated." }
|
||||||
format.json { render :show, status: :ok, location: @domain }
|
format.json { render :show, status: :ok, location: @domain }
|
||||||
else
|
else
|
||||||
|
|||||||
@ -5,6 +5,7 @@ class Domain < ApplicationRecord
|
|||||||
has_many :virtuals, dependent: :destroy
|
has_many :virtuals, dependent: :destroy
|
||||||
validates :domain, presence: true
|
validates :domain, presence: true
|
||||||
validates :domain, uniqueness: true
|
validates :domain, uniqueness: true
|
||||||
|
validates :domain, format: { with: /\A(((?!-))(xn--|_)?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--)?([a-z0-9][a-z0-9\-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})\z/, message: "domain not valid" }
|
||||||
|
|
||||||
private
|
private
|
||||||
def create_abuse_postmaster
|
def create_abuse_postmaster
|
||||||
|
|||||||
@ -12,11 +12,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :domain, style: "display: block" %>
|
<%= form.label :domain %>:<%= form.text_field :domain %>
|
||||||
<%= form.text_field :domain %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= form.submit %>
|
<%= form.submit %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
<div class="domain">
|
||||||
|
|
||||||
<h1>Editing domain</h1>
|
<h1>Editing domain</h1>
|
||||||
|
|
||||||
<%= render "form", domain: @domain %>
|
<%= render "form", domain: @domain %>
|
||||||
@ -5,6 +7,8 @@
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= link_to "Show this domain", @domain %> |
|
<%= link_to "Back", @domain %> |
|
||||||
<%= link_to "Back to domains", domains_path %>
|
<%= link_to "Home", domains_path %>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<div class="domain">
|
<div class="domain">
|
||||||
<div class="domain-header">
|
<div class="domain-header">
|
||||||
<h2><%= @domain.domain %> <%#= link_to "Edit", edit_domain_path(@domain) %> <%= link_to "Delete", @domain, data: { turbo_method: :delete, turbo_confirm: "Are you sure?"} %></h2>
|
<h2><%= @domain.domain %> <%= link_to "Edit", edit_domain_path(@domain) %> <%= link_to "Delete", @domain, data: { turbo_method: :delete, turbo_confirm: "Are you sure?"} %></h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="email-list">
|
<div class="email-list">
|
||||||
<h3>Credentials (<%= @domain.credentials.count %>) <%= link_to "Add #{@domain.domain} email address", new_domain_credential_path(@domain) %></h3>
|
<h3>Credentials (<%= @domain.credentials.count %>) <%= link_to "Add #{@domain.domain} email address", new_domain_credential_path(@domain) %></h3>
|
||||||
|
|||||||
@ -22,4 +22,16 @@ class DomainTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert_equal(@d.virtuals.count,2)
|
assert_equal(@d.virtuals.count,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "valid domain names only" do
|
||||||
|
@d = Domain.new(domain: "Spaces Spaces.co.uk")
|
||||||
|
assert_not @d.save
|
||||||
|
|
||||||
|
@d.domain = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.com"
|
||||||
|
assert_not @d.save
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user