added the notification email method
This commit is contained in:
parent
e64fa197aa
commit
f2dd2c3bad
2
Gemfile
2
Gemfile
@ -28,11 +28,11 @@ gem 'lockbox'
|
|||||||
gem 'airrecord'
|
gem 'airrecord'
|
||||||
gem 'aws-sdk-s3', require: false
|
gem 'aws-sdk-s3', require: false
|
||||||
gem 'google-api-client'
|
gem 'google-api-client'
|
||||||
|
gem 'pagy'
|
||||||
gem 'rack-cors'
|
gem 'rack-cors'
|
||||||
gem 'sentry-raven'
|
gem 'sentry-raven'
|
||||||
gem 'sequenced'
|
gem 'sequenced'
|
||||||
gem 'sorcery'
|
gem 'sorcery'
|
||||||
gem 'pagy'
|
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
|
@ -17,9 +17,7 @@ class FormsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@forms = current_user.forms
|
@forms = current_user.forms
|
||||||
if @forms.empty?
|
redirect_to new_form_url if @forms.empty?
|
||||||
redirect_to new_form_url
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@ -33,6 +31,12 @@ class FormsController < ApplicationController
|
|||||||
|
|
||||||
def edit
|
def edit
|
||||||
@form = current_user.forms.find_by!(token: params[:id])
|
@form = current_user.forms.find_by!(token: params[:id])
|
||||||
|
puts "===========#{@form.notify_email}======================="
|
||||||
|
end
|
||||||
|
|
||||||
|
def notification
|
||||||
|
puts ''
|
||||||
|
@form = current_user.forms.find_by!(token: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@ -55,6 +59,6 @@ class FormsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def form_params
|
def form_params
|
||||||
params.require(:form).permit(:title, :thank_you_url, :backend_name, :google_spreadsheet_sheet, :airtable_table, :airtable_api_key, :airtable_app_key)
|
params.require(:form).permit(:title, :thank_you_url, :backend_name, :google_spreadsheet_sheet, :airtable_table, :airtable_api_key, :airtable_app_key, :notify_email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
include Pagy::Frontend
|
include Pagy::Frontend
|
||||||
end
|
end
|
||||||
|
@ -27,9 +27,7 @@ class Authentication < ApplicationRecord
|
|||||||
c.access_token = access_token
|
c.access_token = access_token
|
||||||
c.refresh_token = refresh_token
|
c.refresh_token = refresh_token
|
||||||
c.expires_at = expires_at
|
c.expires_at = expires_at
|
||||||
if expires_at < 1.minute.from_now
|
refresh_from(c) if expires_at < 1.minute.from_now
|
||||||
refresh_from(c)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ class Form < ApplicationRecord
|
|||||||
validates :airtable_api_key, presence: { if: :airtable? }
|
validates :airtable_api_key, presence: { if: :airtable? }
|
||||||
validates :airtable_app_key, presence: { if: :airtable? }
|
validates :airtable_app_key, presence: { if: :airtable? }
|
||||||
validates :airtable_table, presence: { if: :airtable? }
|
validates :airtable_table, presence: { if: :airtable? }
|
||||||
|
validates :notify_email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :update }
|
||||||
# TODO: use counter_cache option on association
|
# TODO: use counter_cache option on association
|
||||||
def submissions_count
|
def submissions_count
|
||||||
@submissions_count ||= submissions.count
|
@submissions_count ||= submissions.count
|
||||||
@ -41,7 +41,11 @@ class Form < ApplicationRecord
|
|||||||
def google?
|
def google?
|
||||||
backend_name == 'google_sheets'
|
backend_name == 'google_sheets'
|
||||||
end
|
end
|
||||||
def google; google?; end # TODO: remove this alias
|
|
||||||
|
# TODO: remove this alias
|
||||||
|
def google
|
||||||
|
google?
|
||||||
|
end
|
||||||
|
|
||||||
def backend
|
def backend
|
||||||
@backend ||= SpreadsheetBackends.const_get(backend_name.camelize).new(self)
|
@backend ||= SpreadsheetBackends.const_get(backend_name.camelize).new(self)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><%= link_to "Form Settings", edit_form_url(@form), class: "is-active" %></li>
|
<li><%= link_to "Form Settings", edit_form_url(@form), class: "is-active" %></li>
|
||||||
<li><%= link_to "Setup", setup_form_url(@form) %></li>
|
<li><%= link_to "Setup", setup_form_url(@form) %></li>
|
||||||
<li><a>Email notifications</a></li>
|
<li><%= link_to 'Email notifications', notification_form_url(@form) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
56
app/views/forms/notification.html.erb
Normal file
56
app/views/forms/notification.html.erb
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="is-pulled-right">
|
||||||
|
<%= link_to image_tag("#{@form.backend_name}-icon.svg", alt: @form.backend_name.humanize), @form.spreadsheet_url %>
|
||||||
|
</div>
|
||||||
|
<nav class="breadcrumb is-small has-bullet-separator" aria-label="breadcrumbs">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<%= link_to forms_url do %>
|
||||||
|
<span class="icon is-small"><i class="fas fa-home" aria-hidden="true"></i></span>
|
||||||
|
Forms
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<li><%= link_to @form.title, form_url(@form) %></li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<h1 class="title">
|
||||||
|
<%= @form.title %>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column is-one-quarter">
|
||||||
|
|
||||||
|
<aside class="menu">
|
||||||
|
<p class="menu-label">
|
||||||
|
General
|
||||||
|
</p>
|
||||||
|
<ul class="menu-list">
|
||||||
|
<li><%= link_to "Form Settings", edit_form_url(@form) %></li>
|
||||||
|
<li><%= link_to "Setup", setup_form_url(@form) %></li>
|
||||||
|
<li><%= link_to 'Email notifications', notification_form_url(@form), class: "is-active" %></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
|
||||||
|
<%= form_for @form, local: true do |f| %>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">Notification Email</label>
|
||||||
|
<div class="control">
|
||||||
|
<%= f.email_field :notify_email, class: 'input', placeholder: '', required: true, autocomplete: 'off' %>
|
||||||
|
</div>
|
||||||
|
<p class="help">On which Email would you like to be notified when a form is submitted?</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%= f.submit 'Save', class: 'button is-primary' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
@ -28,7 +28,7 @@
|
|||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><%= link_to "Form Settings", edit_form_url(@form) %></li>
|
<li><%= link_to "Form Settings", edit_form_url(@form) %></li>
|
||||||
<li><%= link_to "Setup", setup_form_url(@form), class: 'is-active' %></li>
|
<li><%= link_to "Setup", setup_form_url(@form), class: 'is-active' %></li>
|
||||||
<li><a>Email notifications</a></li>
|
<li><%= link_to 'Email notifications', notification_form_url(@form) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
if ENV['GOOGLE_DEMO_FORM_ID'].present?
|
|
||||||
GOOGLE_DEMO_FORM = Form.find_by(id: ENV['GOOGLE_DEMO_FORM_ID'])
|
|
||||||
end
|
|
||||||
|
|
||||||
if ENV['AIRTABLE_DEMO_FORM_ID'].present?
|
GOOGLE_DEMO_FORM = Form.find_by(id: ENV['GOOGLE_DEMO_FORM_ID']) if ENV['GOOGLE_DEMO_FORM_ID'].present?
|
||||||
AIRTABLE_DEMO_FORM = Form.find_by(id: ENV['AIRTABLE_DEMO_FORM_ID'])
|
|
||||||
end
|
AIRTABLE_DEMO_FORM = Form.find_by(id: ENV['AIRTABLE_DEMO_FORM_ID']) if ENV['AIRTABLE_DEMO_FORM_ID'].present?
|
||||||
|
|
||||||
AIRTABLE_DEMO_EMBED_URL = ENV['AIRTABLE_DEMO_EMBED_URL']
|
AIRTABLE_DEMO_EMBED_URL = ENV['AIRTABLE_DEMO_EMBED_URL']
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
# encoding: utf-8
|
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Pagy initializer file (3.8.0)
|
# Pagy initializer file (3.8.0)
|
||||||
# Customize only what you really need and notice that Pagy works also without any of the following lines.
|
# Customize only what you really need and notice that Pagy works also without any of the following lines.
|
||||||
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
||||||
|
|
||||||
|
|
||||||
# Extras
|
# Extras
|
||||||
# See https://ddnexus.github.io/pagy/extras
|
# See https://ddnexus.github.io/pagy/extras
|
||||||
|
|
||||||
|
|
||||||
# Backend Extras
|
# Backend Extras
|
||||||
|
|
||||||
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
|
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
|
||||||
@ -29,7 +26,6 @@
|
|||||||
# See https://ddnexus.github.io/pagy/extras/searchkick
|
# See https://ddnexus.github.io/pagy/extras/searchkick
|
||||||
# require 'pagy/extras/searchkick'
|
# require 'pagy/extras/searchkick'
|
||||||
|
|
||||||
|
|
||||||
# Frontend Extras
|
# Frontend Extras
|
||||||
|
|
||||||
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
|
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
|
||||||
@ -66,7 +62,6 @@ require 'pagy/extras/bulma'
|
|||||||
# See https://ddnexus.github.io/pagy/extras/navs#steps
|
# See https://ddnexus.github.io/pagy/extras/navs#steps
|
||||||
# Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
|
# Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
|
||||||
|
|
||||||
|
|
||||||
# Feature Extras
|
# Feature Extras
|
||||||
|
|
||||||
# Headers extra: http response headers (and other helpers) useful for API pagination
|
# Headers extra: http response headers (and other helpers) useful for API pagination
|
||||||
@ -101,19 +96,15 @@ require 'pagy/extras/bulma'
|
|||||||
# See https://ddnexus.github.io/pagy/extras/trim
|
# See https://ddnexus.github.io/pagy/extras/trim
|
||||||
# require 'pagy/extras/trim'
|
# require 'pagy/extras/trim'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Pagy Variables
|
# Pagy Variables
|
||||||
# See https://ddnexus.github.io/pagy/api/pagy#variables
|
# See https://ddnexus.github.io/pagy/api/pagy#variables
|
||||||
# All the Pagy::VARS are set for all the Pagy instances but can be overridden
|
# All the Pagy::VARS are set for all the Pagy instances but can be overridden
|
||||||
# per instance by just passing them to Pagy.new or the #pagy controller method
|
# per instance by just passing them to Pagy.new or the #pagy controller method
|
||||||
|
|
||||||
|
|
||||||
# Instance variables
|
# Instance variables
|
||||||
# See https://ddnexus.github.io/pagy/api/pagy#instance-variables
|
# See https://ddnexus.github.io/pagy/api/pagy#instance-variables
|
||||||
# Pagy::VARS[:items] = 20 # default
|
# Pagy::VARS[:items] = 20 # default
|
||||||
|
|
||||||
|
|
||||||
# Other Variables
|
# Other Variables
|
||||||
# See https://ddnexus.github.io/pagy/api/pagy#other-variables
|
# See https://ddnexus.github.io/pagy/api/pagy#other-variables
|
||||||
# Pagy::VARS[:size] = [1,4,4,1] # default
|
# Pagy::VARS[:size] = [1,4,4,1] # default
|
||||||
@ -122,7 +113,6 @@ require 'pagy/extras/bulma'
|
|||||||
# Pagy::VARS[:anchor] = '#anchor' # example
|
# Pagy::VARS[:anchor] = '#anchor' # example
|
||||||
# Pagy::VARS[:link_extra] = 'data-remote="true"' # example
|
# Pagy::VARS[:link_extra] = 'data-remote="true"' # example
|
||||||
|
|
||||||
|
|
||||||
# Rails
|
# Rails
|
||||||
|
|
||||||
# Rails: extras assets path required by the helpers that use javascript
|
# Rails: extras assets path required by the helpers that use javascript
|
||||||
@ -130,7 +120,6 @@ require 'pagy/extras/bulma'
|
|||||||
# See https://ddnexus.github.io/pagy/extras#javascript
|
# See https://ddnexus.github.io/pagy/extras#javascript
|
||||||
# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
|
# Rails.application.config.assets.paths << Pagy.root.join('javascripts')
|
||||||
|
|
||||||
|
|
||||||
# I18n
|
# I18n
|
||||||
|
|
||||||
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
|
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
|
||||||
@ -160,11 +149,10 @@ require 'pagy/extras/bulma'
|
|||||||
# filepath: 'path/to/pagy-xyz.yml',
|
# filepath: 'path/to/pagy-xyz.yml',
|
||||||
# pluralize: lambda{|count| ... } )
|
# pluralize: lambda{|count| ... } )
|
||||||
|
|
||||||
|
|
||||||
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
|
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
|
||||||
# than the default pagy internal i18n (see above)
|
# than the default pagy internal i18n (see above)
|
||||||
# See https://ddnexus.github.io/pagy/extras/i18n
|
# See https://ddnexus.github.io/pagy/extras/i18n
|
||||||
# require 'pagy/extras/i18n'
|
# require 'pagy/extras/i18n'
|
||||||
|
|
||||||
# Default i18n key
|
# Default i18n key
|
||||||
# Pagy::VARS[:i18n_key] = 'pagy.item_name' # default
|
# Pagy::VARS[:i18n_key] = 'pagy.item_name' # default
|
||||||
|
@ -7,6 +7,7 @@ Rails.application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
get :form
|
get :form
|
||||||
get :setup
|
get :setup
|
||||||
|
get :notification
|
||||||
end
|
end
|
||||||
resources :submissions
|
resources :submissions
|
||||||
end
|
end
|
||||||
@ -29,7 +30,7 @@ Rails.application.routes.draw do
|
|||||||
get '/auth' => 'sessions#auth', :as => :auth
|
get '/auth' => 'sessions#auth', :as => :auth
|
||||||
|
|
||||||
get '/demo(/:backend)' => 'home#demo', :as => :demo
|
get '/demo(/:backend)' => 'home#demo', :as => :demo
|
||||||
get '/contact', to: redirect('/#contact-us'), :as => :contact
|
get '/contact', to: redirect('/#contact-us'), as: :contact
|
||||||
get '/help', to: redirect('https://www.notion.so/Tinyforms-Help-Center-04f13b5908bc46cfb4283079a3cb1149')
|
get '/help', to: redirect('https://www.notion.so/Tinyforms-Help-Center-04f13b5908bc46cfb4283079a3cb1149')
|
||||||
get '/privacy', to: redirect('https://www.notion.so/Privacy-Policy-f4bd2d6c8e7742bbb9ca1c952aec0379')
|
get '/privacy', to: redirect('https://www.notion.so/Privacy-Policy-f4bd2d6c8e7742bbb9ca1c952aec0379')
|
||||||
get '/terms', to: redirect('https://www.notion.so/Terms-and-Conditions-d73fd11089164eac91ede8ab4b4da5b3')
|
get '/terms', to: redirect('https://www.notion.so/Terms-and-Conditions-d73fd11089164eac91ede8ab4b4da5b3')
|
||||||
|
5
db/migrate/20200702202828_add_notify_email_to_forms.rb
Normal file
5
db/migrate/20200702202828_add_notify_email_to_forms.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddNotifyEmailToForms < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :forms, :notify_email, :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: 2020_06_10_131725) do
|
ActiveRecord::Schema.define(version: 2020_07_02_202828) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -62,6 +62,7 @@ ActiveRecord::Schema.define(version: 2020_06_10_131725) do
|
|||||||
t.string "airtable_table"
|
t.string "airtable_table"
|
||||||
t.string "backend_name"
|
t.string "backend_name"
|
||||||
t.string "google_spreadsheet_sheet"
|
t.string "google_spreadsheet_sheet"
|
||||||
|
t.string "notify_email"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "submissions", force: :cascade do |t|
|
create_table "submissions", force: :cascade do |t|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user