added the notification email method

This commit is contained in:
Tresor11
2020-07-02 22:51:37 +02:00
parent e64fa197aa
commit f2dd2c3bad
13 changed files with 88 additions and 34 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,7 +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, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :update }
# TODO: use counter_cache option on association
def submissions_count
@submissions_count ||= submissions.count
@@ -41,7 +41,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)