Removed hardcoded links from main tabnav.

* Reorganized routes and foodsoft config
* Avoid saving of wrong foodcoop tokens when following hard coded link
This commit is contained in:
Benjamin Meichsner 2010-03-20 13:45:58 +01:00
parent 9cb367463c
commit 2c1952d625
8 changed files with 81 additions and 113 deletions

View file

@ -6,7 +6,7 @@ class TasksController < ApplicationController
@groups = Workgroup.all
end
def myTasks
def user
@unaccepted_tasks = @current_user.unaccepted_tasks
@accepted_tasks = @current_user.accepted_tasks
end
@ -78,7 +78,7 @@ class TasksController < ApplicationController
task.assignments.create(:user => current_user, :accepted => true)
end
flash[:notice] = "Du hast die Aufgabe übernommen"
redirect_to my_tasks_path
redirect_to user_tasks_path
end
# deletes assignment between current_user and given task

View file

@ -21,11 +21,11 @@
- unless @unaccepted_tasks.empty?
%h3 Aufgaben übernehmen
Du bis für Aufgaben verantwortlich.
= link_to "Aufgaben übernehmen/ablehnen", my_tasks_path
= link_to "Aufgaben übernehmen/ablehnen", user_tasks_path
- unless @unassigned_tasks_number == 0
%h3 Offene Aufgaben
= "Es gibt #{@unassigned_tasks_number} #{link_to 'offene Aufgabe(n)', :controller => 'tasks'}"
%p{:style => "clear:both"}= link_to "Meine Aufgaben", my_tasks_path
%p{:style => "clear:both"}= link_to "Meine Aufgaben", user_tasks_path
- if @ordergroup
// Current orders

View file

