مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
@@ -38,7 +38,7 @@ class IPPoolsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def safe_params
|
def safe_params
|
||||||
params.require(:ip_pool).permit(:name, :type, :default)
|
params.require(:ip_pool).permit(:name, :default)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class OrganizationIPPoolsController < ApplicationController
|
|||||||
before_action :admin_required, :only => [:assignments]
|
before_action :admin_required, :only => [:assignments]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@ip_pools = organization.ip_pools.dedicated.order(:name)
|
@ip_pools = organization.ip_pools.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assignments
|
def assignments
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
# created_at :datetime
|
# created_at :datetime
|
||||||
# updated_at :datetime
|
# updated_at :datetime
|
||||||
# default :boolean default(FALSE)
|
# default :boolean default(FALSE)
|
||||||
# type :string(255)
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
@@ -17,8 +16,6 @@
|
|||||||
|
|
||||||
class IPPool < ApplicationRecord
|
class IPPool < ApplicationRecord
|
||||||
|
|
||||||
TYPES = ['Transactional', 'Bulk', 'Forwarding', 'Dedicated']
|
|
||||||
|
|
||||||
include HasUUID
|
include HasUUID
|
||||||
|
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
@@ -28,21 +25,8 @@ class IPPool < ApplicationRecord
|
|||||||
has_many :organization_ip_pools, :dependent => :destroy
|
has_many :organization_ip_pools, :dependent => :destroy
|
||||||
has_many :organizations, :through => :organization_ip_pools
|
has_many :organizations, :through => :organization_ip_pools
|
||||||
|
|
||||||
scope :transactional, -> { where(:type => 'Transactional') }
|
|
||||||
scope :bulk, -> { where(:type => 'Bulk') }
|
|
||||||
scope :forwarding, -> { where(:type => 'Forwarding') }
|
|
||||||
scope :dedicated, -> { where(:type => 'Dedicated') }
|
|
||||||
|
|
||||||
def self.default
|
def self.default
|
||||||
where(:default => true).order(:id).first
|
where(:default => true).order(:id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
|
||||||
desc = "#{name}"
|
|
||||||
if self.type == 'Dedicated'
|
|
||||||
desc += " (#{ip_addresses.map(&:ipv4).to_sentence})"
|
|
||||||
end
|
|
||||||
desc
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ class Organization < ApplicationRecord
|
|||||||
has_many :ip_pool_rules, :dependent => :destroy, :as => :owner
|
has_many :ip_pool_rules, :dependent => :destroy, :as => :owner
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
if pool = IPPool.transactional.default
|
if pool = IPPool.default
|
||||||
self.ip_pools << IPPool.transactional.default
|
self.ip_pools << IPPool.default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
.fieldSet__field
|
.fieldSet__field
|
||||||
= f.label :ip_pool_id, "IP Pool", :class => 'fieldSet__label'
|
= f.label :ip_pool_id, "IP Pool", :class => 'fieldSet__label'
|
||||||
.fieldSet__input
|
.fieldSet__input
|
||||||
= f.collection_select :ip_pool_id, organization.ip_pools.includes(:ip_addresses).order("`default` desc, name asc"), :id, :description, {}, :class => 'input input--select'
|
= f.collection_select :ip_pool_id, organization.ip_pools.includes(:ip_addresses).order("`default` desc, name asc"), :id, :name, {}, :class => 'input input--select'
|
||||||
%p.fieldSet__text
|
%p.fieldSet__text
|
||||||
This is the IP pool that this message should be delivered from.
|
This is the IP pool that this message should be delivered from.
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
%dl.ipPoolRuleList__condition
|
%dl.ipPoolRuleList__condition
|
||||||
%dt Will be sent using:
|
%dt Will be sent using:
|
||||||
%dd= ip_pool_rule.ip_pool.description
|
%dd= ip_pool_rule.ip_pool.name
|
||||||
- if @server
|
- if @server
|
||||||
%p.ipPoolRuleListDefault.u-margin All mail that doesn't match a rule above will be sent using #{@server.ip_pool.description}.
|
%p.ipPoolRuleListDefault.u-margin All mail that doesn't match a rule above will be sent using #{@server.ip_pool.name}.
|
||||||
%p.u-center= link_to "Add another rule", [:new, organization, @server, :ip_pool_rule], :class => "button button--positive"
|
%p.u-center= link_to "Add another rule", [:new, organization, @server, :ip_pool_rule], :class => "button button--positive"
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
.fieldSet__field
|
.fieldSet__field
|
||||||
= f.label :name, :class => 'fieldSet__label'
|
= f.label :name, :class => 'fieldSet__label'
|
||||||
.fieldSet__input= f.text_field :name, :autofocus => true, :class => 'input input--text'
|
.fieldSet__input= f.text_field :name, :autofocus => true, :class => 'input input--text'
|
||||||
.fieldSet__field
|
|
||||||
= f.label :type, :class => 'fieldSet__label'
|
|
||||||
.fieldSet__input= f.select :type, IPPool::TYPES, {}, :class => 'input input--select'
|
|
||||||
|
|
||||||
- if @ip_pool.persisted?
|
- if @ip_pool.persisted?
|
||||||
%table.dataTable.u-margin-half
|
%table.dataTable.u-margin-half
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.navBar.navBar--secondary
|
.navBar.navBar--secondary
|
||||||
%ul
|
%ul
|
||||||
%li.navBar__item= link_to "Dedicated IPs", organization_ip_pools_path(organization), :class => ['navBar__link', active_nav == :ips ? 'is-active' : '']
|
%li.navBar__item= link_to "IP Pools", organization_ip_pools_path(organization), :class => ['navBar__link', active_nav == :ips ? 'is-active' : '']
|
||||||
%li.navBar__item= link_to "Rules", organization_ip_pool_rules_path(organization), :class => ['navBar__link', active_nav == :rules ? 'is-active' : '']
|
%li.navBar__item= link_to "Rules", organization_ip_pool_rules_path(organization), :class => ['navBar__link', active_nav == :rules ? 'is-active' : '']
|
||||||
|
|||||||
5
db/migrate/20170428153353_remove_type_from_ip_pools.rb
Normal file
5
db/migrate/20170428153353_remove_type_from_ip_pools.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class RemoveTypeFromIPPools < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
remove_column :ip_pools, :type, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170421195415) do
|
ActiveRecord::Schema.define(version: 20170428153353) do
|
||||||
|
|
||||||
create_table "additional_route_endpoints", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
|
create_table "additional_route_endpoints", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
|
||||||
t.integer "route_id"
|
t.integer "route_id"
|
||||||
@@ -141,7 +141,6 @@ ActiveRecord::Schema.define(version: 20170421195415) do
|
|||||||
t.datetime "created_at", precision: 6
|
t.datetime "created_at", precision: 6
|
||||||
t.datetime "updated_at", precision: 6
|
t.datetime "updated_at", precision: 6
|
||||||
t.boolean "default", default: false
|
t.boolean "default", default: false
|
||||||
t.string "type"
|
|
||||||
t.index ["uuid"], name: "index_ip_pools_on_uuid", length: { uuid: 8 }, using: :btree
|
t.index ["uuid"], name: "index_ip_pools_on_uuid", length: { uuid: 8 }, using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم