Add non-verified email filreting in contact index

This commit is contained in:
Alex Sherman 2020-06-09 14:57:55 +05:00
parent 48036c660d
commit af7e0f266d
3 changed files with 17 additions and 2 deletions

View file

@ -13,10 +13,12 @@ module Admin
search_params[:registrant_domains_id_not_null] = 1
end
contacts = Contact.includes(:registrar).joins(:registrar).select('contacts.*, registrars.name')
contacts = Contact.includes(:registrar).joins(:registrar)
.includes(:email_address_verification)
.select('contacts.*, registrars.name')
contacts = contacts.filter_by_states(params[:statuses_contains].join(',')) if params[:statuses_contains]
contacts = contacts.where("ident_country_code is null or ident_country_code=''") if params[:only_no_country_code].eql?('1')
contacts = contacts.email_not_verified if params[:email_not_verified].eql?('1')
normalize_search_parameters do
@q = contacts.search(search_params)

View file

@ -16,6 +16,10 @@ class Contact < ApplicationRecord
has_many :legal_documents, as: :documentable
has_many :registrant_domains, class_name: 'Domain', foreign_key: 'registrant_id'
has_many :actions, dependent: :destroy
belongs_to :email_address_verification, class_name: 'EmailAddressVerification',
primary_key: 'email',
foreign_key: 'email',
optional: true
attr_accessor :legal_document_id
alias_attribute :kind, :ident_type
@ -23,6 +27,11 @@ class Contact < ApplicationRecord
accepts_nested_attributes_for :legal_documents
scope :email_not_verified, lambda {
joins(:email_address_verification)
.where('verified_at IS NULL OR verified_at <= ?', EmailAddressVerification.verification_period)
}
validates :name, :email, presence: true
validates :street, :city, :zip, :country_code, presence: true, if: lambda {
self.class.address_processing?

View file

@ -63,6 +63,10 @@
.form-group
= label_tag :only_no_country_code, "Ident CC missing"
= check_box_tag :only_no_country_code, '1',params[:only_no_country_code].eql?('1'), style: 'width:auto;height:auto;float:right'
.col-md-3
.form-group
= label_tag :email_not_verified, "Email not verified"
= check_box_tag :email_not_verified, '1',params[:email_not_verified].eql?('1'), style: 'width:auto;height:auto;float:right'
.row
.col-md-3{style: 'padding-top: 25px;float:right;'}