fix and cleanup routing (closes foodcoops#190)
This commit is contained in:
parent
70c12b7c1f
commit
de948d7692
9 changed files with 21 additions and 18 deletions
|
@ -48,6 +48,9 @@ class OrdersController < ApplicationController
|
|||
end
|
||||
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
|
||||
end
|
||||
format.text do
|
||||
send_data text_fax_template, filename: @order.name+'.txt', type: 'text/plain'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -101,12 +104,14 @@ class OrdersController < ApplicationController
|
|||
rescue => error
|
||||
redirect_to orders_url, alert: I18n.t('errors.general_msg', :msg => error.message)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Renders the fax-text-file
|
||||
# e.g. for easier use with online-fax-software, which don't accept pdf-files
|
||||
# TODO move to text template
|
||||
def text_fax_template
|
||||
order = Order.find(params[:id])
|
||||
supplier = order.supplier
|
||||
supplier = @order.supplier
|
||||
contact = FoodsoftConfig[:contact].symbolize_keys
|
||||
text = I18n.t('orders.fax.heading', :name => FoodsoftConfig[:name])
|
||||
text += "\n#{Supplier.human_attribute_name(:customer_number)}: #{supplier.customer_number}" unless supplier.customer_number.blank?
|
||||
|
@ -117,15 +122,13 @@ class OrdersController < ApplicationController
|
|||
text += "****** " + I18n.t('orders.fax.articles') + "\n\n"
|
||||
text += I18n.t('orders.fax.number') + " " + I18n.t('orders.fax.amount') + " " + I18n.t('orders.fax.name') + "\n"
|
||||
# now display all ordered articles
|
||||
order.order_articles.ordered.all(:include => [:article, :article_price]).each do |oa|
|
||||
@order.order_articles.ordered.all(:include => [:article, :article_price]).each do |oa|
|
||||
number = oa.article.order_number
|
||||
(8 - number.size).times { number += " " }
|
||||
quantity = oa.units_to_order.to_i.to_s
|
||||
quantity = " " + quantity if quantity.size < 2
|
||||
text += "#{number} #{quantity} #{oa.article.name}\n"
|
||||
end
|
||||
send_data text,
|
||||
:type => 'text/plain; charset=utf-8; header=present',
|
||||
:disposition => "attachment; filename=#{order.name}"
|
||||
text
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%tr.edit_inline{:id=> "edit_"+@article.id.to_s}
|
||||
%td{:colspan=>"10"}
|
||||
= t('.note', article: h(@article.name), drop_link: link_to(t('.drop'), :controller => 'orders', :action => 'edit', :id => @order)).html_safe
|
||||
= t('.note', article: h(@article.name), drop_link: link_to(t('.drop'), edit_order_path(@order))).html_safe
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%li.nav-header= t '.foodcoop'
|
||||
%li= link_to t('.members'), foodcoop_users_path
|
||||
%li= link_to t('.tasks'), user_tasks_path
|
||||
%li= link_to t('.write_message'), :controller => "messages", :action => "new"
|
||||
%li= link_to t('.write_message'), new_message_path
|
||||
|
||||
- has_ordergroup = !@current_user.ordergroup.nil?
|
||||
- has_orders_role = @current_user.role_orders?
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%h3
|
||||
= h(t('.user.title', user: @current_user.nick))
|
||||
%small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on)
|
||||
= simple_form_for(@current_user, :url => { :action => 'update_profile'}) do |f|
|
||||
= simple_form_for(@current_user, :url => update_profile_path) do |f|
|
||||
= render :partial => 'shared/user_form_fields', :locals => {:f => f}
|
||||
.form-actions
|
||||
= submit_tag t('ui.save'), class: 'btn'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
- title t('.title')
|
||||
= t('.body').html_safe
|
||||
= simple_form_for User.new, url: {action: 'reset_password'} do |form|
|
||||
= simple_form_for User.new, url: reset_password_path do |form|
|
||||
= form.input :email
|
||||
.form-actions
|
||||
= form.submit t('.submit'), class: 'btn'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
- title t('.title')
|
||||
= t('.body', user: h(@user.nick)).html_safe
|
||||
= simple_form_for @user, :url => {:action => 'update_password', :id => @user.id, :token => @user.reset_password_token} do |form|
|
||||
= simple_form_for @user, :url => update_password_path(@user.id, :token => @user.reset_password_token) do |form|
|
||||
= form.input :password
|
||||
= form.input :password_confirmation
|
||||
.form-actions
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
%li= order_pdf(@order, :articles, t('.download.article_pdf'))
|
||||
%li= order_pdf(@order, :matrix, t('.download.matrix_pdf'))
|
||||
%li= order_pdf(@order, :fax, t('.download.fax_pdf'))
|
||||
%li= link_to t('.download.fax_txt'), {action: 'text_fax_template', id: @order }, {title: t('.download.download_file')}
|
||||
%li= link_to t('.download.fax_txt'), order_path(@order, format: :txt), {title: t('.download.download_file')}
|
||||
|
||||
%section#articles_table
|
||||
= render 'articles', order: @order
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
- @tasks.each do |task|
|
||||
%tr
|
||||
%td= task.due_date unless task.due_date.nil?
|
||||
%td= link_to t('.task_format', name: task.name, duration: task.duration), :controller => "tasks", :action => "show", :id => task
|
||||
%td= link_to t('.task_format', name: task.name, duration: task.duration), task_path(task)
|
||||
%td= task_assignments task
|
||||
|
|
|
@ -18,14 +18,17 @@ Foodsoft::Application.routes.draw do
|
|||
|
||||
match '/login' => 'sessions#new', :as => 'login'
|
||||
match '/logout' => 'sessions#destroy', :as => 'logout'
|
||||
get '/login/forgot_password' => 'login#forgot_password', as: :forgot_password
|
||||
get '/login/new_password' => 'login#new_password', as: :new_password
|
||||
get '/login/forgot_password' => 'login#forgot_password', as: :forgot_password
|
||||
post '/login/reset_password' => 'login#reset_password', as: :reset_password
|
||||
get '/login/new_password' => 'login#new_password', as: :new_password
|
||||
get '/login/update_password' => 'login#update_password', as: :update_password
|
||||
match '/login/accept_invitation/:token' => 'login#accept_invitation', as: :accept_invitation
|
||||
resources :sessions, :only => [:new, :create, :destroy]
|
||||
|
||||
########### User specific
|
||||
|
||||
match '/home/profile' => 'home#profile', :as => 'my_profile'
|
||||
put '/home/update_profile' => 'home#update_profile', :as => 'update_profile'
|
||||
match '/home/ordergroup' => 'home#ordergroup', :as => 'my_ordergroup'
|
||||
match '/home/cancel_membership' => 'home#cancel_membership', :as => 'cancel_membership'
|
||||
|
||||
|
@ -181,8 +184,5 @@ Foodsoft::Application.routes.draw do
|
|||
|
||||
resources :users, :only => [:index]
|
||||
|
||||
# TODO: This is very error prone. Better deactivate this catch all route
|
||||
match ':controller(/:action(/:id))(.:format)'
|
||||
|
||||
end # End of /:foodcoop scope
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue