enable/disable plugins by config option
This commit is contained in:
parent
6d98be6d22
commit
64bb8e043d
21 changed files with 65 additions and 15 deletions
|
|
@ -11,5 +11,8 @@ add the following to foodsoft's Gemfile:
|
|||
gem 'foodsoft_messages', path: 'lib/foodsoft_messages'
|
||||
```
|
||||
|
||||
This plugin introduces the foodcoop config option `use_messages`, which can be
|
||||
set to `false` to disable messages. May be useful in multicoop deployments.
|
||||
|
||||
This plugin is part of the foodsoft package and uses the GPL-3 license (see
|
||||
foodsoft's LICENSE for the full license text).
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
class MessagesController < ApplicationController
|
||||
|
||||
before_filter -> { require_plugin_enabled FoodsoftMessages }
|
||||
|
||||
# Renders the "inbox" action.
|
||||
def index
|
||||
@messages = Message.public.page(params[:page]).per(@per_page).order('created_at DESC').includes(:sender)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_after 'erb:contains("delete")'
|
||||
= link_to t('.send_message'), new_message_path(:message => {:group_id => @ordergroup.id}), class: 'btn'
|
||||
- if FoodsoftMessages.enabled?
|
||||
= link_to t('.send_message'), new_message_path(:message => {:group_id => @ordergroup.id}), class: 'btn'
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_after 'erb:contains("delete")'
|
||||
= link_to t('.send_message'), new_message_path(:message => {:mail_to => @user.id}), class: 'btn'
|
||||
- if FoodsoftMessages.enabled?
|
||||
= link_to t('.send_message'), new_message_path(:message => {:mail_to => @user.id}), class: 'btn'
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_after 'erb:contains("delete")'
|
||||
= link_to_new_message(message_params: {group_id: @workgroup.id})
|
||||
- if FoodsoftMessages.enabled?
|
||||
= link_to_new_message(message_params: {group_id: @workgroup.id})
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_bottom 'tbody tr'
|
||||
%td= link_to_new_message(message_params: {group_id: ordergroup.id})
|
||||
- if FoodsoftMessages.enabled?
|
||||
%td= link_to_new_message(message_params: {group_id: ordergroup.id})
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_bottom 'tbody tr'
|
||||
%td= link_to_new_message(message_params: {mail_to: user.id})
|
||||
- if FoodsoftMessages.enabled?
|
||||
%td= link_to_new_message(message_params: {mail_to: user.id})
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_after 'erb:contains("tasks")'
|
||||
= link_to_new_message message_params: {group_id: workgroup.id}
|
||||
- if FoodsoftMessages.enabled?
|
||||
= link_to_new_message message_params: {group_id: workgroup.id}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
/ insert_after 'erb:contains("tasks")'
|
||||
%li= link_to t('.write_message'), new_message_path
|
||||
- if FoodsoftMessages.enabled?
|
||||
%li= link_to t('.write_message'), new_message_path
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/ insert_after 'erb[silent]:contains("<dashboard_middle_mark>")'
|
||||
- unless Message.public.empty?
|
||||
%section#messages
|
||||
%h2= t '.messages.title'
|
||||
= render 'messages/messages', messages: Message.public.order('created_at DESC').limit(5), pagination: false
|
||||
%p= link_to t('.messages.view_all'), messages_path
|
||||
- if FoodsoftMessages.enabled?
|
||||
- unless Message.public.empty?
|
||||
%section#messages
|
||||
%h2= t '.messages.title'
|
||||
= render 'messages/messages', messages: Message.public.order('created_at DESC').limit(5), pagination: false
|
||||
%p= link_to t('.messages.view_all'), messages_path
|
||||
|
|
|
|||
|
|
@ -3,4 +3,9 @@ require "foodsoft_messages/user_link"
|
|||
require "deface"
|
||||
|
||||
module FoodsoftMessages
|
||||
# Return whether messages are used or not.
|
||||
# Enabled by default since it used to be part of the foodsoft core.
|
||||
def self.enabled?
|
||||
FoodsoftConfig[:use_messages] != false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
module FoodsoftMessages
|
||||
class Engine < ::Rails::Engine
|
||||
def navigation(primary, context)
|
||||
return unless FoodsoftMessages.enabled?
|
||||
return if primary[:foodcoop].nil?
|
||||
sub_nav = primary[:foodcoop].sub_navigation
|
||||
sub_nav.items <<
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ module FoodsoftMessages
|
|||
|
||||
# modify user presentation link to writing a message for the user
|
||||
def show_user_link(user=@current_user)
|
||||
if user.nil?
|
||||
if user.nil? or not FoodsoftMessages.enabled?
|
||||
show_user user
|
||||
else
|
||||
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue