diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5cebad4c..19958a51 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -48,11 +48,11 @@ class ApplicationController < ActionController::Base # We have an authenticated user, now check role... # Roles gets the user through his memberships. hasRole = case role - when "admin" then user.role_admin? - when "finance" then user.role_finance? - when "article_meta" then user.role_article_meta? - when "suppliers" then user.role_suppliers? - when "orders" then user.role_orders? + when "admin" then current_user.role_admin? + when "finance" then current_user.role_finance? + when "article_meta" then current_user.role_article_meta? + when "suppliers" then current_user.role_suppliers? + when "orders" then current_user.role_orders? when "any" then true # no role required else false # any unknown role will always fail end diff --git a/app/controllers/ordering_controller.rb b/app/controllers/ordering_controller.rb index 87283011..b7a4bb81 100644 --- a/app/controllers/ordering_controller.rb +++ b/app/controllers/ordering_controller.rb @@ -5,8 +5,6 @@ class OrderingController < ApplicationController before_filter :ensure_ordergroup_member before_filter :ensure_open_order, :only => [:order, :stock_order, :saveOrder] - verify :method => :post, :only => [:saveOrder], :redirect_to => {:action => :index} - # Index page. def index end diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index 59051536..7c74c14f 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -3,7 +3,7 @@ class SuppliersController < ApplicationController helper :deliveries def index - @suppliers = Supplier.without_deleted :order => 'name' + @suppliers = Supplier.order(:name) @deliveries = Delivery.recent end diff --git a/app/models/supplier.rb b/app/models/supplier.rb index b1768bfe..ae5854cb 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -9,10 +9,14 @@ class Supplier < ActiveRecord::Base has_many :invoices belongs_to :shared_supplier # for the sharedLists-App - attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, :delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity - - validates_length_of :name, :in => 4..30 - validates_uniqueness_of :name + attr_accessible :name, :address, :phone, :phone2, :fax, :email, :url, :contact_person, :customer_number, + :delivery_days, :order_howto, :note, :shared_supplier_id, :min_order_quantity + + validates :name, :presence => true, :length => { :in => 4..30 }, :uniqueness => true + validates :phone, :presence => true, :length => { :in => 8..20 } + validates :address, :presence => true, :length => { :in => 8..50 } +# validates_length_of :name, :in => 4..30 +# validates_uniqueness_of :name validates_length_of :phone, :in => 8..20 validates_length_of :address, :in => 8..50 diff --git a/app/views/suppliers/_form.haml b/app/views/suppliers/_form.haml index e3b3a2b7..fe935637 100644 --- a/app/views/suppliers/_form.haml +++ b/app/views/suppliers/_form.haml @@ -1,60 +1,19 @@ -= error_messages_for 'supplier' - -- if @supplier.shared_supplier - %p Lieferantin wird mit externer Datenbank verknüpft. -.edit_form{:style=>"width:30em"} - %table - %tr - %td - %label{:for => "supplier_name"} Name - %td= @f.text_field :name - %tr - %td - %label{:for => "supplier_address"} Adresse - %td= @f.text_field :address - %tr - %td - %label{:for => "supplier_phone"} Telefon - %td= @f.text_field :phone - %tr - %td - %label{:for => "supplier_phone2"} Telefon2 - %td= @f.text_field :phone2 - %tr - %td - %label{:for => "supplier_fax"} Fax - %td= @f.text_field :fax - %tr - %td - %label{:for => "supplier_email"} E-Mail - %td= @f.text_field :email - %tr - %td - %label{:for => "supplier_url"} Hompage - %td= @f.text_field :url - %tr - %td - %label{:for => "supplier_contact_person"} Kotakt Person - %td= @f.text_field :contact_person - %tr - %td - %label{:for => "supplier_customer_number"} Kundennummer - %td= @f.text_field :customer_number - %tr - %td - %label{:for => "supplier_delivery_days"} Liefertage - %td= @f.text_field :delivery_days - %tr - %td - %label{:for => "supplier_order_howto"} BestellHowto - %td= @f.text_field :order_howto - %tr - %td - %label{:for => "supplier_note"} Notiz - %td= @f.text_field :note - %tr - %td - %label{:for => "supplier_min_order_quantity"} Mindestbestellmenge - %td= @f.text_field :min_order_quantity - = @f.hidden_field :shared_supplier_id - +- simple_form_for @supplier do |f| + - if @supplier.shared_supplier + %p Lieferantin wird mit externer Datenbank verknüpft. + = f.hidden_field :shared_supplier_id + = f.input :name + = f.input :address + = f.input :phone + = f.input :phone2 + = f.input :fax + = f.input :email + = f.input :url + = f.input :contact_person + = f.input :customer_number + = f.input :delivery_days + = f.input :order_howto + = f.input :note + = f.input :min_order_quantity + = f.submit + = link_to 'oder abbrechen', suppliers_path \ No newline at end of file diff --git a/app/views/suppliers/edit.haml b/app/views/suppliers/edit.haml index 692f80dd..24a35c12 100644 --- a/app/views/suppliers/edit.haml +++ b/app/views/suppliers/edit.haml @@ -1,6 +1,3 @@ -%h1 Lieferantin bearbeiten -- form_for @supplier do |@f| - = render :partial => 'form' - = submit_tag 'Speichern' - | - = link_to 'Abbrechen', suppliers_path \ No newline at end of file +- title "Lieferantin bearbeiten" + += render "form" \ No newline at end of file diff --git a/app/views/suppliers/index.haml b/app/views/suppliers/index.haml index cb3c5cf1..56079919 100644 --- a/app/views/suppliers/index.haml +++ b/app/views/suppliers/index.haml @@ -26,8 +26,8 @@ %td= link_to h(supplier.name) , supplier %td=h supplier.phone %td=h supplier.customer_number - %td= link_to "Artikel (#{supplier.articles.without_deleted.count})", supplier_articles_path(supplier) - %td= link_to "im Lager (#{supplier.stock_articles.without_deleted.count})", stock_articles_path + %td= link_to "Artikel (#{supplier.articles.count})", supplier_articles_path(supplier) + %td= link_to "im Lager (#{supplier.stock_articles.count})", stock_articles_path %td= link_to "Lieferungen (#{supplier.deliveries.count})", supplier_deliveries_path(supplier) .right_column{:style => "width:37%"} diff --git a/app/views/suppliers/new.haml b/app/views/suppliers/new.haml index c8a4d1a1..07fdb6ef 100644 --- a/app/views/suppliers/new.haml +++ b/app/views/suppliers/new.haml @@ -1,7 +1,3 @@ -%h1 Neue Lieferantinn -- form_for @supplier do |@f| - = render :partial => 'form' - = submit_tag "Speichern" - | - = link_to 'Abbrechen', suppliers_path - \ No newline at end of file +- title "Neue Lieferantin" + += render "form" \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 52766355..b13f81be 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -207,6 +207,7 @@ de: password: 'Passwort' description: 'Beschreibung' title: 'Titel' + email: 'E-Mail' workgroup: weekly_task: 'Monatlichen Job definieren?' weekday: 'Wochentag' @@ -230,7 +231,21 @@ de: private: 'privat verschicken, Nachricht erscheint nicht im Foodsoft Posteingang' page: body: 'Inhalt' + supplier: + address: 'Adresse' + phone: 'Telefon' + phone2: 'Telefon 2' + fax: 'FAX' + url: 'Homepage' + contact_person: 'Ansprechparter_in' + customer_number: 'Kundennummer' + delivery_days: 'Liefertage' + order_howto: 'Howto Bestellen' + note: 'Notiz' + min_order_quantity: 'Mindestbestellmenge' hints: task: duration: 'Wie lange dauert die Aufgabe, 1-3 Stunden' required_users: 'Wieviel Benutzerinnen werden insgesamt benötigt?' + supplier: + min_order_quantity: 'Die Mindestbestellmenge wird während der Bestellung angezeigt und soll motivieren'