Remove contacts

This commit is contained in:
Wedge 2021-03-02 09:51:25 +03:00
parent 7b0f0cefae
commit 129212129b
5 changed files with 0 additions and 169 deletions

View File

@ -1,28 +0,0 @@
class ContactsController < ApplicationController
skip_after_action :verify_authorized
def new
@form = Feedback.new(current_user)
end
def create
@form = Feedback.new(feedback_params)
if @form.perform_send
flash[:notice] = I18n.t("flash.contact.success")
redirect_to sended_contact_path
else
flash[:error] = I18n.t("flash.contact.error")
render :new and return
end
end
def sended
end
private
def feedback_params
params[:feedback].permit(:name, :email, :subject, :message)
end
end

View File

@ -1,34 +0,0 @@
class FeedbackMailer < ActionMailer::Base
FBM_CONFIG = APP_CONFIG['feedback']
default to: FBM_CONFIG['email'],
cc: FBM_CONFIG['cc'],
bcc: FBM_CONFIG['bcc']
default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url']
# include Resque::Mailer # send email async
def feedback_form_send(form_data)
@data = Feedback.new(form_data)
from = "#{@data.name} <#{@data.email}>"
subj = prepare_subject(@data.subject)
mail from: from, subject: subj
end
protected
def prepare_subject(subject)
res = ''
res << affix(FBM_CONFIG['subject_prefixes'])
res << subject
res << affix(FBM_CONFIG['subject_postfixes'])
res = res.strip.gsub(/\s+/, ' ')
res
end
def affix(affixes)
' %s ' % Array(affixes).map{|e| "[#{e}]"}.join
end
end

View File

@ -1,101 +0,0 @@
# This class is based on
# https://github.com/rails/rails/blob/4da6e1cce2833474034fda0cbb67b2cc35e828da/activerecord/lib/active_record/validations.rb
class Feedback
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
extend ActiveModel::Naming
self.include_root_in_json = false
attr_accessor :name, :email, :subject, :message
validates :name, :subject, :message, presence: true
validates :email, presence: true,
format: { with: /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/,
allow_blank: false }
def initialize(args = {}, options = {})
return args.dup if args.is_a? Feedback
if args.respond_to? :name and args.respond_to? :email
self.name, self.email = args.name, args.email
elsif args.respond_to? :each_pair
args.each_pair do |k, v|
send("#{k}=", v)
end
else
return false
end
end
# FIXME: Maybe rename to `save`?
def perform_send(options = {})
perform_validations(options) ? real_send : false
end
def perform_send!(options={})
perform_validations(options) ? real_send : raise(ActiveRecord::RecordInvalid.new(self))
end
def new_record?
true
end
def persisted?
false
end
def message_with_links
message.to_s.dup.auto_link
end
def attributes
%w{ name email subject message }.inject({}) do |h, e|
h.merge(e => send(e))
end
end
def to_s
str = %w{ name email subject message }.map do |e|
"#{e}: #{ send(e).inspect }"
end.join(', ')
return "#<#{self.class} #{str}>"
end
class << self
def create(attributes = nil, options = {}, &block)
do_create(attributes, options, false, &block)
end
def create!(attributes = nil, options = {}, &block)
do_create(attributes, options, true, &block)
end
protected
def do_create(attributes = nil, options = {}, bang = false, &block)
if attributes.is_a?(Array)
attributes.collect { |attr| do_create(attr, options, bang, &block) }
else
object = new(attributes, options)
yield(object) if block_given?
bang ? object.perform_send! : object.perform_send
object
end
end
end
protected
def real_send
FeedbackMailer.feedback_form_send(self).deliver
end
def perform_validations(options={})
perform_validation = options[:validate] != false
perform_validation ? valid?(options[:context]) : true
end
end

View File

@ -4,6 +4,4 @@
.col-xs-4
= link_to t('bottom_menu.contacts'), t('bottom_menu.contacts_url')
.col-xs-4
= link_to t('bottom_menu.support'), contact_url
.col-xs-12
= link_to t('bottom_menu.tos'), 'https://www.openmandriva.org/tos'

View File

@ -15,10 +15,6 @@ Rails.application.routes.draw do
match '/robots.txt' => 'sitemap#robots', via: [:get, :post, :head], as: :robots
resources :statistics, only: [:index]
resource :contact, only: [:new, :create, :sended] do
get '/' => 'contacts#new'
get :sended
end
devise_scope :user do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'