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

View file

@ -21,11 +21,11 @@
- unless @unaccepted_tasks.empty? - unless @unaccepted_tasks.empty?
%h3 Aufgaben übernehmen %h3 Aufgaben übernehmen
Du bis für Aufgaben verantwortlich. 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 - unless @unassigned_tasks_number == 0
%h3 Offene Aufgaben %h3 Offene Aufgaben
= "Es gibt #{@unassigned_tasks_number} #{link_to 'offene Aufgabe(n)', :controller => 'tasks'}" = "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 - if @ordergroup
// Current orders // Current orders

View file

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

View file

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

View file

@ -8,7 +8,7 @@
%li %li
Seiten Seiten
%ul %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 "Alle Aufgaben", :action => "index"
%li= link_to "Erledigt Aufgaben (Archiv)", :action => "archive" %li= link_to "Erledigt Aufgaben (Archiv)", :action => "archive"

View file

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

View file

@ -1,23 +1,35 @@
ActionController::Routing::Routes.draw do |map| 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") 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.resources :pages, :collection => { :all => :get }, :member => {:version => :get, :revert => :get}
map.wiki_page "/wiki/:permalink", :controller => 'pages', :action => 'show', :permalink => /[^\s]+/ map.wiki_page "/wiki/:permalink", :controller => 'pages', :action => 'show', :permalink => /[^\s]+/
map.wiki "/wiki", :controller => 'pages', :action => 'show', :permalink => 'Home' map.wiki "/wiki", :controller => 'pages', :action => 'show', :permalink => 'Home'
map.logout '/logout', :controller => 'login', :action => 'logout' # Orders, ordering
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'
map.resources :orders, :member => { :finish => :post, :add_comment => :post } 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], map.resources :messages, :only => [:index, :show, :new, :create],
:member => { :reply => :get, :user => :get, :group => :get } :member => { :reply => :get, :user => :get, :group => :get }
map.resources :invites, :only => [:new, :create]
map.namespace :foodcoop do |foodcoop| map.namespace :foodcoop do |foodcoop|
foodcoop.root :controller => "users", :action => "index" foodcoop.root :controller => "users", :action => "index"
foodcoop.resources :users, :only => [:index] foodcoop.resources :users, :only => [:index]
@ -26,17 +38,7 @@ ActionController::Routing::Routes.draw do |map|
:member => {:memberships => :get} :member => {:memberships => :get}
end end
map.namespace :admin do |admin| # Article management
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
map.resources :stock_takings, map.resources :stock_takings,
:collection => {:fill_new_stock_article_form => :get, :add_stock_article => :post} :collection => {:fill_new_stock_article_form => :get, :add_stock_article => :post}
map.resources :stock_articles, map.resources :stock_articles,
@ -55,47 +57,21 @@ ActionController::Routing::Routes.draw do |map|
end end
map.resources :article_categories 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. # Administration
map.namespace :admin do |admin|
# Sample of regular route: admin.root :controller => "admin", :action => "index"
# map.connect 'products/:id', :controller => 'catalog', :action => 'view' admin.resources :users
# Keep in mind you can assign values other than :controller and :action admin.resources :workgroups, :member => { :memberships => :get }
admin.resources :ordergroups, :member => { :memberships => :get }
# Sample of named route: end
# 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.
# Install the default route as the lowest priority. # Install the default route as the lowest priority.
map.connect ':controller/:action/:id' map.connect ':controller/:action/:id'