@ -3,55 +3,55 @@
tabs = [
{ :name => "Start", :url => root_path, :active => ["index", "home"],
:subnav => [
{ :name => "Meine Aufgaben", :url => "/home/tasks" },
{ :name => "Meine Bestellgruppe", :url => "/home/ordergroup", :access_denied? => (!u.ordergroup)},
{ :name => "Mein Profil", :url => "/home/profile"}
{ :name => "Meine Aufgaben", :url => user_tasks_path },
{ :name => "Meine Bestellgruppe", :url => my_ordergroup_path, :access_denied? => (!u.ordergroup)},
{ :name => "Mein Profil", :url => my_profile_path}
]
},
{ :name => "Foodcoop", :url => "/tasks",
{ :name => "Foodcoop", :url => tasks_path,
:active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups", "foodcoop/workgroups", "foodcoop/users"],
:subnav => [
{ :name => "Mitglieder", :url => "/foodcoop/users"},
{ :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"},
{ :name => "Bestellgruppen", :url => "/foodcoop/ordergroups"},
{ :name => "Nachrichten", :url => "/messages"},
{ :name => "Aufgaben", :url => "/tasks"}
{ :name => "Mitglieder", :url => foodcoop_users_path},
{ :name => "Abeitsgruppen", :url => foodcoop_workgroups_path},
{ :name => "Bestellgruppen", :url => foodcoop_ordergroups_path},
{ :name => "Nachrichten", :url => messages_path},
{ :name => "Aufgaben", :url => tasks_path}
]
},
{ :name => "Wiki", :url => "/wiki", :active => ["pages", "wiki"],
{ :name => "Wiki", :url => wiki_path, :active => ["pages", "wiki"],
:subnav => [
{ :name => "Startseite", :url => "/wiki" },
{ :name => "Alle Seiten", :url => "/pages/all" }
{ :name => "Startseite", :url => wiki_path },
{ :name => "Alle Seiten", :url => all_pages_path }
]
},
{ :name => "Bestellungen", :url => u.ordergroup ? "/ordering/" : "/orders",
{ :name => "Bestellungen", :url => u.ordergroup ? ordering_path : orders_path,
:active => ["orders", "ordering"],
:subnav => [
{ :name => "Bestellen!", :url => "/ordering" },
{ :name => "Meine Bestellungen", :url => "/ordering/myOrders" },
{ :name => "Bestellverwaltung", :url => "/orders", :access_denied? => (!u.role_orders?) }
{ :name => "Bestellen!", :url => ordering_path },
{ :name => "Meine Bestellungen", :url => my_orders_path },
{ :name => "Bestellverwaltung", :url => orders_path, :access_denied? => (!u.role_orders?) }
]
},
{ :name => "Artikel", :url => "/suppliers",
{ :name => "Artikel", :url => suppliers_path,
:active => ["articles", "suppliers", "deliveries", "article_categories", "stockit", "stock_takings"],
:access_denied? => (!u.role_article_meta? && !u.role_suppliers?),
:subnav => [
{ :name => "Artikel", :url => supplier_articles_path(Supplier.first) },
{ :name => "Lager", :url => "/stockit" },
{ :name => "Lager", :url => stock_articles_path },
{ :name => "Lieferantinnen", :url => suppliers_path, :access_denied? => (!u.role_suppliers?) },
{ :name => "Kategorien", :url => "/article_categories"}
{ :name => "Kategorien", :url => article_categories_path }
]
},
{ :name => "Finanzen", :url => "/finance",
{ :name => "Finanzen", :url => finance_root_path,
:active => ["finance/invoices", "finance/transactions", "finance/balancing"],
:access_denied? => (!u.role_finance?),
:subnav => [
{ :name => "Konten verwalten", :url => "/finance/transactions" },
{ :name => "Bestellungen abrechnen", :url => "/finance/balancing/list" },
{ :name => "Konten verwalten", :url => finance_transactions_path },
{ :name => "Bestellungen abrechnen", :url => finance_balancing_path },
{ :name => "Rechnungen", :url => finance_invoices_path }
]
},
{ :name => "Administration", :url => "/admin",
{ :name => "Administration", :url => admin_root_path,
:active => ["admin", "admin/users", "admin/ordergroups", "admin/workgroups"],
:access_denied? => (!u.role_admin?),
:subnav => [

View file

@ -15,7 +15,7 @@
#header
#logo
%a{:href => "/"}
- link_to root_path do
<span>food</span>soft
%span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= Foodsoft.config[:name]
#nav= render :partial => 'layouts/main_tabnav'

View file

@ -8,7 +8,7 @@
%li
Seiten
%ul
%li= link_to "Meine Aufgaben", my_tasks_path
%li= link_to "Meine Aufgaben", user_tasks_path
%li= link_to "Alle Aufgaben", :action => "index"
%li= link_to "Erledigt Aufgaben (Archiv)", :action => "archive"

View file

@ -1,33 +1,25 @@
# Loads and returns config and databases for selected foodcoop.
# TODO: When to use class or module. It seems this could also be a Foodsoft-class?
module Foodsoft
@@configs = YAML.load(File.read(RAILS_ROOT + "/config/app_config.yml"))
@@databases = YAML.load(File.read(RAILS_ROOT + "/config/database.yml"))
@@env = RAILS_ENV
mattr_accessor :env, :config, :database
CONFIGS = YAML.load(File.read(RAILS_ROOT + "/config/app_config.yml"))
DATABASES = YAML.load(File.read(RAILS_ROOT + "/config/database.yml"))
def env=(env)
@@env = env
class << self
def env=(env)
raise "No config or database for this environment (#{env}) available!" if CONFIGS[env].nil? or DATABASES[env].nil?
@@config = CONFIGS[env].symbolize_keys
@@database = DATABASES[env].symbolize_keys
@@env = env
end
end
def env
@@env
end
def config(rails_env = @@env)
raise "No config for this environment (or subdomain) available!" if @@configs[rails_env].nil?
@@configs[rails_env].symbolize_keys
end
def database(rails_env = @@env)
raise "No database for this environment (or subdomain) available!" if @@databases[rails_env].nil?
@@databases[rails_env].symbolize_keys
end
extend self
end
# Initial load the default config and database from rails environment
Foodsoft.env = RAILS_ENV
# Configuration of the exception_notification plugin
# Mailadresses are set in config/foodsoft.yaml
ExceptionNotifier.exception_recipients = Foodsoft.config[:notification]['error_recipients']
ExceptionNotifier.sender_address = Foodsoft.config[:notification]['sender_address']
ExceptionNotifier.email_prefix = Foodsoft.config[:notification]['email_prefix']

View file

@ -1,23 +1,35 @@
ActionController::Routing::Routes.draw do |map|
# Use routing filter to select foodcoop config and datbase
map.filter 'foodcoop', :file => File.join(RAILS_ROOT, "lib", "foodcoop_filter")
# Root path
map.root :controller => 'home', :action => 'index'
# User specific
map.logout '/logout', :controller => 'login', :action => 'logout'
map.my_profile '/home/profile', :controller => 'home', :action => 'profile'
map.my_ordergroup '/home/ordergroup', :controller => 'home', :action => 'ordergroup'
# Wiki
map.resources :pages, :collection => { :all => :get }, :member => {:version => :get, :revert => :get}
map.wiki_page "/wiki/:permalink", :controller => 'pages', :action => 'show', :permalink => /[^\s]+/
map.wiki "/wiki", :controller => 'pages', :action => 'show', :permalink => 'Home'
map.logout '/logout', :controller => 'login', :action => 'logout'
map.my_profile '/home/profile', :controller => 'home', :action => 'profile'
map.my_ordergroup '/home/ordergroup', :controller => 'home', :action => 'ordergroup'
map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks'
# Orders, ordering
map.resources :orders, :member => { :finish => :post, :add_comment => :post }
map.with_options :controller => "ordering" do |ordering|
ordering.ordering "/ordering", :action => "index"
ordering.my_orders "/ordering/myOrders", :action => "myOrders"
end
# Foodcoop orga
map.resources :invites, :only => [:new, :create]
map.resources :tasks,
:collection => {:user => :get}
map.resources :messages, :only => [:index, :show, :new, :create],
:member => { :reply => :get, :user => :get, :group => :get }
map.resources :invites, :only => [:new, :create]
map.namespace :foodcoop do |foodcoop|
foodcoop.root :controller => "users", :action => "index"
foodcoop.resources :users, :only => [:index]
@ -26,17 +38,7 @@ ActionController::Routing::Routes.draw do |map|
:member => {:memberships => :get}
end
map.namespace :admin do |admin|
admin.resources :users
admin.resources :workgroups, :member => { :memberships => :get }
admin.resources :ordergroups, :member => { :memberships => :get }
end
map.namespace :finance do |finance|
finance.root :controller => 'balancing'
finance.resources :invoices
end
# Article management
map.resources :stock_takings,
:collection => {:fill_new_stock_article_form => :get, :add_stock_article => :post}
map.resources :stock_articles,
@ -55,47 +57,21 @@ ActionController::Routing::Routes.draw do |map|
end
map.resources :article_categories
map.root :controller => 'home', :action => 'index'
# Finance
map.namespace :finance do |finance|
finance.root :controller => 'balancing'
finance.balancing "balancing/list", :controller => 'balancing', :action => 'list'
finance.resources :invoices
finance.resources :transactions
end
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing the them or commenting them out if you're using named routes and resources.
# Administration
map.namespace :admin do |admin|
admin.root :controller => "admin", :action => "index"
admin.resources :users
admin.resources :workgroups, :member => { :memberships => :get }
admin.resources :ordergroups, :member => { :memberships => :get }
end
# Install the default route as the lowest priority.
map.connect ':controller/:action/:id'