Supplier mail changing and polishing
This commit is contained in:
@@ -15,7 +15,6 @@ var $translations = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$transformation_mappings = {
|
||||
downcase: 'toLowerCase',
|
||||
upcase: 'toUpperCase'
|
||||
@@ -68,7 +67,7 @@ function setTranslations(selector){
|
||||
}
|
||||
moment.lang($locale);
|
||||
$('[data-time]').each(function(){
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D HH:MM'))
|
||||
$(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D MMM HH:MM'))
|
||||
})
|
||||
|
||||
$('.datepicker').datepicker("option", $.datepicker.regional[$locale])
|
||||
|
||||
@@ -52,3 +52,7 @@ input.dimension
|
||||
cursor: move
|
||||
font-size: 0.8em
|
||||
color: #777
|
||||
form
|
||||
&.form-inline
|
||||
display: inline-block
|
||||
padding: 4px
|
||||
|
||||
@@ -3,6 +3,27 @@ module Suppliers
|
||||
# GET /lists
|
||||
# GET /lists.json
|
||||
def index
|
||||
@lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25)
|
||||
@lists.include_relation(:table)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @lists }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def active
|
||||
@lists = List.active_for_supplier(current_supplier.id)
|
||||
@lists.include_relation(:table) # for number
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @lists }
|
||||
end
|
||||
end
|
||||
|
||||
def at_date
|
||||
@date = params[:date].present? ? (Date.parse(params[:date]) rescue Date.today) : Date.today
|
||||
@time = @date.to_time(:utc)
|
||||
@start_time = @time.beginning_of_day
|
||||
@@ -11,14 +32,8 @@ module Suppliers
|
||||
@start_time += current_supplier.night_offset.to_f.hours
|
||||
@end_time += current_supplier.night_offset.to_f.hours
|
||||
end
|
||||
if params[:show_all] == 'yes'
|
||||
@lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25)
|
||||
elsif params[:state] == 'active'
|
||||
@lists = List.active_for_supplier(current_supplier.id)
|
||||
else
|
||||
@lists = List.for_supplier_created_at current_supplier, @start_time..@end_time
|
||||
end
|
||||
@lists.include_relation(:table)
|
||||
@lists = List.for_supplier_created_at current_supplier, @start_time..@end_time
|
||||
@lists.include_relation(:table) # for number
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -79,6 +79,7 @@ class List
|
||||
def self.for_supplier(supplier, options = {})
|
||||
total_entries = database.view(for_supplier_view({startkey: ["#{supplier.id}\u9999"], endkey: [supplier.id], include_docs: false, reduce: true, descending: true}))
|
||||
options[:total_entries] = total_entries
|
||||
options[:descending] = true
|
||||
with_pagination_options(options) do |options|
|
||||
database.view(for_supplier_view({startkey: ["#{supplier.id}\u9999"], endkey: [supplier.id], include_docs: true, reduce: false, descending: true}.merge(options)))
|
||||
end
|
||||
|
||||
@@ -50,6 +50,11 @@ class User
|
||||
save
|
||||
end
|
||||
|
||||
# This is the user name as it is shown to the supplier
|
||||
def supplier_name
|
||||
auth_data['info']['name'] rescue I18n.t('user.unknown_supplier_name')
|
||||
end
|
||||
|
||||
def has_active_list?
|
||||
active_list_id.present?
|
||||
end
|
||||
|
||||
@@ -59,6 +59,6 @@
|
||||
= image_tag 'supplier/settings/iens-example.png', title: 'supplier.settings.reviews.explanation'
|
||||
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
= f.submit nil, class: 'btn btn-primary submit-supplier-settings'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), supplier_root_path, class: 'btn'
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th data-t='attributes.list.state' = List.human_attribute_name(:state)
|
||||
th data-t='attributes.list.needs_help' = List.human_attribute_name(:needs_help)
|
||||
th data-t='attributes.list.needs_payment' = List.human_attribute_name(:needs_payment)
|
||||
th data-t='attributes.list.closed_at' = List.human_attribute_name(:closed_at)
|
||||
th data-t='models.table' = Table.model_name.human
|
||||
th.currency data-t='attributes.list.price' = List.human_attribute_name(:price)
|
||||
th.timestamp data-t='attributes.list.created_at' = List.human_attribute_name(:created_at)
|
||||
th.actions data-t='helpers.actions.title' =t 'helpers.actions.title'
|
||||
tbody
|
||||
- lists.each do |list|
|
||||
tr
|
||||
td= link_to list.state, [:suppliers, list]
|
||||
td=show_boolean list.needs_help
|
||||
td=show_boolean list.needs_payment
|
||||
td.timestamp data-time=list.closed_at.try(:utc).try(:iso8601)
|
||||
td= link_to_if list.table.present?, list.table_number, [:suppliers, list.table]
|
||||
td.currency= list.price.present? ? currency(list.price) : '...'
|
||||
td.timestamp data-time=list.created_at.utc.iso8601
|
||||
td.actions
|
||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, list], class: 'btn btn-mini', data: {t: 'helpers.links.edit'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, list], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger', data: {t: 'helpers.links.destroy'}
|
||||
@@ -0,0 +1,7 @@
|
||||
- model_class = List
|
||||
div.page-header= title :index, model_class
|
||||
.well
|
||||
- if @lists.any?
|
||||
= render 'lists_table', lists: @lists
|
||||
- else
|
||||
= no_content_given model_class
|
||||
@@ -0,0 +1,12 @@
|
||||
- model_class = List
|
||||
div.page-header= title :index, model_class
|
||||
form#select-date-form.form-inline action='' method="get"
|
||||
label for="lists-date" data-t="lists.index.show_list_on_day"
|
||||
input#lists-date.datepicker type="text" name="date" value=@date.to_s('%Y-%m-%d')
|
||||
.well
|
||||
- if @lists.any?
|
||||
= render 'lists_table', lists: @lists
|
||||
- else
|
||||
= no_content_given model_class
|
||||
javascript:
|
||||
window.datepicker_options['onSelect'] = function(dateText, inst){$('#select-date-form').submit()}
|
||||
@@ -1,39 +1,7 @@
|
||||
- model_class = List
|
||||
div.page-header= title :index, model_class
|
||||
form#select-date-form action='' method="get"
|
||||
- if params[:show_all] == 'yes'
|
||||
- else
|
||||
input#lists-date.datepicker type="text" name="date" value=@date.to_s('%Y-%m-%d')
|
||||
= link_to '', {show_all: 'yes'}, class: 'btn', data: {t: 'lists.index.show_all'}
|
||||
div.page-header= title :index, List
|
||||
.well
|
||||
- if @lists.any?
|
||||
= paginate @lists if params[:show_all] == 'yes'
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th data-t='attributes.list.state' = model_class.human_attribute_name(:state)
|
||||
th data-t='attributes.list.needs_help' = model_class.human_attribute_name(:needs_help)
|
||||
th data-t='attributes.list.needs_payment' = model_class.human_attribute_name(:needs_payment)
|
||||
th data-t='attributes.list.closed_at' = model_class.human_attribute_name(:closed_at)
|
||||
th data-t='models.table' = Table.model_name.human
|
||||
th.currency data-t='attributes.list.price' = model_class.human_attribute_name(:price)
|
||||
th.timestamp data-t='attributes.list.created_at' = model_class.human_attribute_name(:created_at)
|
||||
th.actions data-t='helpers.actions.title' =t 'helpers.actions.title'
|
||||
tbody
|
||||
- @lists.each do |list|
|
||||
tr
|
||||
td= link_to list.state, [:suppliers, list]
|
||||
td=show_boolean list.needs_help
|
||||
td=show_boolean list.needs_payment
|
||||
td.timestamp data-time=list.closed_at.try(:utc).try(:iso8601)
|
||||
td= link_to_if list.table.present?, list.table_number, [:suppliers, list.table]
|
||||
td.currency= list.price.present? ? currency(list.price) : '...'
|
||||
td.timestamp data-time=list.created_at.utc.iso8601
|
||||
td.actions
|
||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, list], class: 'btn btn-mini', data: {t: 'helpers.links.edit'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, list], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger', data: {t: 'helpers.links.destroy'}
|
||||
= paginate @lists
|
||||
= render 'lists_table', lists: @lists
|
||||
- else
|
||||
= no_content_given model_class
|
||||
javascript:
|
||||
window.datepicker_options['onSelect'] = function(dateText, inst){$('#select-date-form').submit()}
|
||||
= no_content_given List
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
dl.dl-horizontal
|
||||
dt= List.human_attribute_name(:created_at)
|
||||
dd= l @list.created_at, format: :short
|
||||
dt= t('supplier.lists.show.users')
|
||||
dd= @list.users.map(&:supplier_name).join(', ')
|
||||
.well
|
||||
table#list-table.table.list-table
|
||||
thead
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
h3 "Welkom bij Qwaiter #{@resource.email}!"
|
||||
p
|
||||
|
|
||||
Je hebt een account aangevraag bij Qwaiter of wil een wijziging doorvoeren waarvoor bevestiging nodig is. Als dit niet de bedoeling is kan je deze email negeren.
|
||||
Om je account te activeren of de aangevraagde wijziging door te voeren moet je op de bevestigingslink hieronder klikken:
|
||||
p= t('devise.mailer.confirmation_instructions.supplier.salutation', email: @resource.email)
|
||||
|
||||
p= link_to 'Bevestig mijn Qwaiter account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
|
||||
p=raw t \
|
||||
'devise.mailer.confirmation_instructions.supplier.body',
|
||||
unconfirmed_email: @resource.unconfirmed_email,
|
||||
confirm_url: confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
dl.dl-horizontal.show-list
|
||||
dt data-t='attributes.product_category.name'= model_class.human_attribute_name(:name)
|
||||
dd= @product_category.name
|
||||
dt data-t='attributes.product_category.position'= model_class.human_attribute_name(:position)
|
||||
dd= @product_category.position
|
||||
/dt data-t='attributes.product_category.position'= model_class.human_attribute_name(:position)
|
||||
/dd= @product_category.position
|
||||
dt data-t='attributes.product_category.visible_on'= model_class.human_attribute_name(:visible_on)
|
||||
dd= @product_category.visible_on
|
||||
dt data-t='models.plural.product'= Product.model_name.human_plural
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
= f.text_field :height, class: ['text_field', :numeric]
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
- unless f.object.new_record?
|
||||
'
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_sections_path, class: 'btn'
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
span.active-table-count= (@active_table_ids & section.tables.map(&:id)).size
|
||||
td.numeric= section.width
|
||||
td.numeric= section.height
|
||||
td.actions = link_to t("helpers.links.destroy"), [:suppliers, section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy'}, class: 'btn btn-mini btn-danger'
|
||||
td.actions
|
||||
= link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: section.id), class: 'btn btn-mini btn-info', data: {t: 'tables.qr_codes.link'}
|
||||
'
|
||||
= link_to t("helpers.links.destroy"), [:suppliers, section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy'}, class: 'btn btn-mini btn-danger'
|
||||
- else
|
||||
= no_content_given model_class
|
||||
.form-actions
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<p>Welcome <%= @resource.email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
|
||||
@@ -0,0 +1,6 @@
|
||||
p= t('devise.mailer.confirmation_instructions.salutation', email: @resource.email)
|
||||
|
||||
p=raw t \
|
||||
'devise.mailer.confirmation_instructions.body',
|
||||
unconfirmed_email: @resource.unconfirmed_email,
|
||||
confirm_url: confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
|
||||
@@ -206,7 +206,7 @@ Devise.setup do |config|
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# are using only default views.
|
||||
# config.scoped_views = false
|
||||
config.scoped_views = true
|
||||
|
||||
# Configure the default scope given to Warden. By default it's the first
|
||||
# devise role declared in your routes (usually :user).
|
||||
|
||||
@@ -19,7 +19,17 @@ en:
|
||||
unconfirmed: "You have to confirm your account before continuing."
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: "Confirmation instructions"
|
||||
supplier_subject: "Confirmation instructions2"
|
||||
supplier:
|
||||
salutation: "Welcome to Qwaiter %{email}!"
|
||||
body: |
|
||||
<p>
|
||||
You requested a Qwaiter account or want to change data that need reconfirmation.
|
||||
If this is not wat you requested please ignore this email.<br>
|
||||
To activate your account click the link below:<br>
|
||||
<br>
|
||||
<a href="%{confirm_url}">Confirm my account or changes %{unconfirmed_email}</a>
|
||||
</p>
|
||||
reset_password_instructions:
|
||||
subject: "Reset password instructions"
|
||||
unlock_instructions:
|
||||
|
||||
@@ -9,6 +9,13 @@ nl:
|
||||
other: "%{count} fouten verhinderden het uitvoeren van de actie:"
|
||||
|
||||
devise:
|
||||
confirmations:
|
||||
send_instructions: 'Er wordt een een e-mail naar je toe gestuurd waarin je je account kan bevestigen.'
|
||||
confirmed: 'De activatie van je account is succesvol. Je bent nu aangemeld!'
|
||||
did_not_receive_instructions_link: "Heeft u geen bevestigingsinstructies ontvangen?"
|
||||
did_not_receive: 'Heeft u geen bevestigingsinstructies ontvangen?'
|
||||
supplier:
|
||||
confirmed_and_signed_in: Account bevestigd en ingelogd
|
||||
failure:
|
||||
already_authenticated: 'U bent reeds ingelogd.'
|
||||
unauthenticated: 'U moet inloggen voordat u verder kunt'
|
||||
@@ -35,11 +42,6 @@ nl:
|
||||
updated: 'Uw wachtwoord is succesvol gewijzigd. U bent nu ingelogd.'
|
||||
forgot_password: Wachtwoord vergeten?
|
||||
send_instructions_button: Stuur mij reset instructies
|
||||
confirmations:
|
||||
send_instructions: 'Er wordt een een e-mail naar je toe gestuurd waarin je je account kan bevestigen.'
|
||||
confirmed: 'De activatie van je account is succesvol. Je bent nu aangemeld!'
|
||||
did_not_receive_instructions_link: "Heeft u geen bevestigingsinstructies ontvangen?"
|
||||
did_not_receive: 'Heeft u geen bevestigingsinstructies ontvangen?'
|
||||
registrations:
|
||||
title: Aanmelden
|
||||
button: Aanmelden
|
||||
@@ -66,6 +68,17 @@ nl:
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Bevestigingsinstructies'
|
||||
#supplier_subject: "Confirmation instructions"
|
||||
supplier:
|
||||
salutation: "Welkom bij Qwaiter %{email}!"
|
||||
body: |
|
||||
<p>
|
||||
Je hebt een account aangevraag bij Qwaiter of wil een wijziging doorvoeren waarvoor bevestiging nodig is.
|
||||
Als dit niet de bedoeling is kan je deze email negeren.<br>
|
||||
Om je account te activeren of de aangevraagde wijziging door te voeren moet je op de bevestigingslink hieronder klikken:<br>
|
||||
<br>
|
||||
<a href="%{confirm_url}">Bevestig mijn Qwaiter account of verandering %{unconfirmed_email}</a>
|
||||
</p>
|
||||
reset_password_instructions:
|
||||
subject: 'Wachtwoord reset instructies'
|
||||
unlock_instructions:
|
||||
|
||||
@@ -24,8 +24,11 @@ en:
|
||||
lists:
|
||||
index:
|
||||
show_all: Show all ${models.plural.list}
|
||||
show_active: Show active ${models.plural.list}
|
||||
show_list_on_day: Lists on date
|
||||
show:
|
||||
title: Show %{list}
|
||||
users: Clients
|
||||
list:
|
||||
is_helped_button: Question answered!
|
||||
close_list: Close!
|
||||
|
||||
@@ -24,8 +24,11 @@ nl:
|
||||
lists:
|
||||
index:
|
||||
show_all: Toon alle ${models.plural.list}
|
||||
show_active: Toon actieve ${models.plural.list}
|
||||
show_list_on_day: 'Lijsten op datum'
|
||||
show:
|
||||
title: "%{list} tonen"
|
||||
users: Klanten
|
||||
list:
|
||||
is_helped_button: Vraag beantwoord!
|
||||
close_list: Afsluiten!
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
en:
|
||||
user:
|
||||
unknown_supplier_name: unknown
|
||||
active_list:
|
||||
title: Active list
|
||||
needs_payment: Check please!
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
nl:
|
||||
user:
|
||||
unknown_supplier_name: onbekend
|
||||
active_list:
|
||||
title: Actieve lijst
|
||||
needs_payment: Rekening vragen!
|
||||
|
||||
+6
-1
@@ -97,7 +97,12 @@ Qwaiter::Application.routes.draw do
|
||||
get :preview_products
|
||||
end
|
||||
end
|
||||
resources :lists
|
||||
resources :lists do
|
||||
collection do
|
||||
get :active
|
||||
get :at_date
|
||||
end
|
||||
end
|
||||
resources :product_categories do
|
||||
collection do
|
||||
post :sort
|
||||
|
||||
@@ -1,2 +1,13 @@
|
||||
Feature: Manage settings
|
||||
Scenario: Changing the supplier email
|
||||
Given there is a confirmed and open supplier
|
||||
And I am signed in as supplier
|
||||
When I visit the supplier settings path
|
||||
And I provide a new supplier email address
|
||||
And the supplier submits the supplier settings form
|
||||
Then the supplier email should not have been changed
|
||||
And the supplier unconfirmed email should have been set to the new supplier email
|
||||
And an email should have been sent to the original supplier email with email confirmation instructions
|
||||
When the supplier clicks on the new email confirmation link
|
||||
Then the supplier gets redirected to the supplier settings path
|
||||
And the supplier email is the new email and the unconfirmed email is empty
|
||||
|
||||
@@ -12,5 +12,10 @@ end
|
||||
|
||||
|
||||
step "I should be redirected to the supplier settings page" do
|
||||
page.current_path.should == supplier_settings_path
|
||||
#page.current_path.should == supplier_settings_path
|
||||
route_should_be 'supplier#edit'
|
||||
end
|
||||
|
||||
step "I visit the supplier settings path" do
|
||||
visit supplier_settings_path
|
||||
end
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
step "I provide a new supplier email address" do
|
||||
find('#supplier_email').set 'new-supplier-mail@qwaiter.com'
|
||||
end
|
||||
|
||||
step "the supplier submits the supplier settings form" do
|
||||
find('.submit-supplier-settings').click
|
||||
end
|
||||
|
||||
step "the supplier email should not have been changed" do
|
||||
@supplier.reload
|
||||
@supplier.email.should == 'supplier@qwaiter.com'
|
||||
end
|
||||
|
||||
step "the supplier unconfirmed email should have been set to the new supplier email" do
|
||||
@supplier.reload
|
||||
@supplier.unconfirmed_email.should == 'new-supplier-mail@qwaiter.com'
|
||||
end
|
||||
|
||||
step "an email should have been sent to the original supplier email with email confirmation instructions" do
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
mail.to.should == ['supplier@qwaiter.com']
|
||||
mail.body.should include I18n.t('devise.mailer.confirmation_instructions.supplier.salutation', email: @supplier.email)
|
||||
mail.body.should_not include 'translation' # indicating a translation issue
|
||||
confirmation_link_match = mail.body.match(/http:\/\/www.qwaiter.com(\/suppliers\/confirmation[^"]+)"/)
|
||||
confirmation_link_match.should be_present
|
||||
@confirmation_link = confirmation_link_match[1]
|
||||
end
|
||||
|
||||
step "the supplier clicks on the new email confirmation link" do
|
||||
visit @confirmation_link
|
||||
end
|
||||
|
||||
step "the supplier gets redirected to the supplier settings path" do
|
||||
route_should_be 'supplier#edit'
|
||||
end
|
||||
|
||||
step "the supplier email is the new email and the unconfirmed email is empty" do
|
||||
@supplier.reload
|
||||
@supplier.email.should == 'new-supplier-mail@qwaiter.com'
|
||||
@supplier.unconfirmed_email.should be_blank
|
||||
end
|
||||
Reference in New Issue
Block a user