From 4a4552564dea1c3586bf2ab360eddaf75dc3d57e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 6 May 2019 13:09:50 +0300 Subject: [PATCH] Remove mail templates feature as buggy and unused --- Gemfile | 1 - Gemfile.lock | 2 - .../admin/mail_templates_controller.rb | 63 ------------------- app/models/ability.rb | 1 - app/models/mail_template.rb | 3 - app/views/admin/base/_menu.haml | 1 - app/views/admin/mail_templates/_form.haml | 54 ---------------- app/views/admin/mail_templates/edit.haml | 3 - app/views/admin/mail_templates/index.haml | 26 -------- app/views/admin/mail_templates/new.haml | 3 - app/views/admin/mail_templates/show.haml | 41 ------------ config/locales/admin/mail_templates.en.yml | 5 -- config/locales/en.yml | 1 - config/routes.rb | 1 - .../20190506100655_remove_mail_templates.rb | 5 ++ db/structure.sql | 54 +--------------- .../admin_area/mail_templates/new_test.rb | 14 ----- 17 files changed, 7 insertions(+), 271 deletions(-) delete mode 100644 app/controllers/admin/mail_templates_controller.rb delete mode 100644 app/models/mail_template.rb delete mode 100644 app/views/admin/mail_templates/_form.haml delete mode 100644 app/views/admin/mail_templates/edit.haml delete mode 100644 app/views/admin/mail_templates/index.haml delete mode 100644 app/views/admin/mail_templates/new.haml delete mode 100644 app/views/admin/mail_templates/show.haml delete mode 100644 config/locales/admin/mail_templates.en.yml create mode 100644 db/migrate/20190506100655_remove_mail_templates.rb delete mode 100644 test/system/admin_area/mail_templates/new_test.rb diff --git a/Gemfile b/Gemfile index a9b78afdb..170c244d8 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,6 @@ gem 'selectize-rails', '0.12.1' # include selectize.js for select gem 'kaminari', '0.16.3' # pagination gem 'coderay', '1.1.0' # xml console visualize gem 'select2-rails', '3.5.9.3' # for autocomplete -gem 'liquid', '3.0.6' # for email templates # rights gem 'cancancan', '1.11.0' # autharization diff --git a/Gemfile.lock b/Gemfile.lock index 44e87e54b..18f3b193e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -232,7 +232,6 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) libxml-ruby (3.0.0) - liquid (3.0.6) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -480,7 +479,6 @@ DEPENDENCIES jquery-rails (= 4.0.4) jquery-ui-rails (= 5.0.5) kaminari (= 0.16.3) - liquid (= 3.0.6) mina (= 0.3.1) money-rails nokogiri diff --git a/app/controllers/admin/mail_templates_controller.rb b/app/controllers/admin/mail_templates_controller.rb deleted file mode 100644 index d7ec4e6d0..000000000 --- a/app/controllers/admin/mail_templates_controller.rb +++ /dev/null @@ -1,63 +0,0 @@ -module Admin - class MailTemplatesController < BaseController - load_and_authorize_resource - - def index - @q = MailTemplate.search(params[:q]) - @mail_templates = @q.result.page(params[:page]) - end - - def new - @mail_tempalte = MailTemplate.new - end - - def show - @mail_template = MailTemplate.find(params[:id]) - @subject = Liquid::Template.parse(@mail_template.subject).render.html_safe - @html_body = Liquid::Template.parse(@mail_template.body).render.html_safe - @text_body = Liquid::Template.parse(@mail_template.text_body).render.html_safe - end - - def edit - @mail_template = MailTemplate.find(params[:id]) - end - - def create - @mail_template = MailTemplate.new(mail_template_params) - - if @mail_template.save - redirect_to [:admin, @mail_template] - else - flash.now[:alert] = I18n.t(:failure) - render 'new' - end - end - - def update - @mail_template = MailTemplate.find(params[:id]) - - if @mail_template.update_attributes(mail_template_params) - redirect_to [:admin, @mail_template] - else - flash.now[:alert] = I18n.t(:failure) - render 'edit' - end - end - - def destroy - @mail_template = MailTemplate.find(params[:id]) - if @mail_template.destroy - redirect_to admin_mail_templates_path, notice: t(:deleted) - else - flash.now[:alert] = I18n.t(:failure) - render 'show' - end - end - - private - - def mail_template_params - params.require(:mail_template).permit(:name, :subject, :from, :bcc, :cc, :body, :text_body) - end - end -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 33c276492..50e87c98e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -99,7 +99,6 @@ class Ability can :manage, LegalDocument can :manage, BankStatement can :manage, BankTransaction - can :manage, MailTemplate can :manage, Invoice can :manage, WhiteIp can :manage, AccountActivity diff --git a/app/models/mail_template.rb b/app/models/mail_template.rb deleted file mode 100644 index ee693a0a3..000000000 --- a/app/models/mail_template.rb +++ /dev/null @@ -1,3 +0,0 @@ -class MailTemplate < ActiveRecord::Base - validates :name, :subject, :from, :body, :text_body, presence: true -end diff --git a/app/views/admin/base/_menu.haml b/app/views/admin/base/_menu.haml index 6c8e15201..d99a1598c 100644 --- a/app/views/admin/base/_menu.haml +++ b/app/views/admin/base/_menu.haml @@ -34,7 +34,6 @@ %li= link_to t('.zones'), admin_zones_path %li= link_to t('.blocked_domains'), admin_blocked_domains_path %li= link_to t('.reserved_domains'), admin_reserved_domains_path - %li= link_to t(:mail_templates), admin_mail_templates_path %li= link_to t('.epp_log'), admin_epp_logs_path(created_after: 'today') %li= link_to t('.repp_log'), admin_repp_logs_path(created_after: 'today') %li= link_to t('.que'), '/admin/que' diff --git a/app/views/admin/mail_templates/_form.haml b/app/views/admin/mail_templates/_form.haml deleted file mode 100644 index 70873c22a..000000000 --- a/app/views/admin/mail_templates/_form.haml +++ /dev/null @@ -1,54 +0,0 @@ -= form_for([:admin, mail_template], html: {class: 'form-horizontal'}) do |f| - = render 'shared/full_errors', object: mail_template - - - - liquid_help = link_to 'Liquid info', 'https://github.com/Shopify/liquid/wiki/Liquid-for-Designers' - - .row - .col-md-12 - .panel.panel-default - .panel-body - .form-group - .col-md-4.control-label - = f.label :name - .col-md-7 - = f.text_field(:name, class: 'form-control') - .form-group - .col-md-4.control-label - = f.label :subject - %br - = liquid_help - .col-md-7 - = f.text_field(:subject, class: 'form-control') - .form-group - .col-md-4.control-label - = f.label :from - .col-md-7 - = f.email_field :from, class: 'form-control' - .form-group - .col-md-4.control-label - = f.label :cc - .col-md-7 - = f.email_field :cc, class: 'form-control' - .form-group - .col-md-4.control-label - = f.label :bcc - .col-md-7 - = f.email_field :bcc, class: 'form-control' - .form-group - .col-md-12 - = f.label :body, t('admin.mail_templates.html_body') - = liquid_help - .col-md-12 - = f.text_area(:body, class: 'form-control', size: '15x15') - .form-group - .col-md-12 - = f.label :text_body - = liquid_help - .col-md-12 - = f.text_area(:text_body, class: 'form-control', size: '15x15') - - %hr - .row - .col-md-12.text-right - = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/mail_templates/edit.haml b/app/views/admin/mail_templates/edit.haml deleted file mode 100644 index 9516671c6..000000000 --- a/app/views/admin/mail_templates/edit.haml +++ /dev/null @@ -1,3 +0,0 @@ -= render 'shared/title', name: "#{t(:edit)}: #{@mail_template.name}" - -= render 'form', mail_template: @mail_template diff --git a/app/views/admin/mail_templates/index.haml b/app/views/admin/mail_templates/index.haml deleted file mode 100644 index 7fa1913ae..000000000 --- a/app/views/admin/mail_templates/index.haml +++ /dev/null @@ -1,26 +0,0 @@ -- content_for :actions do - = link_to(t(:new), new_admin_mail_template_path, class: 'btn btn-primary') -= render 'shared/title', name: t(:mail_templates) - -.row - .col-md-12 - .table-responsive - %table.table.table-hover.table-bordered.table-condensed - %thead - %tr - %th{class: 'col-xs-3'}= sort_link(@q, 'name', t(:name)) - %th{class: 'col-xs-3'}= sort_link(@q, 'subject') - %th{class: 'col-xs-3'}= sort_link(@q, 'updated_at') - %th{class: 'col-xs-3'}= t(:actions) - %tbody - - @mail_templates.each do |mt| - %tr - %td= link_to(truncate(mt.name), admin_mail_template_path(mt)) - %td= truncate(mt.subject) - %td= l(mt.updated_at) - %td - = link_to(t(:edit), edit_admin_mail_template_path(mt), class: 'btn btn-primary btn-xs') - -.row - .col-md-12 - = paginate @mail_templates diff --git a/app/views/admin/mail_templates/new.haml b/app/views/admin/mail_templates/new.haml deleted file mode 100644 index ecf2ea1e8..000000000 --- a/app/views/admin/mail_templates/new.haml +++ /dev/null @@ -1,3 +0,0 @@ -= render 'shared/title', name: t('admin.mail_templates.new_mail_template') - -= render 'form', mail_template: @mail_template diff --git a/app/views/admin/mail_templates/show.haml b/app/views/admin/mail_templates/show.haml deleted file mode 100644 index 31739bbf9..000000000 --- a/app/views/admin/mail_templates/show.haml +++ /dev/null @@ -1,41 +0,0 @@ -- content_for :actions do - = link_to(t(:edit), edit_admin_mail_template_path(@mail_template.id), class: 'btn btn-primary') - = link_to(t(:delete), admin_mail_template_path(@mail_template.id), - method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') - = link_to(t(:email_templates), admin_mail_templates_path, class: 'btn btn-default') -= render 'shared/title', name: @mail_template.name - -.row - .col-md-12 - .panel.panel-default - .panel-heading - %h3.panel-title= t(:general) - .panel-body - %dl.dl-horizontal - %dt= t(:subject) - %dd= @mail_template.subject - - %dt= t(:from) - %dd= @mail_template.from - - - if @mail_template.cc.present? - %dt= t(:cc) - %dd= @mail_template.cc - - - if @mail_template.bcc.present? - %dt= t(:bcc) - %dd= @mail_template.bcc - - .col-md-12 - .panel.panel-default - .panel-heading - %h3.panel-title= t(:html_body) - .panel-body - = @html_body - - .col-md-12 - .panel.panel-default - .panel-heading - %h3.panel-title= t(:text_body) - .panel-body - = @text_body diff --git a/config/locales/admin/mail_templates.en.yml b/config/locales/admin/mail_templates.en.yml deleted file mode 100644 index 2aa6ad52d..000000000 --- a/config/locales/admin/mail_templates.en.yml +++ /dev/null @@ -1,5 +0,0 @@ -en: - admin: - mail_templates: - html_body: HTML body - new_mail_template: New mail template diff --git a/config/locales/en.yml b/config/locales/en.yml index 4bb40ed5d..8beb4bed2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -660,7 +660,6 @@ en: created_at_until: 'Created at until' is_registrant: 'Is registrant' force_delete_set_on_domain: 'Force delete set on domain %{domain_name}' - mail_templates: Mail Templates contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact' next: 'Next' previous: 'Previous' diff --git a/config/routes.rb b/config/routes.rb index 5ffa5e50b..ab72d0092 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -186,7 +186,6 @@ Rails.application.routes.draw do end end - resources :mail_templates resources :account_activities resources :bank_statements do diff --git a/db/migrate/20190506100655_remove_mail_templates.rb b/db/migrate/20190506100655_remove_mail_templates.rb new file mode 100644 index 000000000..1c35a8a3c --- /dev/null +++ b/db/migrate/20190506100655_remove_mail_templates.rb @@ -0,0 +1,5 @@ +class RemoveMailTemplates < ActiveRecord::Migration + def change + drop_table :mail_templates + end +end diff --git a/db/structure.sql b/db/structure.sql index fc482bdc8..83716ff1e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1832,43 +1832,6 @@ CREATE SEQUENCE public.log_white_ips_id_seq ALTER SEQUENCE public.log_white_ips_id_seq OWNED BY public.log_white_ips.id; --- --- Name: mail_templates; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE public.mail_templates ( - id integer NOT NULL, - name character varying NOT NULL, - subject character varying, - "from" character varying, - bcc character varying, - cc character varying, - body text NOT NULL, - text_body text NOT NULL, - created_at timestamp without time zone, - updated_at timestamp without time zone -); - - --- --- Name: mail_templates_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.mail_templates_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: mail_templates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.mail_templates_id_seq OWNED BY public.mail_templates.id; - - -- -- Name: nameservers; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2669,13 +2632,6 @@ ALTER TABLE ONLY public.log_users ALTER COLUMN id SET DEFAULT nextval('public.lo ALTER TABLE ONLY public.log_white_ips ALTER COLUMN id SET DEFAULT nextval('public.log_white_ips_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.mail_templates ALTER COLUMN id SET DEFAULT nextval('public.mail_templates_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3079,14 +3035,6 @@ ALTER TABLE ONLY public.log_white_ips ADD CONSTRAINT log_white_ips_pkey PRIMARY KEY (id); --- --- Name: mail_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY public.mail_templates - ADD CONSTRAINT mail_templates_pkey PRIMARY KEY (id); - - -- -- Name: nameservers_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -4795,6 +4743,8 @@ INSERT INTO schema_migrations (version) VALUES ('20190415120246'); INSERT INTO schema_migrations (version) VALUES ('20190426174225'); +INSERT INTO schema_migrations (version) VALUES ('20190506100655'); + INSERT INTO schema_migrations (version) VALUES ('20190510090240'); INSERT INTO schema_migrations (version) VALUES ('20190510102549'); diff --git a/test/system/admin_area/mail_templates/new_test.rb b/test/system/admin_area/mail_templates/new_test.rb deleted file mode 100644 index dcaa5d592..000000000 --- a/test/system/admin_area/mail_templates/new_test.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'test_helper' - -class AdminAreaNewMailTemplateTest < ApplicationSystemTestCase - setup do - sign_in users(:admin) - end - - def test_new_mail_template_does_not_throw_template_error - visit admin_mail_templates_url - click_link_or_button 'New' - assert_text "HTML body" - assert_text "New mail template" - end -end