Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -1,6 +1,4 @@
|
|||
# encoding: utf-8
|
||||
class CurrentOrders::ArticlesController < ApplicationController
|
||||
|
||||
before_action :authenticate_orders
|
||||
before_action :find_order_and_order_article, only: [:index, :show]
|
||||
|
||||
|
|
@ -21,7 +19,7 @@ class CurrentOrders::ArticlesController < ApplicationController
|
|||
end
|
||||
|
||||
def show_on_group_order_article_update
|
||||
#@goa = GroupOrderArticle.find(params[:group_order_article_id])
|
||||
# @goa = GroupOrderArticle.find(params[:group_order_article_id])
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
@ -40,7 +38,7 @@ class CurrentOrders::ArticlesController < ApplicationController
|
|||
end
|
||||
|
||||
helper_method \
|
||||
def ordergroups_for_adding
|
||||
def ordergroups_for_adding
|
||||
Ordergroup.undeleted.order(:name)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ class CurrentOrders::GroupOrdersController < ApplicationController
|
|||
def index
|
||||
# XXX code duplication lib/foodsoft_current_orders/app/controllers/current_orders/ordergroups_controller.rb
|
||||
@order_ids = Order.where(state: ['open', 'finished']).all.map(&:id)
|
||||
@goas = GroupOrderArticle.includes(:group_order => :ordergroup).includes(:order_article).
|
||||
where(group_orders: {order_id: @order_ids, ordergroup_id: @ordergroup.id}).ordered
|
||||
@articles_grouped_by_category = @goas.includes(:order_article => {:article => :article_category}).
|
||||
order('articles.name').
|
||||
group_by { |a| a.order_article.article.article_category.name }.
|
||||
sort { |a, b| a[0] <=> b[0] }
|
||||
@goas = GroupOrderArticle.includes(:group_order => :ordergroup).includes(:order_article)
|
||||
.where(group_orders: { order_id: @order_ids, ordergroup_id: @ordergroup.id }).ordered
|
||||
@articles_grouped_by_category = @goas.includes(:order_article => { :article => :article_category })
|
||||
.order('articles.name')
|
||||
.group_by { |a| a.order_article.article.article_category.name }
|
||||
.sort { |a, b| a[0] <=> b[0] }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -22,5 +22,4 @@ class CurrentOrders::GroupOrdersController < ApplicationController
|
|||
redirect_to root_url, :alert => I18n.t('group_orders.errors.no_member')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
# encoding: utf-8
|
||||
class CurrentOrders::OrdergroupsController < ApplicationController
|
||||
|
||||
before_action :authenticate_orders
|
||||
before_action :find_group_orders, only: [:index, :show]
|
||||
|
||||
|
|
@ -21,7 +19,7 @@ class CurrentOrders::OrdergroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def show_on_group_order_article_update
|
||||
#@goa = GroupOrderArticle.find(params[:group_order_article_id])
|
||||
# @goa = GroupOrderArticle.find(params[:group_order_article_id])
|
||||
@group_order = GroupOrder.find(params[:group_order_id])
|
||||
@ordergroup = @group_order.ordergroup
|
||||
end
|
||||
|
|
@ -33,15 +31,15 @@ class CurrentOrders::OrdergroupsController < ApplicationController
|
|||
|
||||
@all_ordergroups = Ordergroup.undeleted.order(:name).to_a
|
||||
@ordered_group_ids = GroupOrder.where(order_id: @order_ids).pluck('DISTINCT(ordergroup_id)')
|
||||
@all_ordergroups.sort_by! {|o| @ordered_group_ids.include?(o.id) ? o.name : "ZZZZZ#{o.name}" }
|
||||
@all_ordergroups.sort_by! { |o| @ordered_group_ids.include?(o.id) ? o.name : "ZZZZZ#{o.name}" }
|
||||
|
||||
@ordergroup = Ordergroup.find(params[:id]) unless params[:id].nil?
|
||||
@goas = GroupOrderArticle.includes(:group_order, :order_article => [:article, :article_price]).
|
||||
where(group_orders: {order_id: @order_ids, ordergroup_id: @ordergroup.id}).ordered.all unless @ordergroup.nil?
|
||||
@goas = GroupOrderArticle.includes(:group_order, :order_article => [:article, :article_price])
|
||||
.where(group_orders: { order_id: @order_ids, ordergroup_id: @ordergroup.id }).ordered.all unless @ordergroup.nil?
|
||||
end
|
||||
|
||||
helper_method \
|
||||
def articles_for_adding
|
||||
def articles_for_adding
|
||||
OrderArticle.includes(:article, :article_price).where(order_id: @order_ids)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class CurrentOrders::OrdersController < ApplicationController
|
||||
|
||||
before_action :authenticate_orders, except: :my
|
||||
|
||||
def show
|
||||
|
|
@ -14,8 +13,8 @@ class CurrentOrders::OrdersController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.pdf do
|
||||
pdf = case params[:document]
|
||||
when 'groups' then MultipleOrdersByGroups.new(@order_ids, @doc_options)
|
||||
when 'articles' then MultipleOrdersByArticles.new(@order_ids, @doc_options)
|
||||
when 'groups' then MultipleOrdersByGroups.new(@order_ids, @doc_options)
|
||||
when 'articles' then MultipleOrdersByArticles.new(@order_ids, @doc_options)
|
||||
end
|
||||
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
|
||||
end
|
||||
|
|
@ -36,5 +35,4 @@ class CurrentOrders::OrdersController < ApplicationController
|
|||
def receive
|
||||
@orders = Order.finished_not_closed.includes(:supplier)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class CurrentOrdersController < ApplicationController
|
||||
|
||||
before_action :authenticate_orders
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class MultipleOrdersByArticles < OrderPdf
|
||||
include OrdersHelper
|
||||
|
||||
|
|
@ -32,28 +31,29 @@ class MultipleOrdersByArticles < OrderPdf
|
|||
dimrows << rows.length if goa.result == 0
|
||||
end
|
||||
next if rows.length == 0
|
||||
|
||||
sum = order_article.group_orders_sum
|
||||
rows.unshift I18n.t('documents.order_by_articles.rows').dup # table header
|
||||
|
||||
rows << [I18n.t('documents.order_by_groups.sum'),
|
||||
order_article.tolerance > 0 ? "#{order_article.quantity} + #{order_article.tolerance}" : order_article.quantity,
|
||||
sum[:quantity],
|
||||
nil] #number_to_currency(sum[:price])]
|
||||
nil] # number_to_currency(sum[:price])]
|
||||
|
||||
text "<b>#{order_article.article.name}</b> " +
|
||||
"(#{order_article.article.unit}; #{number_to_currency order_article.price.fc_price}; " +
|
||||
units_history_line(order_article, plain: true) + ')',
|
||||
size: fontsize(10), inline_format: true
|
||||
table rows, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table|
|
||||
table rows, cell_style: { size: fontsize(8), overflow: :shrink_to_fit } do |table|
|
||||
# borders
|
||||
table.cells.borders = [:bottom]
|
||||
table.cells.border_width = 0.02
|
||||
table.cells.border_color = 'dddddd'
|
||||
table.rows(0).border_width = 1
|
||||
table.rows(0).border_color = '666666'
|
||||
table.row(rows.length-2).border_width = 1
|
||||
table.row(rows.length-2).border_color = '666666'
|
||||
table.row(rows.length-1).borders = []
|
||||
table.row(rows.length - 2).border_width = 1
|
||||
table.row(rows.length - 2).border_color = '666666'
|
||||
table.row(rows.length - 1).borders = []
|
||||
|
||||
table.column(0).width = 200
|
||||
table.columns(1..2).align = :center
|
||||
|
|
@ -73,25 +73,24 @@ class MultipleOrdersByArticles < OrderPdf
|
|||
end
|
||||
|
||||
def order_articles
|
||||
OrderArticle.where(order_id: order).ordered.
|
||||
includes(:article).references(:article).
|
||||
reorder('order_articles.order_id, articles.name').
|
||||
preload(:article_price). # preload not join, just in case it went missing
|
||||
preload(:order, :group_order_articles => {:group_order => :ordergroup})
|
||||
OrderArticle.where(order_id: order).ordered
|
||||
.includes(:article).references(:article)
|
||||
.reorder('order_articles.order_id, articles.name')
|
||||
.preload(:article_price) # preload not join, just in case it went missing
|
||||
.preload(:order, :group_order_articles => { :group_order => :ordergroup })
|
||||
end
|
||||
|
||||
def each_order_article
|
||||
order_articles.find_each_with_order(batch_size: BATCH_SIZE) {|oa| yield oa }
|
||||
order_articles.find_each_with_order(batch_size: BATCH_SIZE) { |oa| yield oa }
|
||||
end
|
||||
|
||||
def group_order_articles_for(order_article)
|
||||
goas = order_article.group_order_articles.to_a
|
||||
goas.sort_by! {|goa| goa.group_order.ordergroup_name }
|
||||
goas.sort_by! { |goa| goa.group_order.ordergroup_name }
|
||||
goas
|
||||
end
|
||||
|
||||
def each_group_order_article_for(group_order)
|
||||
group_order_articles_for(group_order).each {|goa| yield goa }
|
||||
group_order_articles_for(group_order).each { |goa| yield goa }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class MultipleOrdersByGroups < OrderPdf
|
||||
include OrdersHelper
|
||||
|
||||
|
|
@ -23,12 +22,12 @@ class MultipleOrdersByGroups < OrderPdf
|
|||
down_or_page 15
|
||||
|
||||
total = 0
|
||||
taxes = Hash.new {0}
|
||||
taxes = Hash.new { 0 }
|
||||
rows = []
|
||||
dimrows = []
|
||||
has_tolerance = false
|
||||
|
||||
each_group_order_article_for(ordergroup) do |goa|
|
||||
each_group_order_article_for(ordergroup) do |goa|
|
||||
has_tolerance = true if goa.order_article.price.unit_quantity > 1
|
||||
price = goa.order_article.price.fc_price
|
||||
sub_total = goa.total_price
|
||||
|
|
@ -46,7 +45,7 @@ class MultipleOrdersByGroups < OrderPdf
|
|||
next if rows.length == 0
|
||||
|
||||
# total
|
||||
rows << [{content: I18n.t('documents.order_by_groups.sum'), colspan: 6}, number_to_currency(total), nil]
|
||||
rows << [{ content: I18n.t('documents.order_by_groups.sum'), colspan: 6 }, number_to_currency(total), nil]
|
||||
|
||||
# table header
|
||||
rows.unshift [
|
||||
|
|
@ -57,14 +56,14 @@ class MultipleOrdersByGroups < OrderPdf
|
|||
I18n.t('shared.articles.ordered'),
|
||||
I18n.t('shared.articles.received'),
|
||||
I18n.t('shared.articles_by.price_sum'),
|
||||
{image: "#{Rails.root}/app/assets/images/package-bg.png", scale: 0.6, position: :center}
|
||||
{ image: "#{Rails.root}/app/assets/images/package-bg.png", scale: 0.6, position: :center }
|
||||
]
|
||||
|
||||
# last column showing unit_quantity is useless if they're all one
|
||||
rows.each {|row| row[-1] = nil} unless has_tolerance
|
||||
rows.each { |row| row[-1] = nil } unless has_tolerance
|
||||
|
||||
text ordergroup.name, size: fontsize(13), style: :bold
|
||||
table rows, width: bounds.width, cell_style: {size: fontsize(8), overflow: :shrink_to_fit} do |table|
|
||||
table rows, width: bounds.width, cell_style: { size: fontsize(8), overflow: :shrink_to_fit } do |table|
|
||||
# borders
|
||||
table.cells.borders = [:bottom]
|
||||
table.cells.border_width = 0.02
|
||||
|
|
@ -72,9 +71,9 @@ class MultipleOrdersByGroups < OrderPdf
|
|||
table.rows(0).border_width = 1
|
||||
table.rows(0).border_color = '666666'
|
||||
table.rows(0).column(5).font_style = :bold
|
||||
table.row(rows.length-2).border_width = 1
|
||||
table.row(rows.length-2).border_color = '666666'
|
||||
table.row(rows.length-1).borders = []
|
||||
table.row(rows.length - 2).border_width = 1
|
||||
table.row(rows.length - 2).border_color = '666666'
|
||||
table.row(rows.length - 1).borders = []
|
||||
|
||||
table.column(0).width = 180 # @todo would like to set minimum width here
|
||||
table.column(1).width = 62
|
||||
|
|
@ -105,34 +104,33 @@ class MultipleOrdersByGroups < OrderPdf
|
|||
end
|
||||
|
||||
def ordergroups
|
||||
s = Ordergroup.
|
||||
includes(:group_orders).
|
||||
where(group_orders: {order_id: order}).
|
||||
group(:id).
|
||||
reorder(:name)
|
||||
s = Ordergroup
|
||||
.includes(:group_orders)
|
||||
.where(group_orders: { order_id: order })
|
||||
.group(:id)
|
||||
.reorder(:name)
|
||||
s = s.where(id: @options[:ordergroup]) if @options[:ordergroup]
|
||||
s
|
||||
end
|
||||
|
||||
def each_ordergroup
|
||||
ordergroups.find_in_batches_with_order(batch_size: BATCH_SIZE) do |ordergroups|
|
||||
@group_order_article_batch = GroupOrderArticle.
|
||||
joins(:group_order).
|
||||
where(group_orders: {order_id: order}).
|
||||
where(group_orders: {ordergroup_id: ordergroups.map(&:id)}).
|
||||
order('group_orders.order_id, group_order_articles.id').
|
||||
preload(group_orders: {order: :supplier}).
|
||||
preload(order_article: [:article, :article_price, :order])
|
||||
ordergroups.each {|ordergroup| yield ordergroup }
|
||||
@group_order_article_batch = GroupOrderArticle
|
||||
.joins(:group_order)
|
||||
.where(group_orders: { order_id: order })
|
||||
.where(group_orders: { ordergroup_id: ordergroups.map(&:id) })
|
||||
.order('group_orders.order_id, group_order_articles.id')
|
||||
.preload(group_orders: { order: :supplier })
|
||||
.preload(order_article: [:article, :article_price, :order])
|
||||
ordergroups.each { |ordergroup| yield ordergroup }
|
||||
end
|
||||
end
|
||||
|
||||
def group_order_articles_for(ordergroup)
|
||||
@group_order_article_batch.select {|goa| goa.group_order.ordergroup_id == ordergroup.id }
|
||||
@group_order_article_batch.select { |goa| goa.group_order.ordergroup_id == ordergroup.id }
|
||||
end
|
||||
|
||||
def each_group_order_article_for(ordergroup)
|
||||
group_order_articles_for(ordergroup).each {|goa| yield goa }
|
||||
group_order_articles_for(ordergroup).each { |goa| yield goa }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module CurrentOrdersHelper
|
||||
|
||||
def to_pay_message(ordergroup)
|
||||
funds = ordergroup.get_available_funds
|
||||
if funds > 0
|
||||
|
|
@ -10,5 +9,4 @@ module CurrentOrdersHelper
|
|||
content_tag :b, I18n.t('helpers.current_orders.pay_amount', amount: number_to_currency(-ordergroup.get_available_funds))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@ module FoodsoftCurrentOrders
|
|||
def navigation(primary, context)
|
||||
return unless FoodsoftCurrentOrders.enabled?
|
||||
return if primary[:orders].nil?
|
||||
|
||||
cond = Proc.new { current_user.role_orders? }
|
||||
[
|
||||
SimpleNavigation::Item.new(primary, :stage_divider, nil, nil, class: 'divider', if: cond),
|
||||
SimpleNavigation::Item.new(primary, :current_orders_receive, I18n.t('current_orders.navigation.receive'), context.receive_current_orders_orders_path, if: cond),
|
||||
SimpleNavigation::Item.new(primary, :current_orders_articles, I18n.t('current_orders.navigation.articles'), context.current_orders_articles_path, if: cond),
|
||||
SimpleNavigation::Item.new(primary, :current_orders_ordergroups, I18n.t('current_orders.navigation.ordergroups'), context.current_orders_ordergroups_path, if: cond)
|
||||
].each {|i| primary[:orders].sub_navigation.items << i }
|
||||
].each { |i| primary[:orders].sub_navigation.items << i }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
class DiscourseController < ApplicationController
|
||||
|
||||
before_action -> { require_plugin_enabled FoodsoftDiscourse }
|
||||
|
||||
protected
|
||||
|
||||
def valid_signature?
|
||||
return false if params[:sso].blank? || params[:sig].blank?
|
||||
|
||||
get_hmac_hex_string(params[:sso]) == params[:sig]
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class DiscourseLoginController < DiscourseController
|
||||
|
||||
before_action -> { require_config_disabled :discourse_sso }
|
||||
skip_before_action :authenticate
|
||||
|
||||
|
|
@ -11,8 +10,8 @@ class DiscourseLoginController < DiscourseController
|
|||
|
||||
session[:discourse_sso_nonce] = nonce
|
||||
redirect_to_with_payload "#{discourse_url}/session/sso_provider",
|
||||
nonce: nonce,
|
||||
return_sso_url: return_sso_url
|
||||
nonce: nonce,
|
||||
return_sso_url: return_sso_url
|
||||
end
|
||||
|
||||
def callback
|
||||
|
|
@ -21,6 +20,7 @@ class DiscourseLoginController < DiscourseController
|
|||
payload = parse_payload
|
||||
|
||||
raise I18n.t('discourse.callback.invalid_nonce') if payload[:nonce] != session[:discourse_sso_nonce]
|
||||
|
||||
session[:discourse_sso_nonce] = nil
|
||||
|
||||
id = payload[:external_id].to_i
|
||||
|
|
@ -39,5 +39,4 @@ class DiscourseLoginController < DiscourseController
|
|||
rescue => error
|
||||
redirect_to login_url, alert: error.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class DiscourseSsoController < DiscourseController
|
||||
|
||||
before_action -> { require_config_enabled :discourse_sso }
|
||||
|
||||
def sso
|
||||
|
|
@ -12,14 +11,13 @@ class DiscourseSsoController < DiscourseController
|
|||
raise I18n.t('discourse.sso.nonce_missing') if nonce.blank?
|
||||
|
||||
redirect_to_with_payload return_sso_url,
|
||||
nonce: nonce,
|
||||
email: current_user.email,
|
||||
require_activation: true,
|
||||
external_id: "#{FoodsoftConfig.scope}/#{current_user.id}",
|
||||
username: current_user.nick,
|
||||
name: current_user.name
|
||||
nonce: nonce,
|
||||
email: current_user.email,
|
||||
require_activation: true,
|
||||
external_id: "#{FoodsoftConfig.scope}/#{current_user.id}",
|
||||
username: current_user.nick,
|
||||
name: current_user.name
|
||||
rescue => error
|
||||
redirect_to root_url, alert: error.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope '/:foodcoop' do
|
||||
|
||||
get '/discourse/callback' => 'discourse_login#callback'
|
||||
get '/discourse/initiate' => 'discourse_login#initiate'
|
||||
get '/discourse/sso' => 'discourse_sso#sso'
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,23 +1,19 @@
|
|||
module FoodsoftDiscourse
|
||||
|
||||
module RedirectToLogin
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
|
||||
alias foodsoft_discourse_orig_redirect_to_login redirect_to_login
|
||||
|
||||
def redirect_to_login(options={})
|
||||
def redirect_to_login(options = {})
|
||||
if FoodsoftDiscourse.enabled? && !FoodsoftConfig[:discourse_sso]
|
||||
redirect_to discourse_initiate_path
|
||||
else
|
||||
foodsoft_discourse_orig_redirect_to_login(options)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# modify existing helper
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ class DocumentsController < ApplicationController
|
|||
def index
|
||||
if params["sort"]
|
||||
sort = case params["sort"]
|
||||
when "name" then "data IS NULL DESC, name"
|
||||
when "created_at" then "created_at"
|
||||
when "name_reverse" then "data IS NULL, name DESC"
|
||||
when "created_at_reverse" then "created_at DESC"
|
||||
when "name" then "data IS NULL DESC, name"
|
||||
when "created_at" then "created_at"
|
||||
when "name_reverse" then "data IS NULL, name DESC"
|
||||
when "created_at_reverse" then "created_at DESC"
|
||||
end
|
||||
else
|
||||
sort = "data IS NULL DESC, name"
|
||||
|
|
@ -31,6 +31,7 @@ class DocumentsController < ApplicationController
|
|||
@document.data = data.read
|
||||
@document.mime = FileMagic.new(FileMagic::MAGIC_MIME).buffer(@document.data)
|
||||
raise t('.not_allowed_mime', mime: @document.mime) unless allowed_mime? @document.mime
|
||||
|
||||
if @document.name.empty?
|
||||
name = File.basename(data.original_filename)
|
||||
@document.name = name.gsub(/[^\w\.\-]/, '_')
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ class Document < ApplicationRecord
|
|||
|
||||
"#{name}.#{types.first.preferred_extension}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope '/:foodcoop' do
|
||||
|
||||
resources :documents do
|
||||
get :move
|
||||
get :new
|
||||
get :new_folder
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ module FoodsoftDocuments
|
|||
def navigation(primary, context)
|
||||
return unless FoodsoftDocuments.enabled?
|
||||
return if primary[:foodcoop].nil?
|
||||
|
||||
sub_nav = primary[:foodcoop].sub_navigation
|
||||
sub_nav.items <<
|
||||
SimpleNavigation::Item.new(primary, :documents, I18n.t('navigation.documents'), context.documents_path)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope '/:foodcoop' do
|
||||
|
||||
resources :links, only: [:show]
|
||||
|
||||
namespace :admin do
|
||||
resources :links
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module FoodsoftLinks
|
||||
class Engine < ::Rails::Engine
|
||||
def navigation(primary, context)
|
||||
primary.item :links, I18n.t('navigation.links'), '#', if: Proc.new { visble_links(context).any? } do |subnav|
|
||||
primary.item :links, I18n.t('navigation.links'), '#', if: Proc.new { visble_links(context).any? } do |subnav|
|
||||
visble_links(context).each do |link|
|
||||
subnav.item link.id, link.name, context.link_path(link)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class Admin::MessagegroupsController < Admin::BaseController
|
||||
inherit_resources
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class MessageThreadsController < ApplicationController
|
||||
|
||||
before_action -> { require_plugin_enabled FoodsoftMessages }
|
||||
|
||||
def index
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class MessagegroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@messagegroups = Messagegroup.order("name")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class MessagesController < ApplicationController
|
||||
|
||||
before_action -> { require_plugin_enabled FoodsoftMessages }
|
||||
|
||||
# Renders the "inbox" action.
|
||||
|
|
@ -22,7 +21,7 @@ class MessagesController < ApplicationController
|
|||
@message.private = original_message.private
|
||||
@message.subject = I18n.t('messages.model.reply_subject', :subject => original_message.subject)
|
||||
@message.body = I18n.t('messages.model.reply_header', :user => original_message.sender.display, :when => I18n.l(original_message.created_at, :format => :short)) + "\n"
|
||||
original_message.body.each_line{ |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) }
|
||||
original_message.body.each_line { |l| @message.body += I18n.t('messages.model.reply_indent', :line => l) }
|
||||
else
|
||||
redirect_to new_message_url, alert: I18n.t('messages.new.error_private')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ module MessagesHelper
|
|||
link_text = content_tag :i, nil, class: 'icon-envelope'
|
||||
link_text << " #{options[:text]}" if options[:text].present?
|
||||
link_to(link_text.html_safe, new_message_path(message: messages_params), class: 'btn',
|
||||
title: I18n.t('helpers.submit.message.create'))
|
||||
title: I18n.t('helpers.submit.message.create'))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require "email_reply_trimmer"
|
||||
|
||||
class MessagesMailReceiver
|
||||
|
||||
def self.regexp
|
||||
/(?<message_id>\d+)\.(?<user_id>\d+)\.(?<hash>\w+)/
|
||||
end
|
||||
|
|
@ -37,9 +36,9 @@ class MessagesMailReceiver
|
|||
raise BlankBodyException if body.empty?
|
||||
|
||||
message = @user.send_messages.new body: body,
|
||||
group: @message.group,
|
||||
private: @message.private,
|
||||
received_email: data
|
||||
group: @message.group,
|
||||
private: @message.private,
|
||||
received_email: data
|
||||
if @message.reply_to
|
||||
message.reply_to_message = @message.reply_to_message
|
||||
else
|
||||
|
|
@ -73,11 +72,8 @@ class MessagesMailReceiver
|
|||
end
|
||||
|
||||
class BlankBodyException < MidiSmtpServer::SmtpdException
|
||||
|
||||
def initialize(msg = nil)
|
||||
super msg, 541, 'The recipient address rejected your message because of a blank plain body'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ class Message < ApplicationRecord
|
|||
attr_accessor :send_method, :recipient_tokens, :order_id
|
||||
|
||||
scope :threads, -> { where(:reply_to => nil) }
|
||||
scope :thread, -> (id) { where("id = ? OR reply_to = ?", id, id) }
|
||||
scope :readable_for, -> (user) {
|
||||
scope :thread, ->(id) { where("id = ? OR reply_to = ?", id, id) }
|
||||
scope :readable_for, ->(user) {
|
||||
user_id = user.try(&:id)
|
||||
|
||||
joins(:message_recipients)
|
||||
|
|
@ -128,12 +128,13 @@ class Message < ApplicationRecord
|
|||
def can_toggle_private?(user)
|
||||
return true if sender == user
|
||||
return false if private?
|
||||
|
||||
user.role_admin?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_salt
|
||||
self.salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
|
||||
self.salt = [Array.new(6) { rand(256).chr }.join].pack("m").chomp
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
# encoding: utf-8
|
||||
class Messagegroup < Group
|
||||
|
||||
validates_uniqueness_of :name
|
||||
|
||||
protected
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ module FoodsoftMessages
|
|||
class Engine < ::Rails::Engine
|
||||
def navigation(primary, context)
|
||||
return unless FoodsoftMessages.enabled?
|
||||
|
||||
unless primary[:foodcoop].nil?
|
||||
sub_nav = primary[:foodcoop].sub_navigation
|
||||
sub_nav.items <<
|
||||
|
|
|
|||
|
|
@ -1,23 +1,19 @@
|
|||
module FoodsoftMessages
|
||||
|
||||
module UserLink
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
|
||||
# modify user presentation link to writing a message for the user
|
||||
def show_user_link(user=@current_user)
|
||||
def show_user_link(user = @current_user)
|
||||
if user.nil? || !FoodsoftMessages.enabled?
|
||||
show_user user
|
||||
else
|
||||
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
||||
:title => I18n.t('helpers.messages.write_message')
|
||||
:title => I18n.t('helpers.messages.write_message')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# modify existing helper
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ class PollsController < ApplicationController
|
|||
if @poll.one_vote_per_ordergroup
|
||||
ordergroup = current_user.ordergroup
|
||||
return redirect_to polls_path, alert: t('.no_ordergroup') unless ordergroup
|
||||
|
||||
attributes = { ordergroup: ordergroup }
|
||||
else
|
||||
attributes = { user: current_user }
|
||||
|
|
@ -103,8 +104,8 @@ class PollsController < ApplicationController
|
|||
params
|
||||
.require(:poll)
|
||||
.permit(:name, :starts_date_value, :starts_time_value, :ends_date_value,
|
||||
:ends_time_value, :description, :one_vote_per_ordergroup, :voting_method,
|
||||
:multi_select_count, :min_points, :max_points, choices: [],
|
||||
required_ordergroup_custom_fields: [], required_user_custom_fields: [])
|
||||
:ends_time_value, :description, :one_vote_per_ordergroup, :voting_method,
|
||||
:multi_select_count, :min_points, :max_points, choices: [],
|
||||
required_ordergroup_custom_fields: [], required_user_custom_fields: [])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class Poll < ActiveRecord::Base
|
||||
|
||||
# @!attribute required_ordergroup_custom_fields
|
||||
# A list of custom_fileds, which are required to poll.
|
||||
# If the required field on the ordergroup of the user
|
||||
|
|
@ -29,6 +28,7 @@ class Poll < ActiveRecord::Base
|
|||
|
||||
def available_points
|
||||
return 0...0 if min_points.nil? || max_points.nil?
|
||||
|
||||
min_points..max_points
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope '/:foodcoop' do
|
||||
|
||||
resources :polls do
|
||||
member do
|
||||
get :vote
|
||||
post :vote
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ module FoodsoftPolls
|
|||
def navigation(primary, context)
|
||||
return unless FoodsoftPolls.enabled?
|
||||
return if primary[:foodcoop].nil?
|
||||
|
||||
sub_nav = primary[:foodcoop].sub_navigation
|
||||
sub_nav.items <<
|
||||
SimpleNavigation::Item.new(primary, :polls, I18n.t('navigation.polls'), context.polls_path)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class PrinterController < ApplicationController
|
|||
json = JSON.parse data, symbolize_names: true
|
||||
job = PrinterJob.unfinished.find_by_id(json[:id])
|
||||
return unless job
|
||||
|
||||
if json[:state]
|
||||
job.add_update! json[:state], json[:message]
|
||||
end
|
||||
|
|
@ -54,5 +55,4 @@ class PrinterController < ApplicationController
|
|||
return head(:unauthorized) unless bearer_token
|
||||
return head(:forbidden) if bearer_token != FoodsoftConfig[:printer_token]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class PrinterJobsController < ApplicationController
|
|||
PrinterJob.transaction do
|
||||
%w(articles fax groups matrix).each do |document|
|
||||
next unless FoodsoftConfig["printer_print_order_#{document}"]
|
||||
|
||||
job = PrinterJob.create! order: order, document: document, created_by: current_user
|
||||
job.add_update! state
|
||||
count += 1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class PrinterJob < ActiveRecord::Base
|
||||
|
||||
belongs_to :order
|
||||
belongs_to :created_by, class_name: 'User', foreign_key: 'created_by_user_id'
|
||||
belongs_to :finished_by, optional: true, class_name: 'User', foreign_key: 'finished_by_user_id'
|
||||
|
|
@ -7,8 +6,8 @@ class PrinterJob < ActiveRecord::Base
|
|||
|
||||
scope :finished, -> { where.not(finished_at: nil) }
|
||||
scope :unfinished, -> { where(finished_at: nil).order(:id) }
|
||||
scope :pending, -> { unfinished.includes(:order).where.not(orders: {state: 'open'}) }
|
||||
scope :queued, -> { unfinished.includes(:order).where(orders: {state: 'open'}) }
|
||||
scope :pending, -> { unfinished.includes(:order).where.not(orders: { state: 'open' }) }
|
||||
scope :queued, -> { unfinished.includes(:order).where(orders: { state: 'open' }) }
|
||||
|
||||
def last_update_at
|
||||
printer_job_updates.order(:created_at).last.try(&:created_at)
|
||||
|
|
@ -18,14 +17,15 @@ class PrinterJob < ActiveRecord::Base
|
|||
printer_job_updates.order(:created_at).last.try(&:state)
|
||||
end
|
||||
|
||||
def add_update!(state, message=nil)
|
||||
def add_update!(state, message = nil)
|
||||
return unless finished_at.nil?
|
||||
|
||||
PrinterJobUpdate.create! printer_job: self, state: state, message: message
|
||||
end
|
||||
|
||||
def finish!(user=nil)
|
||||
def finish!(user = nil)
|
||||
return unless finished_at.nil?
|
||||
|
||||
update_attributes finished_at: Time.now, finished_by: user
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
class PrinterJobUpdate < ActiveRecord::Base
|
||||
|
||||
belongs_to :printer_job
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ module FoodsoftPrinter
|
|||
class Engine < ::Rails::Engine
|
||||
def navigation(primary, context)
|
||||
return unless FoodsoftPrinter.enabled?
|
||||
|
||||
unless primary[:orders].nil?
|
||||
sub_nav = primary[:orders].sub_navigation
|
||||
sub_nav.items <<
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module FoodsoftPrinter
|
||||
|
||||
module OrderPrinterJobs
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
|
|
@ -22,5 +21,4 @@ module FoodsoftPrinter
|
|||
Order.send :include, self
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ module FoodsoftUservoice
|
|||
js_load = "var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/#{view_context.j api_key}.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s);"
|
||||
|
||||
# configuration
|
||||
sections = FoodsoftConfig[:uservoice].reject {|k,v| k=='api_key'}
|
||||
sections.each_pair do |k,v|
|
||||
sections = FoodsoftConfig[:uservoice].reject { |k, v| k == 'api_key' }
|
||||
sections.each_pair do |k, v|
|
||||
if k == 'identify'
|
||||
v['id'] = current_user.try(:id) if v.include?('id')
|
||||
v['name'] = current_user.try(:display) if v.include?('name')
|
||||
v['email'] = current_user.try(:email) if v.include?('email')
|
||||
v['created_at'] = current_user.try {|u| u.created_on.to_i} if v.include?('created_at')
|
||||
v['created_at'] = current_user.try { |u| u.created_on.to_i } if v.include?('created_at')
|
||||
elsif k == 'set'
|
||||
v['locale'] = I18n.locale
|
||||
end
|
||||
|
|
@ -40,7 +40,7 @@ module FoodsoftUservoice
|
|||
js_load = "$(function() { if(!$('[data-role=page]')[0]){#{js_load}} });"
|
||||
|
||||
# include in layout
|
||||
content_for :javascript, view_context.javascript_tag(js_pre+js_load)
|
||||
content_for :javascript, view_context.javascript_tag(js_pre + js_load)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ end
|
|||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
|
||||
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'rake/testtask'
|
||||
|
|
@ -36,5 +34,4 @@ Rake::TestTask.new(:test) do |t|
|
|||
t.verbose = false
|
||||
end
|
||||
|
||||
|
||||
task :default => :test
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# encoding: utf-8
|
||||
class PagesController < ApplicationController
|
||||
before_action -> { require_plugin_enabled FoodsoftWiki }
|
||||
before_action :catch_special_pages, only: [:show, :new]
|
||||
|
|
@ -33,7 +32,7 @@ class PagesController < ApplicationController
|
|||
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?
|
||||
|
|
@ -61,7 +60,7 @@ class PagesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@page = Page.new(params[:page].merge({:user => current_user}))
|
||||
@page = Page.new(params[:page].merge({ :user => current_user }))
|
||||
|
||||
if params[:preview]
|
||||
render :action => 'new'
|
||||
|
|
@ -77,7 +76,7 @@ class PagesController < ApplicationController
|
|||
|
||||
def update
|
||||
@page = Page.find(params[:id])
|
||||
@page.attributes = params[:page].merge({:user => current_user})
|
||||
@page.attributes = params[:page].merge({ :user => current_user })
|
||||
|
||||
if params[:preview]
|
||||
@page.attributes = params[:page]
|
||||
|
|
@ -92,7 +91,6 @@ class PagesController < ApplicationController
|
|||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
rescue ActiveRecord::StaleObjectError
|
||||
flash[:error] = I18n.t('pages.error_stale_object')
|
||||
redirect_to wiki_page_path(@page.permalink)
|
||||
|
|
@ -116,11 +114,11 @@ class PagesController < ApplicationController
|
|||
end
|
||||
if params[:sort]
|
||||
sort = case params[:sort]
|
||||
when "title" then "title"
|
||||
when "title_reverse" then "title DESC"
|
||||
when "last_updated" then "updated_at DESC"
|
||||
when "last_updated_reverse" then "updated_at"
|
||||
end
|
||||
when "title" then "title"
|
||||
when "title_reverse" then "title DESC"
|
||||
when "last_updated" then "updated_at DESC"
|
||||
when "last_updated_reverse" then "updated_at"
|
||||
end
|
||||
else
|
||||
sort = "title"
|
||||
end
|
||||
|
|
@ -152,7 +150,7 @@ class PagesController < ApplicationController
|
|||
|
||||
def variables
|
||||
keys = Foodsoft::ExpansionVariables.variables.keys
|
||||
@variables = Hash[keys.map {|k| [k, Foodsoft::ExpansionVariables.get(k)]}]
|
||||
@variables = Hash[keys.map { |k| [k, Foodsoft::ExpansionVariables.get(k)] }]
|
||||
render 'variables'
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module PagesHelper
|
|||
end
|
||||
|
||||
def wikified_body(body, title = nil)
|
||||
FoodsoftWiki::WikiParser.new(data: body+"\n", params: {referer: title}).to_html(noedit: true).html_safe
|
||||
FoodsoftWiki::WikiParser.new(data: body + "\n", params: { referer: title }).to_html(noedit: true).html_safe
|
||||
rescue => e
|
||||
# try the following with line breaks: === one === == two == = three =
|
||||
content_tag :span, class: 'alert alert-error' do
|
||||
|
|
@ -22,13 +22,12 @@ module PagesHelper
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def link_to_wikipage_by_permalink(permalink, text = nil)
|
||||
unless permalink.blank?
|
||||
page = Page.find_by_permalink(permalink)
|
||||
if page.nil?
|
||||
if text.nil?
|
||||
link_to permalink, new_page_path(:title => permalink)
|
||||
link_to permalink, new_page_path(:title => permalink)
|
||||
else
|
||||
link_to text, new_page_path(:title => permalink)
|
||||
end
|
||||
|
|
@ -65,9 +64,8 @@ module PagesHelper
|
|||
end
|
||||
|
||||
# return url for all_pages rss feed
|
||||
def all_pages_rss_url(options={})
|
||||
def all_pages_rss_url(options = {})
|
||||
token = TokenVerifier.new(['wiki', 'all']).generate
|
||||
all_pages_url({:format => 'rss', :token => token}.merge(options))
|
||||
all_pages_url({ :format => 'rss', :token => token }.merge(options))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ class Page < ApplicationRecord
|
|||
def create_redirect
|
||||
unless old_title.blank?
|
||||
Page.create :redirect => id,
|
||||
:title => old_title,
|
||||
:body => I18n.t('model.page.redirect', :title => title),
|
||||
:permalink => Page.permalink(old_title),
|
||||
:updated_by => updated_by
|
||||
:title => old_title,
|
||||
:body => I18n.t('model.page.redirect', :title => title),
|
||||
:permalink => Page.permalink(old_title),
|
||||
:updated_by => updated_by
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
scope '/:foodcoop' do
|
||||
|
||||
resources :pages do
|
||||
get :all, :on => :collection
|
||||
get :version, :on => :member
|
||||
|
|
@ -9,8 +7,6 @@ Rails.application.routes.draw do
|
|||
get :diff, :on => :member
|
||||
end
|
||||
get '/wiki/:permalink' => 'pages#show', :as => 'wiki_page' # , :constraints => {:permalink => /[^\s]+/}
|
||||
get '/wiki' => 'pages#show', :defaults => {:permalink => 'Home'}, :as => 'wiki'
|
||||
|
||||
get '/wiki' => 'pages#show', :defaults => { :permalink => 'Home' }, :as => 'wiki'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ module FoodsoftWiki
|
|||
class Engine < ::Rails::Engine
|
||||
def navigation(primary, ctx)
|
||||
return unless FoodsoftWiki.enabled?
|
||||
|
||||
primary.item :wiki, I18n.t('navigation.wiki.title'), '#', id: nil do |subnav|
|
||||
subnav.item :wiki_home, I18n.t('navigation.wiki.home'), ctx.wiki_path, id: nil
|
||||
subnav.item :all_pages, I18n.t('navigation.wiki.all_pages'), ctx.all_pages_path, id: nil
|
||||
end
|
||||
# move this last added item to just after the foodcoop menu
|
||||
if i = primary.items.index(primary[:foodcoop])
|
||||
primary.items.insert(i+1, primary.items.delete_at(-1))
|
||||
primary.items.insert(i + 1, primary.items.delete_at(-1))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
module FoodsoftWiki
|
||||
|
||||
module Mailer
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
|
||||
# modify user presentation link to writing a message for the user
|
||||
def additonal_welcome_text(user)
|
||||
if FoodsoftWiki.enabled? && (page = Page.welcome_mail)
|
||||
page.body
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# modify existing helper
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
module FoodsoftWiki
|
||||
class WikiParser < WikiCloth::Parser
|
||||
|
||||
template do |template|
|
||||
Foodsoft::ExpansionVariables.get(template)
|
||||
end
|
||||
|
|
@ -31,12 +30,11 @@ module FoodsoftWiki
|
|||
super(render_options)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def link_attributes_if_number_sign_contained_in_nonexistent(page, referer)
|
||||
# Interpret the part after the last number sign as anchor.
|
||||
arr = page.split('#', -1)# `-1` preserves empty anchor
|
||||
arr = page.split('#', -1) # `-1` preserves empty anchor
|
||||
page = arr[0...-1].join('#')
|
||||
anchor = arr[-1]
|
||||
|
||||
|
|
@ -52,9 +50,8 @@ module FoodsoftWiki
|
|||
end
|
||||
end
|
||||
|
||||
def url_for(path_name, options={})
|
||||
Rails.application.routes.url_helpers.send path_name, options.merge({foodcoop: FoodsoftConfig.scope})
|
||||
def url_for(path_name, options = {})
|
||||
Rails.application.routes.url_helpers.send path_name, options.merge({ foodcoop: FoodsoftConfig.scope })
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue