Add default roles for users
Some foodcoops want to give some roles to every member by default, without adding every users to a workgroup.
This commit is contained in:
parent
ff76fa60c0
commit
e498f9cb58
5 changed files with 35 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ class Admin::ConfigsController < Admin::BaseController
|
|||
|
||||
# Set configuration tab names as `@tabs`
|
||||
def get_tabs
|
||||
@tabs = %w(foodcoop payment tasks messages layout language others)
|
||||
@tabs = %w(foodcoop payment tasks messages layout language roles others)
|
||||
# allow engines to modify this list
|
||||
engines = Rails::Engine.subclasses.map(&:instance).select { |e| e.respond_to?(:configuration) }
|
||||
engines.each { |e| e.configuration(@tabs, self) }
|
||||
|
|
|
|||
|
|
@ -147,32 +147,32 @@ class User < ApplicationRecord
|
|||
|
||||
# Checks the finance role
|
||||
def role_finance?
|
||||
groups.detect {|group| group.role_finance?}
|
||||
FoodsoftConfig[:default_role_finance] || groups.detect {|group| group.role_finance?}
|
||||
end
|
||||
|
||||
# Checks the invoices role
|
||||
def role_invoices?
|
||||
groups.detect {|group| group.role_invoices?}
|
||||
FoodsoftConfig[:default_role_invoices] || groups.detect {|group| group.role_invoices?}
|
||||
end
|
||||
|
||||
# Checks the article_meta role
|
||||
def role_article_meta?
|
||||
groups.detect {|group| group.role_article_meta?}
|
||||
FoodsoftConfig[:default_role_article_meta] || groups.detect {|group| group.role_article_meta?}
|
||||
end
|
||||
|
||||
# Checks the suppliers role
|
||||
def role_suppliers?
|
||||
groups.detect {|group| group.role_suppliers?}
|
||||
FoodsoftConfig[:default_role_suppliers] || groups.detect {|group| group.role_suppliers?}
|
||||
end
|
||||
|
||||
# Checks the invoices role
|
||||
def role_pickups?
|
||||
groups.detect {|group| group.role_pickups?}
|
||||
FoodsoftConfig[:default_role_pickups] || groups.detect {|group| group.role_pickups?}
|
||||
end
|
||||
|
||||
# Checks the orders role
|
||||
def role_orders?
|
||||
groups.detect {|group| group.role_orders?}
|
||||
FoodsoftConfig[:default_role_orders] || groups.detect {|group| group.role_orders?}
|
||||
end
|
||||
|
||||
def ordergroup_name
|
||||
|
|
|
|||
8
app/views/admin/configs/_tab_roles.html.haml
Normal file
8
app/views/admin/configs/_tab_roles.html.haml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%h4= t '.access_to_title'
|
||||
= t '.access_to_paragraph'
|
||||
= config_input form, :default_role_suppliers, as: :boolean
|
||||
= config_input form, :default_role_article_meta, as: :boolean
|
||||
= config_input form, :default_role_orders, as: :boolean
|
||||
= config_input form, :default_role_pickups, as: :boolean
|
||||
= config_input form, :default_role_finance, as: :boolean
|
||||
= config_input form, :default_role_invoices, as: :boolean
|
||||
Loading…
Add table
Add a link
Reference in a new issue