Merge branch 'master' into feature-receive
Conflicts: app/helpers/finance/order_articles_helper.rb
This commit is contained in:
commit
b30b424540
26 changed files with 247 additions and 69 deletions
|
|
@ -26,11 +26,11 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def deny_access
|
||||
session[:return_to] = request.original_url
|
||||
redirect_to login_url, :alert => I18n.t('application.controller.error_denied')
|
||||
redirect_to root_url, alert: I18n.t('application.controller.error_denied', sign_in: ActionController::Base.helpers.link_to(t('application.controller.error_denied_sign_in'), login_path))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def authenticate(role = 'any')
|
||||
# Attempt to retrieve authenticated user from controller instance or session...
|
||||
if !current_user
|
||||
|
|
@ -92,6 +92,18 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def authenticate_or_token(prefix, role = 'any')
|
||||
if not params[:token].blank?
|
||||
begin
|
||||
TokenVerifier.new(prefix).verify(params[:token])
|
||||
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
||||
redirect_to root_path, alert: I18n.t('application.controller.error_token')
|
||||
end
|
||||
else
|
||||
authenticate(role)
|
||||
end
|
||||
end
|
||||
|
||||
# Stores this controller instance as a thread local varibale to be accessible from outside ActionController/ActionView.
|
||||
def store_controller
|
||||
Thread.current[:application_controller] = self
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class SessionsController < ApplicationController
|
|||
|
||||
def destroy
|
||||
session[:user_id] = nil
|
||||
session[:return_to] = nil
|
||||
redirect_to login_url, :notice => I18n.t('sessions.logged_out')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,35 +7,14 @@
|
|||
.modal-body
|
||||
= f.input :availability
|
||||
= f.input :name
|
||||
.fold-line
|
||||
= f.input :unit_quantity, label: Article.human_attribute_name(:unit),
|
||||
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit_quantity)}
|
||||
= f.input :unit, label: '×'.html_safe,
|
||||
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit)}
|
||||
|
||||
= render partial: 'shared/article_fields_units', locals: {f: f}
|
||||
|
||||
= f.input :note
|
||||
= f.association :article_category
|
||||
/ TODO labels
|
||||
|
||||
.fold-line
|
||||
= f.input :price do
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= f.input_field :price, class: 'input-mini'
|
||||
= f.input :tax do
|
||||
.input-append
|
||||
= f.input_field :tax, class: 'input-mini'
|
||||
%span.add-on %
|
||||
.fold-line
|
||||
= f.input :deposit do
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= f.input_field :deposit, class: 'input-mini'
|
||||
.control-group
|
||||
%label.control-label{for: 'article_fc_price'}
|
||||
= Article.human_attribute_name(:fc_price)
|
||||
.controls.control-text#article_fc_price
|
||||
= number_to_currency(@article.fc_price) rescue nil
|
||||
= render partial: 'shared/article_fields_price', locals: {f: f}
|
||||
|
||||
= f.input :origin
|
||||
= f.input :manufacturer
|
||||
|
|
@ -44,14 +23,3 @@
|
|||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= f.submit class: 'btn btn-primary'
|
||||
|
||||
:javascript
|
||||
var form = $('form.edit_article, form.new_article');
|
||||
$('#article_price, #article_tax, #article_deposit', form).on('change keyup', function() {
|
||||
var price = parseFloat($('#article_price', form).val());
|
||||
var tax = parseFloat($('#article_tax', form).val());
|
||||
var deposit = parseFloat($('#article_deposit', form).val());
|
||||
// Article#gross_price and Article#fc_price
|
||||
var gross_price = (price + deposit) * (tax / 100 + 1);
|
||||
var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1);
|
||||
$('#article_fc_price').html($.isNumeric(fc_price) ? I18n.l("currency", fc_price) : '…');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
= csrf_meta_tags
|
||||
= stylesheet_link_tag "application", :media => "all"
|
||||
//%link(href="images/favicon.ico" rel="shortcut icon")
|
||||
|
||||
|
||||
= yield(:head)
|
||||
|
||||
%body
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
- title t('.title')
|
||||
= raw t('.body', user: h(show_user(@user)))
|
||||
= simple_form_for @user, :url => update_password_path(@user.id, :token => @user.reset_password_token) do |form|
|
||||
= simple_form_for @user, :url => {:action => 'update_password', :id => @user.id, :token => @user.reset_password_token} do |form|
|
||||
= form.input :password
|
||||
= form.input :password_confirmation
|
||||
.form-actions
|
||||
|
|
|
|||
|
|
@ -17,18 +17,16 @@
|
|||
|
||||
= simple_fields_for :article, @order_article.article do |f|
|
||||
= f.input :name
|
||||
= f.input :order_number
|
||||
= f.input :unit
|
||||
|
||||
- if @order_article.article.is_a?(StockArticle)
|
||||
%div.alert= t '.stock_alert'
|
||||
- else
|
||||
= simple_fields_for :article_price, @order_article.article_price do |f|
|
||||
= f.input :unit_quantity
|
||||
= f.input :price
|
||||
= f.input :tax
|
||||
= f.input :deposit
|
||||
- if @order_article.article.is_a?(StockArticle)
|
||||
%div.alert= t '.stock_alert'
|
||||
- else
|
||||
= simple_fields_for :article_price, @order_article.article_price do |fprice|
|
||||
= render partial: 'shared/article_fields_units', locals: {f_unit: f, f_uq: fprice}
|
||||
= render partial: 'shared/article_fields_price', locals: {f: fprice}
|
||||
|
||||
= form.input :update_current_price, as: :boolean
|
||||
= f.input :order_number
|
||||
.modal-footer
|
||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= form.submit class: 'btn btn-primary'
|
||||
|
|
|
|||
34
app/views/shared/_article_fields_price.html.haml
Normal file
34
app/views/shared/_article_fields_price.html.haml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
.fold-line
|
||||
= f.input :price do
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= f.input_field :price, class: 'input-mini'
|
||||
= f.input :tax do
|
||||
.input-append
|
||||
= f.input_field :tax, class: 'input-mini'
|
||||
%span.add-on %
|
||||
.fold-line
|
||||
= f.input :deposit do
|
||||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= f.input_field :deposit, class: 'input-mini'
|
||||
.control-group
|
||||
%label.control-label{for: 'article_fc_price'}
|
||||
= Article.human_attribute_name(:fc_price)
|
||||
.controls.control-text#article_fc_price
|
||||
= number_to_currency(f.object.fc_price) rescue nil
|
||||
|
||||
-# do this inline, since it's being used in ajax forms only
|
||||
- field = f.object.class.model_name.underscore
|
||||
:javascript
|
||||
var form = $('#article_fc_price').closest('form');
|
||||
$('##{field}_price, ##{field}_tax, ##{field}_deposit', form).on('change keyup', function() {
|
||||
var price = parseFloat($('##{field}_price', form).val());
|
||||
var tax = parseFloat($('##{field}_tax', form).val());
|
||||
var deposit = parseFloat($('##{field}_deposit', form).val());
|
||||
// Article#gross_price and Article#fc_price
|
||||
var gross_price = (price + deposit) * (tax / 100 + 1);
|
||||
var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1);
|
||||
$('#article_fc_price').html($.isNumeric(fc_price) ? I18n.l("currency", fc_price) : '…');
|
||||
});
|
||||
|
||||
6
app/views/shared/_article_fields_units.html.haml
Normal file
6
app/views/shared/_article_fields_units.html.haml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-# use the local 'f', or supply 'f_uq' and 'f_unit' for more control (like in balancing)
|
||||
.fold-line
|
||||
= (f_uq rescue f).input :unit_quantity, label: Article.human_attribute_name(:unit),
|
||||
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit_quantity)}
|
||||
= (f_unit rescue f).input :unit, label: '×'.html_safe,
|
||||
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit)}
|
||||
Loading…
Add table
Add a link
Reference in a new issue