Merge pull request #194 from foodcoop-adam/plugin-move
Better support for plugins (engines) + move wiki to plugin
This commit is contained in:
commit
bb5a67033d
36 changed files with 185 additions and 37 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,130 +0,0 @@
|
|||
# encoding: utf-8
|
||||
class PagesController < ApplicationController
|
||||
|
||||
def index
|
||||
@page = Page.find_by_permalink "Home"
|
||||
|
||||
if @page
|
||||
render :action => 'show'
|
||||
else
|
||||
redirect_to all_pages_path
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
if params[:permalink]
|
||||
@page = Page.find_by_permalink(params[:permalink])
|
||||
elsif params[:id]
|
||||
page = Page.find_by_id(params[:id])
|
||||
if page.nil?
|
||||
flash[:error] = I18n.t('pages.cshow.error_noexist')
|
||||
redirect_to all_pages_path and return
|
||||
else
|
||||
redirect_to wiki_page_path(page.permalink) and return
|
||||
end
|
||||
end
|
||||
|
||||
if @page.nil?
|
||||
redirect_to new_page_path(:title => params[:permalink])
|
||||
elsif @page.redirect?
|
||||
page = Page.find_by_id(@page.redirect)
|
||||
unless page.nil?
|
||||
flash[:notice] = I18n.t('pages.cshow.redirect_notice', :page => @page.title)
|
||||
redirect_to wiki_page_path(page.permalink)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@page = Page.new
|
||||
@page.title = params[:title].gsub("_", " ") if params[:title]
|
||||
@page.parent = Page.find_by_permalink(params[:parent]) if params[:parent]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @page }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@page = Page.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@page = current_user.pages.build(params[:page])
|
||||
|
||||
if params[:preview]
|
||||
render :action => 'new'
|
||||
else
|
||||
if @page.save
|
||||
flash[:notice] = I18n.t('pages.create.notice')
|
||||
redirect_to(wiki_page_path(@page.permalink))
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@page = Page.find(params[:id])
|
||||
@page.attributes = params[:page].merge({:user => current_user})
|
||||
|
||||
if params[:preview]
|
||||
@page.attributes = params[:page]
|
||||
render :action => 'edit'
|
||||
else
|
||||
if @page.save
|
||||
@page.parent_id = parent_id if (!params[:parent_id].blank? \
|
||||
and params[:parent_id] != @page_id)
|
||||
flash[:notice] = I18n.t('pages.update.notice')
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
flash[:error] = I18n.t('pages.error_stale_object')
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@page = Page.find(params[:id])
|
||||
@page.destroy
|
||||
|
||||
flash[:notice] = I18n.t('pages.destroy.notice', :page => @page.title)
|
||||
redirect_to wiki_path
|
||||
end
|
||||
|
||||
def all
|
||||
@pages = Page.non_redirected
|
||||
@partial = params[:view] || 'recent_changes'
|
||||
|
||||
if params[:name]
|
||||
@pages = @pages.where("title LIKE ?", "%#{params[:name]}%").limit(20).order('updated_at DESC')
|
||||
@partial = 'title_list'
|
||||
else
|
||||
order = case @partial
|
||||
when 'recent_changes' then
|
||||
'updated_at DESC'
|
||||
when 'site_map' then
|
||||
'created_at DESC'
|
||||
when 'title_list' then
|
||||
'title DESC'
|
||||
end
|
||||
@pages.order(order)
|
||||
end
|
||||
end
|
||||
|
||||
def version
|
||||
@page = Page.find(params[:id])
|
||||
@version = Page::Version.find_by_page_id_and_lock_version params[:id], params[:version]
|
||||
end
|
||||
|
||||
def revert
|
||||
@page = Page.find(params[:id])
|
||||
@page.revert_to!(params[:version].to_i)
|
||||
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue