From baa5f16cfcf59b27b0f0c4e23eb7dc3b5366e5b6 Mon Sep 17 00:00:00 2001 From: Julius Date: Tue, 31 Dec 2013 11:41:14 +0100 Subject: [PATCH] Free order_article resource from finance namespace; also unlock for role_orders --- app/controllers/application_controller.rb | 5 +++++ .../{finance => }/order_articles_controller.rb | 4 ++-- app/helpers/{finance => }/order_articles_helper.rb | 2 +- .../balancing/_edit_results_by_articles.html.haml | 2 +- app/views/finance/balancing/_order_article.html.haml | 4 ++-- .../{finance => }/order_articles/_edit.html.haml | 2 +- .../{finance => }/order_articles/_new.html.haml | 2 +- .../{finance => }/order_articles/create.js.haml | 0 .../{finance => }/order_articles/destroy.js.haml | 0 app/views/{finance => }/order_articles/edit.js.haml | 0 app/views/{finance => }/order_articles/new.js.haml | 0 app/views/{finance => }/order_articles/update.js.erb | 0 app/views/orders/_edit_amount.html.haml | 2 +- config/locales/de.yml | 12 ++++++------ config/locales/en.yml | 12 ++++++------ config/locales/fr.yml | 12 ++++++------ config/locales/nl.yml | 12 ++++++------ config/routes.rb | 4 ++-- 18 files changed, 40 insertions(+), 35 deletions(-) rename app/controllers/{finance => }/order_articles_controller.rb (94%) rename app/helpers/{finance => }/order_articles_helper.rb (84%) rename app/views/{finance => }/order_articles/_edit.html.haml (93%) rename app/views/{finance => }/order_articles/_new.html.haml (84%) rename app/views/{finance => }/order_articles/create.js.haml (100%) rename app/views/{finance => }/order_articles/destroy.js.haml (100%) rename app/views/{finance => }/order_articles/edit.js.haml (100%) rename app/views/{finance => }/order_articles/new.js.haml (100%) rename app/views/{finance => }/order_articles/update.js.erb (100%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dcc0f298..44c9b7e2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,6 +47,7 @@ class ApplicationController < ActionController::Base when "article_meta" then current_user.role_article_meta? when "suppliers" then current_user.role_suppliers? when "orders" then current_user.role_orders? + when "finance_or_orders" then (current_user.role_finance? || current_user.role_orders?) when "any" then true # no role required else false # any unknown role will always fail end @@ -78,6 +79,10 @@ class ApplicationController < ActionController::Base authenticate('orders') end + def authenticate_finance_or_orders + authenticate('finance_or_orders') + end + # checks if the current_user is member of given group. # if fails the user will redirected to startpage def authenticate_membership_or_admin(group_id = params[:id]) diff --git a/app/controllers/finance/order_articles_controller.rb b/app/controllers/order_articles_controller.rb similarity index 94% rename from app/controllers/finance/order_articles_controller.rb rename to app/controllers/order_articles_controller.rb index cc3351b0..6ce0ebda 100644 --- a/app/controllers/finance/order_articles_controller.rb +++ b/app/controllers/order_articles_controller.rb @@ -1,6 +1,6 @@ -class Finance::OrderArticlesController < ApplicationController +class OrderArticlesController < ApplicationController - before_filter :authenticate_finance + before_filter :authenticate_finance_or_orders layout false # We only use this controller to serve js snippets, no need for layout rendering diff --git a/app/helpers/finance/order_articles_helper.rb b/app/helpers/order_articles_helper.rb similarity index 84% rename from app/helpers/finance/order_articles_helper.rb rename to app/helpers/order_articles_helper.rb index 0ebbc835..4a83d330 100644 --- a/app/helpers/finance/order_articles_helper.rb +++ b/app/helpers/order_articles_helper.rb @@ -1,4 +1,4 @@ -module Finance::OrderArticlesHelper +module OrderArticlesHelper def new_order_articles_collection if @order.stockit? diff --git a/app/views/finance/balancing/_edit_results_by_articles.html.haml b/app/views/finance/balancing/_edit_results_by_articles.html.haml index ab77723e..55dbe212 100644 --- a/app/views/finance/balancing/_edit_results_by_articles.html.haml +++ b/app/views/finance/balancing/_edit_results_by_articles.html.haml @@ -10,7 +10,7 @@ %th= heading_helper Article, :tax %th= heading_helper Article, :deposit %th{:colspan => "2"} - = link_to t('.add_article'), new_finance_order_order_article_path(@order), remote: true, + = link_to t('.add_article'), new_order_order_article_path(@order), remote: true, class: 'btn btn-small' %tbody#result_table - for order_article in @articles diff --git a/app/views/finance/balancing/_order_article.html.haml b/app/views/finance/balancing/_order_article.html.haml index 1e54e18d..88cc55fc 100644 --- a/app/views/finance/balancing/_order_article.html.haml +++ b/app/views/finance/balancing/_order_article.html.haml @@ -20,8 +20,8 @@ %td #{order_article.price.tax}% %td= order_article.price.deposit %td - = link_to t('ui.edit'), edit_finance_order_order_article_path(order_article.order, order_article), remote: true, + = link_to t('ui.edit'), edit_order_order_article_path(order_article.order, order_article), remote: true, class: 'btn btn-mini' %td - = link_to t('ui.delete'), finance_order_order_article_path(order_article.order, order_article), method: :delete, + = link_to t('ui.delete'), order_order_article_path(order_article.order, order_article), method: :delete, remote: true, confirm: t('.confirm'), class: 'btn btn-danger btn-mini' diff --git a/app/views/finance/order_articles/_edit.html.haml b/app/views/order_articles/_edit.html.haml similarity index 93% rename from app/views/finance/order_articles/_edit.html.haml rename to app/views/order_articles/_edit.html.haml index 5501575a..8167f08b 100644 --- a/app/views/finance/order_articles/_edit.html.haml +++ b/app/views/order_articles/_edit.html.haml @@ -1,4 +1,4 @@ -= simple_form_for [:finance, @order, @order_article], remote: true do |form| += simple_form_for [@order, @order_article], remote: true do |form| .modal-header = link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'} %h3= t '.title' diff --git a/app/views/finance/order_articles/_new.html.haml b/app/views/order_articles/_new.html.haml similarity index 84% rename from app/views/finance/order_articles/_new.html.haml rename to app/views/order_articles/_new.html.haml index 41619e6e..dd6c8237 100644 --- a/app/views/finance/order_articles/_new.html.haml +++ b/app/views/order_articles/_new.html.haml @@ -1,4 +1,4 @@ -= simple_form_for [:finance, @order, @order_article], remote: true do |form| += simple_form_for [@order, @order_article], remote: true do |form| .modal-header = link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'} %h3= t '.title' diff --git a/app/views/finance/order_articles/create.js.haml b/app/views/order_articles/create.js.haml similarity index 100% rename from app/views/finance/order_articles/create.js.haml rename to app/views/order_articles/create.js.haml diff --git a/app/views/finance/order_articles/destroy.js.haml b/app/views/order_articles/destroy.js.haml similarity index 100% rename from app/views/finance/order_articles/destroy.js.haml rename to app/views/order_articles/destroy.js.haml diff --git a/app/views/finance/order_articles/edit.js.haml b/app/views/order_articles/edit.js.haml similarity index 100% rename from app/views/finance/order_articles/edit.js.haml rename to app/views/order_articles/edit.js.haml diff --git a/app/views/finance/order_articles/new.js.haml b/app/views/order_articles/new.js.haml similarity index 100% rename from app/views/finance/order_articles/new.js.haml rename to app/views/order_articles/new.js.haml diff --git a/app/views/finance/order_articles/update.js.erb b/app/views/order_articles/update.js.erb similarity index 100% rename from app/views/finance/order_articles/update.js.erb rename to app/views/order_articles/update.js.erb diff --git a/app/views/orders/_edit_amount.html.haml b/app/views/orders/_edit_amount.html.haml index 72277c08..cbca8838 100644 --- a/app/views/orders/_edit_amount.html.haml +++ b/app/views/orders/_edit_amount.html.haml @@ -25,4 +25,4 @@ %td.article_price_price= number_to_currency order_article.article_price.price %td.units_delta %td - = link_to t('ui.edit'), edit_finance_order_order_article_path(order_article.order, order_article), remote: true, class: 'btn btn-mini' + = link_to t('ui.edit'), edit_order_order_article_path(order_article.order, order_article), remote: true, class: 'btn btn-mini' diff --git a/config/locales/de.yml b/config/locales/de.yml index 112e6f7a..29765905 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -611,12 +611,6 @@ de: show: back: Züruck title: Rechnung %{number} - order_articles: - edit: - stock_alert: Preise von Lagerartikeln können nicht geändert werden! - title: Artikel aktualisieren - new: - title: Neuer gelieferter Artikel die Bestellung ordergroups: index: new_transaction: Neue Überweisungen eingeben @@ -1083,6 +1077,12 @@ de: model: error_single_group: ! '%{user} ist schon in einer anderen Bestellgruppe' invalid_balance: ist keine gültige Zahl + order_articles: + edit: + stock_alert: Preise von Lagerartikeln können nicht geändert werden! + title: Artikel aktualisieren + new: + title: Neuer gelieferter Artikel der Bestellung orders: articles: article_count: ! 'Bestellte Artikel:' diff --git a/config/locales/en.yml b/config/locales/en.yml index 230aab46..27b62ded 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -615,12 +615,6 @@ en: show: back: Back title: Invoice %{number} - order_articles: - edit: - stock_alert: The price of stock articles cannot be changed! - title: Update article - new: - title: Add delivered article to order ordergroups: index: new_transaction: Add new transactions @@ -1087,6 +1081,12 @@ en: model: error_single_group: ! '%{user} is already a member of another ordergroup' invalid_balance: is not a valid number + order_articles: + edit: + stock_alert: The price of stock articles cannot be changed! + title: Update article + new: + title: Add delivered article to order orders: add_article: title: Add article diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e73a720b..1d188530 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -625,12 +625,6 @@ fr: show: back: Retour title: Facture %{number} - order_articles: - edit: - stock_alert: - title: Mettre à jour la liste des article - new: - title: ordergroups: index: new_transaction: Saisir une nouvelle transaction @@ -1092,6 +1086,12 @@ fr: model: error_single_group: ! '%{user} fait déjà partie d''une autre cellule' invalid_balance: n'est pas un nombre valide + order_articles: + edit: + stock_alert: + title: Mettre à jour la liste des article + new: + title: orders: articles: article_count: ! 'Articles commandés:' diff --git a/config/locales/nl.yml b/config/locales/nl.yml index e11dfebc..8c6299bb 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -615,12 +615,6 @@ nl: show: back: Terug title: Factuur %{number} - order_articles: - edit: - stock_alert: De prijs van voorraadartikelen kan niet aangepast worden! - title: Artikel bijwerken - new: - title: Geleverd artikel aan bestelling toevoegen ordergroups: index: new_transaction: Nieuwe transacties toevoegen @@ -1067,6 +1061,12 @@ nl: model: error_single_group: ! '%{user} behoort al tot een ander huishouden' invalid_balance: is geen geldig nummer + order_articles: + edit: + stock_alert: De prijs van voorraadartikelen kan niet aangepast worden! + title: Artikel bijwerken + new: + title: Geleverd artikel aan bestelling toevoegen orders: articles: article_count: ! 'Bestelde artikelen:' diff --git a/config/routes.rb b/config/routes.rb index 18d955a1..46b4a12b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -45,6 +45,8 @@ Foodsoft::Application.routes.draw do get :receive_on_order_article_update end + + resources :order_articles end resources :group_orders do @@ -150,8 +152,6 @@ Foodsoft::Application.routes.draw do get :new_on_order_article_update end - - resources :order_articles end resources :group_order_articles do