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`
|
# Set configuration tab names as `@tabs`
|
||||||
def get_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
|
# allow engines to modify this list
|
||||||
engines = Rails::Engine.subclasses.map(&:instance).select { |e| e.respond_to?(:configuration) }
|
engines = Rails::Engine.subclasses.map(&:instance).select { |e| e.respond_to?(:configuration) }
|
||||||
engines.each { |e| e.configuration(@tabs, self) }
|
engines.each { |e| e.configuration(@tabs, self) }
|
||||||
|
|
|
@ -147,32 +147,32 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
# Checks the finance role
|
# Checks the finance role
|
||||||
def role_finance?
|
def role_finance?
|
||||||
groups.detect {|group| group.role_finance?}
|
FoodsoftConfig[:default_role_finance] || groups.detect {|group| group.role_finance?}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the invoices role
|
# Checks the invoices role
|
||||||
def role_invoices?
|
def role_invoices?
|
||||||
groups.detect {|group| group.role_invoices?}
|
FoodsoftConfig[:default_role_invoices] || groups.detect {|group| group.role_invoices?}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the article_meta role
|
# Checks the article_meta role
|
||||||
def role_article_meta?
|
def role_article_meta?
|
||||||
groups.detect {|group| group.role_article_meta?}
|
FoodsoftConfig[:default_role_article_meta] || groups.detect {|group| group.role_article_meta?}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the suppliers role
|
# Checks the suppliers role
|
||||||
def role_suppliers?
|
def role_suppliers?
|
||||||
groups.detect {|group| group.role_suppliers?}
|
FoodsoftConfig[:default_role_suppliers] || groups.detect {|group| group.role_suppliers?}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the invoices role
|
# Checks the invoices role
|
||||||
def role_pickups?
|
def role_pickups?
|
||||||
groups.detect {|group| group.role_pickups?}
|
FoodsoftConfig[:default_role_pickups] || groups.detect {|group| group.role_pickups?}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks the orders role
|
# Checks the orders role
|
||||||
def role_orders?
|
def role_orders?
|
||||||
groups.detect {|group| group.role_orders?}
|
FoodsoftConfig[:default_role_orders] || groups.detect {|group| group.role_orders?}
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordergroup_name
|
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
|
|
@ -268,6 +268,9 @@ de:
|
||||||
emails_title: E-Mails versenden
|
emails_title: E-Mails versenden
|
||||||
tab_payment:
|
tab_payment:
|
||||||
schedule_title: Bestellschema
|
schedule_title: Bestellschema
|
||||||
|
tab_roles:
|
||||||
|
access_to_title: Zugriff auf
|
||||||
|
access_to_paragraph: Jedes Mitglied der Foodcoop hat automatisch Zugriff auf folgende Bereiche.
|
||||||
tab_tasks:
|
tab_tasks:
|
||||||
periodic_title: Wiederkehrende Aufgaben
|
periodic_title: Wiederkehrende Aufgaben
|
||||||
tabs:
|
tabs:
|
||||||
|
@ -570,6 +573,12 @@ de:
|
||||||
currency_unit: Währung
|
currency_unit: Währung
|
||||||
custom_css: Angepasstes CSS
|
custom_css: Angepasstes CSS
|
||||||
default_locale: Standardsprache
|
default_locale: Standardsprache
|
||||||
|
default_role_article_meta: Artikeldatenbank
|
||||||
|
default_role_finance: Finanzen
|
||||||
|
default_role_invoices: Rechnungen
|
||||||
|
default_role_orders: Bestellverwaltung
|
||||||
|
default_role_pickups: Abholtage
|
||||||
|
default_role_suppliers: Lieferanten
|
||||||
disable_invite: Einladungen deaktivieren
|
disable_invite: Einladungen deaktivieren
|
||||||
email_from: Absenderadresse
|
email_from: Absenderadresse
|
||||||
email_replyto: Antwortadresse
|
email_replyto: Antwortadresse
|
||||||
|
@ -607,6 +616,7 @@ de:
|
||||||
messages: Nachrichten
|
messages: Nachrichten
|
||||||
others: Sonstiges
|
others: Sonstiges
|
||||||
payment: Finanzen
|
payment: Finanzen
|
||||||
|
roles: Rollen
|
||||||
tasks: Aufgaben
|
tasks: Aufgaben
|
||||||
deliveries:
|
deliveries:
|
||||||
add_stock_change:
|
add_stock_change:
|
||||||
|
|
|
@ -285,6 +285,9 @@ en:
|
||||||
emails_title: Sending email
|
emails_title: Sending email
|
||||||
tab_payment:
|
tab_payment:
|
||||||
schedule_title: Ordering schedule
|
schedule_title: Ordering schedule
|
||||||
|
tab_roles:
|
||||||
|
access_to_title: Access to
|
||||||
|
access_to_paragraph: By default every member of the foodcoop has access to the following areas.
|
||||||
tab_tasks:
|
tab_tasks:
|
||||||
periodic_title: Periodic tasks
|
periodic_title: Periodic tasks
|
||||||
tabs:
|
tabs:
|
||||||
|
@ -590,6 +593,12 @@ en:
|
||||||
currency_unit: Currency
|
currency_unit: Currency
|
||||||
custom_css: Custom CSS
|
custom_css: Custom CSS
|
||||||
default_locale: Default language
|
default_locale: Default language
|
||||||
|
default_role_article_meta: Articles
|
||||||
|
default_role_finance: Finance
|
||||||
|
default_role_invoices: Invoices
|
||||||
|
default_role_orders: Orders
|
||||||
|
default_role_pickups: Pickup days
|
||||||
|
default_role_suppliers: Suppliers
|
||||||
disable_invite: Disable invites
|
disable_invite: Disable invites
|
||||||
email_from: From address
|
email_from: From address
|
||||||
email_replyto: Reply-to address
|
email_replyto: Reply-to address
|
||||||
|
@ -632,6 +641,7 @@ en:
|
||||||
messages: Messages
|
messages: Messages
|
||||||
others: Other
|
others: Other
|
||||||
payment: Finances
|
payment: Finances
|
||||||
|
roles: Roles
|
||||||
tasks: Tasks
|
tasks: Tasks
|
||||||
deliveries:
|
deliveries:
|
||||||
add_stock_change:
|
add_stock_change:
|
||||||
|
|
Loading…
Reference in a new issue