From b16250059aebc7cdcdaf26de91d19b3c94013f89 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 20 Aug 2020 14:21:35 -0300 Subject: [PATCH] poder reenviar formularios desde la consola --- app/models/log_entry.rb | 12 ++++++++++++ db/migrate/20200820165316_add_sent_to_log_entries.rb | 5 +++++ db/schema.rb | 8 +------- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20200820165316_add_sent_to_log_entries.rb diff --git a/app/models/log_entry.rb b/app/models/log_entry.rb index 45023d51..59b368f1 100644 --- a/app/models/log_entry.rb +++ b/app/models/log_entry.rb @@ -7,4 +7,16 @@ class LogEntry < ApplicationRecord serialize :text, JSON default_scope -> { order(created_at: :desc) } + + def resend + return if sent + + ContactJob.perform_async site_id: site_id, + form_name: params[:form], + form: params + end + + def params + @params ||= text&.dig('params')&.symbolize_keys + end end diff --git a/db/migrate/20200820165316_add_sent_to_log_entries.rb b/db/migrate/20200820165316_add_sent_to_log_entries.rb new file mode 100644 index 00000000..614f134d --- /dev/null +++ b/db/migrate/20200820165316_add_sent_to_log_entries.rb @@ -0,0 +1,5 @@ +class AddSentToLogEntries < ActiveRecord::Migration[6.0] + def change + add_column :log_entries, :sent, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ca1dd40..4df09176 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20_200_811_210_507) do - # Could not dump table "access_logs" because of following StandardError - # Unknown type '' for column 'id' - +ActiveRecord::Schema.define(version: 20_200_816_003_344) do create_table 'action_text_rich_texts', force: :cascade do |t| t.string 'name', null: false t.text 'body' @@ -56,9 +53,6 @@ ActiveRecord::Schema.define(version: 20_200_811_210_507) do t.index ['deploy_id'], name: 'index_build_stats_on_deploy_id' end - # Could not dump table "csp_reports" because of following StandardError - # Unknown type 'uuid' for column 'id' - create_table 'deploys', force: :cascade do |t| t.datetime 'created_at', null: false t.datetime 'updated_at', null: false