Add polls plugin

This commit is contained in:
Patrick Gansterer 2017-11-05 22:16:32 +01:00
parent 42e0ce86a8
commit d476993321
29 changed files with 787 additions and 0 deletions

View file

@ -0,0 +1,9 @@
require 'foodsoft_polls/engine'
module FoodsoftPolls
# Return whether the polls are used or not.
# Enabled by default in {FoodsoftConfig} since it used to be part of the foodsoft core.
def self.enabled?
FoodsoftConfig[:use_polls]
end
end

View file

@ -0,0 +1,15 @@
module FoodsoftPolls
class Engine < ::Rails::Engine
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)
# move to right before tasks item
if i = sub_nav.items.index(sub_nav[:tasks])
sub_nav.items.insert(i, sub_nav.items.delete_at(-1))
end
end
end
end

View file

@ -0,0 +1,3 @@
module FoodsoftPolls
VERSION = "0.0.1"
end