Merge pull request #48 from bumi/email-notification

Added the notify_email column to the forms table
This commit is contained in:
2020-07-22 16:30:34 +02:00
committed by GitHub
14 changed files with 93 additions and 35 deletions

View File

@@ -27,9 +27,7 @@ class Authentication < ApplicationRecord
c.access_token = access_token
c.refresh_token = refresh_token
c.expires_at = expires_at
if expires_at < 1.minute.from_now
refresh_from(c)
end
refresh_from(c) if expires_at < 1.minute.from_now
end
end
end

View File

@@ -18,6 +18,7 @@ class Form < ApplicationRecord
validates :airtable_api_key, presence: { if: :airtable? }
validates :airtable_app_key, presence: { if: :airtable? }
validates :airtable_table, presence: { if: :airtable? }
validates :notify_email, presence: true, on: :update, allow_blank: true
# TODO: use counter_cache option on association
def submissions_count
@@ -41,7 +42,11 @@ class Form < ApplicationRecord
def google?
backend_name == 'google_sheets'
end
def google; google?; end # TODO: remove this alias
# TODO: remove this alias
def google
google?
end
def backend
@backend ||= SpreadsheetBackends.const_get(backend_name.camelize).new(self)