Add pickups role
This commit is contained in:
parent
4c41a99fde
commit
ac11ba1cc1
14 changed files with 42 additions and 15 deletions
BIN
app/assets/images/role-pickups.png
Normal file
BIN
app/assets/images/role-pickups.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 446 B |
|
@ -68,9 +68,11 @@ class ApplicationController < ActionController::Base
|
||||||
when "admin" then current_user.role_admin?
|
when "admin" then current_user.role_admin?
|
||||||
when "finance" then current_user.role_finance?
|
when "finance" then current_user.role_finance?
|
||||||
when "article_meta" then current_user.role_article_meta?
|
when "article_meta" then current_user.role_article_meta?
|
||||||
|
when "pickups" then current_user.role_pickups?
|
||||||
when "suppliers" then current_user.role_suppliers?
|
when "suppliers" then current_user.role_suppliers?
|
||||||
when "orders" then current_user.role_orders?
|
when "orders" then current_user.role_orders?
|
||||||
when "finance_or_orders" then (current_user.role_finance? || current_user.role_orders?)
|
when "finance_or_orders" then (current_user.role_finance? || current_user.role_orders?)
|
||||||
|
when "pickups_or_orders" then (current_user.role_pickups? || current_user.role_orders?)
|
||||||
when "any" then true # no role required
|
when "any" then true # no role required
|
||||||
else false # any unknown role will always fail
|
else false # any unknown role will always fail
|
||||||
end
|
end
|
||||||
|
@ -94,6 +96,10 @@ class ApplicationController < ActionController::Base
|
||||||
authenticate('article_meta')
|
authenticate('article_meta')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authenticate_pickups
|
||||||
|
authenticate('pickups')
|
||||||
|
end
|
||||||
|
|
||||||
def authenticate_suppliers
|
def authenticate_suppliers
|
||||||
authenticate('suppliers')
|
authenticate('suppliers')
|
||||||
end
|
end
|
||||||
|
@ -106,6 +112,10 @@ class ApplicationController < ActionController::Base
|
||||||
authenticate('finance_or_orders')
|
authenticate('finance_or_orders')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authenticate_pickups_or_orders
|
||||||
|
authenticate('pickups_or_orders')
|
||||||
|
end
|
||||||
|
|
||||||
# checks if the current_user is member of given group.
|
# checks if the current_user is member of given group.
|
||||||
# if fails the user will redirected to startpage
|
# if fails the user will redirected to startpage
|
||||||
def authenticate_membership_or_admin(group_id = params[:id])
|
def authenticate_membership_or_admin(group_id = params[:id])
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
# Normal ordering actions of members of order groups is handled by the OrderingController.
|
# Normal ordering actions of members of order groups is handled by the OrderingController.
|
||||||
class OrdersController < ApplicationController
|
class OrdersController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_orders
|
before_filter :authenticate_pickups_or_orders
|
||||||
|
before_filter :authenticate_orders, except: [:receive, :receive_on_order_article_create, :receive_on_order_article_update, :show]
|
||||||
before_filter :remove_empty_article, only: [:create, :update]
|
before_filter :remove_empty_article, only: [:create, :update]
|
||||||
|
|
||||||
# List orders
|
# List orders
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
class PickupsController < ApplicationController
|
class PickupsController < ApplicationController
|
||||||
|
|
||||||
|
before_filter :authenticate_pickups
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup }
|
@orders = Order.finished_not_closed.order('pickup DESC').group_by { |o| o.pickup }
|
||||||
end
|
end
|
||||||
|
|
|
@ -150,7 +150,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_roles(record, icon=false)
|
def format_roles(record, icon=false)
|
||||||
roles = %w(suppliers article_meta orders finance invoices admin)
|
roles = %w(suppliers article_meta orders pickups finance invoices admin)
|
||||||
roles.select! {|role| record.send "role_#{role}?"}
|
roles.select! {|role| record.send "role_#{role}?"}
|
||||||
names = Hash[roles.map{|r| [r, I18n.t("helpers.application.role_#{r}")]}]
|
names = Hash[roles.map{|r| [r, I18n.t("helpers.application.role_#{r}")]}]
|
||||||
if icon
|
if icon
|
||||||
|
|
|
@ -165,6 +165,11 @@ class User < ActiveRecord::Base
|
||||||
groups.detect {|group| group.role_suppliers?}
|
groups.detect {|group| group.role_suppliers?}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks the invoices role
|
||||||
|
def role_pickups?
|
||||||
|
groups.detect {|group| group.role_pickups?}
|
||||||
|
end
|
||||||
|
|
||||||
# Checks the orders role
|
# Checks the orders role
|
||||||
def role_orders?
|
def role_orders?
|
||||||
groups.detect {|group| group.role_orders?}
|
groups.detect {|group| group.role_orders?}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
= f.input :role_suppliers
|
= f.input :role_suppliers
|
||||||
= f.input :role_article_meta
|
= f.input :role_article_meta
|
||||||
= f.input :role_orders
|
= f.input :role_orders
|
||||||
|
= f.input :role_pickups
|
||||||
= f.input :role_finance
|
= f.input :role_finance
|
||||||
= f.input :role_invoices
|
= f.input :role_invoices
|
||||||
= f.input :role_admin
|
= f.input :role_admin
|
||||||
|
|
|
@ -24,10 +24,7 @@
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
= check_box_tag "orders[]", order.id, true #, style: 'float:left'
|
= check_box_tag "orders[]", order.id, true #, style: 'float:left'
|
||||||
- if current_user.role_orders?
|
= link_to order.name, order_path(order)
|
||||||
= link_to order.name, order_path(order)
|
|
||||||
- else
|
|
||||||
= order.name
|
|
||||||
%td= truncate order.note
|
%td= truncate order.note
|
||||||
%td{style:'white-space:nowrap'}
|
%td{style:'white-space:nowrap'}
|
||||||
= render 'shared/order_download_button', order: order, klass: 'btn-small'
|
= render 'shared/order_download_button', order: order, klass: 'btn-small'
|
||||||
|
|
|
@ -220,6 +220,7 @@ de:
|
||||||
role_finance: Finanzen
|
role_finance: Finanzen
|
||||||
role_invoices: Rechnungen
|
role_invoices: Rechnungen
|
||||||
role_orders: Bestellverwaltung
|
role_orders: Bestellverwaltung
|
||||||
|
role_pickups: Abholtage
|
||||||
role_suppliers: Lieferanten
|
role_suppliers: Lieferanten
|
||||||
user_tokens: Mitglieder
|
user_tokens: Mitglieder
|
||||||
errors:
|
errors:
|
||||||
|
@ -1082,6 +1083,7 @@ de:
|
||||||
role_finance: Finanzen
|
role_finance: Finanzen
|
||||||
role_invoices: Rechnungen
|
role_invoices: Rechnungen
|
||||||
role_orders: Bestellung
|
role_orders: Bestellung
|
||||||
|
role_pickups: Abholtage
|
||||||
role_suppliers: Lieferanten
|
role_suppliers: Lieferanten
|
||||||
show_google_maps: Show it on Google maps
|
show_google_maps: Show it on Google maps
|
||||||
sort_by: Nach %{text} sortieren
|
sort_by: Nach %{text} sortieren
|
||||||
|
|
|
@ -220,6 +220,7 @@ en:
|
||||||
role_finance: Finances
|
role_finance: Finances
|
||||||
role_invoices: Invoices
|
role_invoices: Invoices
|
||||||
role_orders: Order management
|
role_orders: Order management
|
||||||
|
role_pickups: Pickup days
|
||||||
role_suppliers: Suppliers
|
role_suppliers: Suppliers
|
||||||
user_tokens: Members
|
user_tokens: Members
|
||||||
errors:
|
errors:
|
||||||
|
@ -1084,6 +1085,7 @@ en:
|
||||||
role_finance: Finance
|
role_finance: Finance
|
||||||
role_invoices: Invoices
|
role_invoices: Invoices
|
||||||
role_orders: Orders
|
role_orders: Orders
|
||||||
|
role_pickups: Pickup days
|
||||||
role_suppliers: Suppliers
|
role_suppliers: Suppliers
|
||||||
show_google_maps: Show it on Google maps
|
show_google_maps: Show it on Google maps
|
||||||
sort_by: Sort by %{text}
|
sort_by: Sort by %{text}
|
||||||
|
|
|
@ -24,7 +24,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
||||||
subnav.item :ordering, I18n.t('navigation.orders.ordering'), group_orders_path
|
subnav.item :ordering, I18n.t('navigation.orders.ordering'), group_orders_path
|
||||||
subnav.item :ordering_archive, I18n.t('navigation.orders.archive'), archive_group_orders_path
|
subnav.item :ordering_archive, I18n.t('navigation.orders.archive'), archive_group_orders_path
|
||||||
subnav.item :orders, I18n.t('navigation.orders.manage'), orders_path, if: Proc.new { current_user.role_orders? }
|
subnav.item :orders, I18n.t('navigation.orders.manage'), orders_path, if: Proc.new { current_user.role_orders? }
|
||||||
subnav.item :pickups, I18n.t('navigation.orders.pickups'), pickups_path, if: Proc.new { current_user.role_orders? }
|
subnav.item :pickups, I18n.t('navigation.orders.pickups'), pickups_path, if: Proc.new { current_user.role_pickups? }
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :articles, I18n.t('navigation.articles.title'), '#',
|
primary.item :articles, I18n.t('navigation.articles.title'), '#',
|
||||||
|
|
5
db/migrate/20171111000000_add_role_pickups_to_group.rb
Normal file
5
db/migrate/20171111000000_add_role_pickups_to_group.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddRolePickupsToGroup < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :groups, :role_pickups, :boolean, default: false, null: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171110000000) do
|
ActiveRecord::Schema.define(version: 20171111000000) do
|
||||||
|
|
||||||
create_table "article_categories", force: :cascade do |t|
|
create_table "article_categories", force: :cascade do |t|
|
||||||
t.string "name", limit: 255, default: "", null: false
|
t.string "name", limit: 255, default: "", null: false
|
||||||
|
@ -170,6 +170,7 @@ ActiveRecord::Schema.define(version: 20171110000000) do
|
||||||
t.boolean "role_invoices", default: false, null: false
|
t.boolean "role_invoices", default: false, null: false
|
||||||
t.date "break_start"
|
t.date "break_start"
|
||||||
t.date "break_end"
|
t.date "break_end"
|
||||||
|
t.boolean "role_pickups", default: false, null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "groups", ["name"], name: "index_groups_on_name", unique: true, using: :btree
|
add_index "groups", ["name"], name: "index_groups_on_name", unique: true, using: :btree
|
||||||
|
|
|
@ -7,6 +7,7 @@ administrators = Workgroup.create(
|
||||||
:role_admin => true,
|
:role_admin => true,
|
||||||
:role_finance => true,
|
:role_finance => true,
|
||||||
:role_article_meta => true,
|
:role_article_meta => true,
|
||||||
|
:role_pickups => true,
|
||||||
:role_suppliers => true,
|
:role_suppliers => true,
|
||||||
:role_orders => true
|
:role_orders => true
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue