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:
Patrick Gansterer 2019-11-04 00:25:57 +01:00
parent ff76fa60c0
commit e498f9cb58
5 changed files with 35 additions and 7 deletions

View file

@ -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