diff --git a/app/helpers/mail_helper.rb b/app/helpers/mail_helper.rb new file mode 100644 index 00000000..e5ca70c1 --- /dev/null +++ b/app/helpers/mail_helper.rb @@ -0,0 +1,3 @@ +module MailHelper + +end diff --git a/app/models/table.rb b/app/models/table.rb index ffcfa10f..09c1bbec 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -15,10 +15,22 @@ class Table #validates :list_id, presence: true validates :number, numericality: {greater_than: 0} view :by_supplier_id_and_id, key: [:supplier_id, :_id] + view :by_supplier_id_and_number, key: [:supplier_id, :number] #validates_uniqueness_of :number view :by_number, key: :number + def self.for_supplier(supplier, options = {}) + startkey = options[:from_number].present? ? [supplier.id, options.delete(:from_number).to_i] : [supplier.id] + endkey = options[:to_number].present? ? [supplier.id, options.delete(:to_number).to_i]: [supplier.id, {}] + + total_entries = database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: false, reduce: true})) + options[:total_entries] = total_entries + with_pagination_options(options) do |options| + database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: true, reduce: false}.merge(options))) + end + end + def occupied? return @is_occupied if instance_variable_defined?(:'@is_occupied') @is_occupied = !self.class.database.view(List.active_by_table_id_view(key: id, reduce: true)).zero? diff --git a/app/views/suppliers/mailer/confirmation_instructions.html.erb b/app/views/suppliers/mailer/confirmation_instructions.html.erb deleted file mode 100644 index a5c4585e..00000000 --- a/app/views/suppliers/mailer/confirmation_instructions.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -
Welcome <%= @resource.email %>!
- -You can confirm your account email through the link below:
- -<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/suppliers/mailer/confirmation_instructions.html.slim b/app/views/suppliers/mailer/confirmation_instructions.html.slim new file mode 100644 index 00000000..807dc09e --- /dev/null +++ b/app/views/suppliers/mailer/confirmation_instructions.html.slim @@ -0,0 +1,7 @@ +h3 "Welkom bij Qwaiter #{@resource.email}!" +p + | + Je hebt een account aangevraag bij Qwaiter. Als dit niet de bedoeling is kan je deze email negeren. + Om je account te activeren moet je op de bevestigingslink hieronder klikken: + +p= link_to 'Bevestig mijn Qwaiter account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) diff --git a/app/views/suppliers/tables/index.html.slim b/app/views/suppliers/tables/index.html.slim index adebad23..1478b6f6 100644 --- a/app/views/suppliers/tables/index.html.slim +++ b/app/views/suppliers/tables/index.html.slim @@ -5,10 +5,10 @@ div.page-header= title :index, model_class table.table thead tr - th.link= model_class.human_attribute_name(:number) - th.link= Section.model_name.human - th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions' + th.link data-t="attributes.table.number"= model_class.human_attribute_name(:number) + th.link data-t="models.section"= Section.model_name.human + th.timestamp data-t="attributes.table.created_at"= model_class.human_attribute_name(:created_at) + th.actions data-t="helpers.actions"=t 'helpers.actions' tbody - @tables.each do |table| tr diff --git a/config/application.rb b/config/application.rb index 2586a3bd..ff47a8f3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -75,6 +75,13 @@ module Qwaiter config.assets.precompile += ['supplier/application.css', 'user/application.css', 'qr_sheet/application.css'] config.default_url_options = {format: 'html'} + config.to_prepare do + Devise::Mailer.layout "mail" + Devise::Mailer.class_eval do + helper :mail + end + end + #config.middleware.use Rack::Cors do # allow do # origins '*' diff --git a/config/environments/production.rb b/config/environments/production.rb index d5659407..8c6c07d0 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -50,6 +50,9 @@ Qwaiter::Application.configure do # Disable delivery errors, bad email addresses will be ignored config.action_mailer.raise_delivery_errors = false + config.action_mailer.default_url_options = { + host: 'www.qwaiter.com' + } config.action_mailer.smtp_settings = { address: "smtp.gmail.com", port: 587, diff --git a/config/environments/test.rb b/config/environments/test.rb index 30759687..a7504865 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -27,6 +27,9 @@ Qwaiter::Application.configure do # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. + config.action_mailer.default_url_options = { + host: 'www.qwaiter.com' + } config.action_mailer.delivery_method = :test # Raise exception on mass assignment protection for Active Record models diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 90e36697..04eeb97a 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -4,7 +4,7 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" + config.mailer_sender = 'Qwaiter