From 5fb0bc244458be161614d38c5c18997e3ba44997 Mon Sep 17 00:00:00 2001 From: benni Date: Fri, 24 Aug 2012 11:11:40 +0200 Subject: [PATCH] Big feactoring and bug fixing, Mailer, Tasks, GroupOrders --- .../financial_transactions_controller.rb | 5 +++-- ...ontroller.rb => group_orders_controller.rb} | 12 ++++++++---- app/controllers/login_controller.rb | 3 ++- app/controllers/messages_controller.rb | 4 +--- app/controllers/tasks_controller.rb | 17 +++-------------- ...dering_helper.rb => group_orders_helper.rb} | 2 +- app/mailers/mailer.rb | 15 +++++++-------- app/models/message.rb | 10 +++++----- app/models/ordergroup.rb | 2 +- app/models/task.rb | 1 + app/models/user.rb | 4 ++++ app/models/workgroup.rb | 5 +++-- .../financial_transactions/new.html.haml | 4 +++- .../foodcoop/workgroups/_workgroup.html.haml | 2 +- .../{ordering => group_orders}/_form.html.haml | 2 +- .../_orders.html.haml | 2 +- .../_switch_order.html.haml | 0 .../archive.html.haml | 2 +- .../{ordering => group_orders}/edit.html.haml | 0 .../{ordering => group_orders}/index.html.haml | 0 .../{ordering => group_orders}/new.html.haml | 0 .../{ordering => group_orders}/order.html.haml | 0 .../{ordering => group_orders}/show.html.haml | 0 app/views/home/_start_nav.haml | 2 +- app/views/layouts/_main_tabnav.html.erb | 4 ++-- app/views/login/forgot_password.html.haml | 13 ++++--------- app/views/login/password.html.haml | 18 ++++-------------- .../mailer/{feedback.erb => feedback.text.erb} | 0 app/views/mailer/foodsoft_message.text.erb | 6 ------ .../{invite.html.erb => invite.text.erb} | 4 ++-- ...ance.html.erb => negative_balance.text.erb} | 0 app/views/mailer/not_enough_users_assigned.erb | 11 ----------- .../mailer/not_enough_users_assigned.text.erb | 11 +++++++++++ ...r_result.html.erb => order_result.text.erb} | 4 ++-- ...ssword.html.erb => reset_password.text.erb} | 4 ++-- app/views/mailer/upcoming_tasks.html.erb | 16 ---------------- app/views/mailer/upcoming_tasks.text.erb | 15 +++++++++++++++ app/views/shared/_group_form_fields.html.haml | 2 +- app/views/tasks/_form.html.haml | 2 +- app/views/tasks/_nav.haml | 2 +- app/views/tasks/show.haml | 2 +- app/views/tasks/workgroup.haml | 2 +- config/routes.rb | 3 +-- 43 files changed, 95 insertions(+), 118 deletions(-) rename app/controllers/{ordering_controller.rb => group_orders_controller.rb} (89%) rename app/helpers/{ordering_helper.rb => group_orders_helper.rb} (97%) rename app/views/{ordering => group_orders}/_form.html.haml (99%) rename app/views/{ordering => group_orders}/_orders.html.haml (85%) rename app/views/{ordering => group_orders}/_switch_order.html.haml (100%) rename app/views/{ordering => group_orders}/archive.html.haml (89%) rename app/views/{ordering => group_orders}/edit.html.haml (100%) rename app/views/{ordering => group_orders}/index.html.haml (100%) rename app/views/{ordering => group_orders}/new.html.haml (100%) rename app/views/{ordering => group_orders}/order.html.haml (100%) rename app/views/{ordering => group_orders}/show.html.haml (100%) rename app/views/mailer/{feedback.erb => feedback.text.erb} (100%) rename app/views/mailer/{invite.html.erb => invite.text.erb} (78%) rename app/views/mailer/{negative_balance.html.erb => negative_balance.text.erb} (100%) delete mode 100644 app/views/mailer/not_enough_users_assigned.erb create mode 100644 app/views/mailer/not_enough_users_assigned.text.erb rename app/views/mailer/{order_result.html.erb => order_result.text.erb} (65%) rename app/views/mailer/{reset_password.html.erb => reset_password.text.erb} (80%) delete mode 100644 app/views/mailer/upcoming_tasks.html.erb create mode 100644 app/views/mailer/upcoming_tasks.text.erb diff --git a/app/controllers/finance/financial_transactions_controller.rb b/app/controllers/finance/financial_transactions_controller.rb index 02c15188..fd39f4a8 100644 --- a/app/controllers/finance/financial_transactions_controller.rb +++ b/app/controllers/finance/financial_transactions_controller.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class Finance::FinancialTransactionsController < ApplicationController before_filter :authenticate_finance before_filter :find_ordergroup, :except => [:new_collection, :create_collection] @@ -38,8 +39,8 @@ class Finance::FinancialTransactionsController < ApplicationController @financial_transaction.user = current_user @financial_transaction.add_transaction! redirect_to finance_ordergroup_transactions_url(@ordergroup), :notice => "Die Transaktion wurde gespeichert." - rescue - render :action => :new + #rescue + # render :action => :new end def new_collection diff --git a/app/controllers/ordering_controller.rb b/app/controllers/group_orders_controller.rb similarity index 89% rename from app/controllers/ordering_controller.rb rename to app/controllers/group_orders_controller.rb index 5df56696..4b8811f4 100644 --- a/app/controllers/ordering_controller.rb +++ b/app/controllers/group_orders_controller.rb @@ -1,9 +1,10 @@ # Controller for all ordering-actions that are performed by a user who is member of an Ordergroup. # Management actions that require the "orders" role are handled by the OrdersController. -class OrderingController < ApplicationController +class GroupOrdersController < ApplicationController # Security before_filter :ensure_ordergroup_member before_filter :ensure_open_order, :only => [:new, :create, :edit, :update, :order, :stock_order, :saveOrder] + before_filter :ensure_my_group_order, only: [:show, :edit, :update] # Index page. def index @@ -28,17 +29,14 @@ class OrderingController < ApplicationController end def show - @group_order = GroupOrder.find(params[:id]) @order= @group_order.order end def edit - @group_order = GroupOrder.find(params[:id]) @ordering_data = @group_order.load_data end def update - @group_order = GroupOrder.find(params[:id]) @group_order.attributes = params[:group_order] begin @group_order.save_ordering! @@ -84,4 +82,10 @@ class OrderingController < ApplicationController end end + def ensure_my_group_order + @group_order = @ordergroup.group_orders.find(params[:id]) + rescue ActiveRecord::RecordNotFound + redirect_to group_orders_url, alert: 'Fehlerhafte URL, das ist nicht Deine Bestellung.' + end + end diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 82fd7c9a..eaffffcf 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -5,11 +5,12 @@ class LoginController < ApplicationController # Display the form to enter an email address requesting a token to set a new password. def forgot_password + @user = User.new end # Sends an email to a user with the token that allows setting a new password through action "password". def reset_password - if (user = User.find_by_email(params[:login][:email])) + if (user = User.find_by_email(params[:user][:email])) user.reset_password_token = user.new_random_password(16) user.reset_password_expires = Time.now.advance(:days => 2) if user.save diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 4ca5200b..a1f97797 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -14,9 +14,7 @@ class MessagesController < ApplicationController def create @message = @current_user.send_messages.new(params[:message]) if @message.save - #FIXME: Send Mails wit ID instead of using message.state ... - #call_rake :send_emails - @message.deliver + @message.deliver #TODO: Put this into a background job redirect_to messages_url, :notice => "Nachricht ist gespeichert und wird versendet." else render :action => 'new' diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 101bb203..945aee47 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -40,9 +40,9 @@ class TasksController < ApplicationController @task.save flash[:notice] = "Aufgabe wurde aktualisiert" if @task.workgroup - redirect_to :action => "workgroup", :id => @task.workgroup + redirect_to workgroup_tasks_url(workgroup_id: @task.workgroup_id) else - redirect_to :action => "index" + redirect_to tasks_url end else render :template => "tasks/edit" @@ -84,20 +84,9 @@ class TasksController < ApplicationController # shows workgroup (normal group) to edit weekly_tasks_template def workgroup - @group = Group.find(params[:id]) + @group = Group.find(params[:workgroup_id]) if @group.is_a? Ordergroup redirect_to tasks_url, :alert => "Keine Arbeitsgruppe gefunden" end end - - # this method is uses for the auto_complete-function from script.aculo.us - def auto_complete_for_task_user_list - @users = User.find( - :all, - :conditions => [ 'LOWER(nick) LIKE ?', '%' + params[:task][:user_list].downcase + '%' ], - :order => 'nick ASC', - :limit => 8 - ) - render :partial => '/shared/auto_complete_users' - end end diff --git a/app/helpers/ordering_helper.rb b/app/helpers/group_orders_helper.rb similarity index 97% rename from app/helpers/ordering_helper.rb rename to app/helpers/group_orders_helper.rb index f5c4cdc1..d1c40cc4 100644 --- a/app/helpers/ordering_helper.rb +++ b/app/helpers/group_orders_helper.rb @@ -1,4 +1,4 @@ -module OrderingHelper +module GroupOrdersHelper def data_to_js(ordering_data) ordering_data[:order_articles].map { |id, data| [id, data[:price], data[:unit], data[:total_price], data[:others_quantity], data[:others_tolerance], data[:used_quantity], data[:quantity_available]] diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index c6e12fd3..820fad2c 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -4,15 +4,15 @@ class Mailer < ActionMailer::Base layout 'email' # Use views/layouts/email.txt.erb - default from: "FoodSoft <#{Foodsoft.config[:email_sender]}>" + default from: "FoodSoft <#{Foodsoft.config[:email_sender]}>", + sender: Foodsoft.config[:email_sender], + errors_to: Foodsoft.config[:email_sender] # Sends an email copy of the given internal foodsoft message. def foodsoft_message(message, recipient) @message = message - mail sender: Foodsoft.config[:email_sender], - errors_to: Foodsoft.config[:email_sender], - subject: "[#{Foodsoft.config[:name]}] " + message.subject, + mail subject: "[#{Foodsoft.config[:name]}] " + message.subject, to: recipient.email, from: "#{message.sender.nick} <#{message.sender.email}>" end @@ -74,13 +74,12 @@ class Mailer < ActionMailer::Base :subject => "[Foodsoft] Feeback von #{user.email}" end - def not_enough_users_assigned(task,user) + def not_enough_users_assigned(task, user) @task = task @user = user - @task_url = url_for(:controller => "tasks", :action => "workgroup", :id => task.workgroup_id) - + mail :to => user.email, - :subject => "[#{Foodsoft.config[:name]}] #{task.name} braucht noch Leute!" + :subject => "[#{Foodsoft.config[:name]}] \"#{task.name}\" braucht noch Leute!" end end diff --git a/app/models/message.rb b/app/models/message.rb index 2cdb2549..1a4defed 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -68,12 +68,12 @@ class Message < ActiveRecord::Base end def deliver - for recipient in recipients - if recipient.settings['messages.sendAsEmail'] == "1" && !recipient.email.blank? + for user in recipients + if user.receive_email? begin - Mailer.foodsoft_message(self, recipient).deliver -# rescue -# logger.warn "Deliver failed for #{recipient.nick}: #{recipient.email}" + Mailer.foodsoft_message(self, user).deliver + rescue + logger.warn "Deliver failed for #{user.nick}: #{user.email}" end end end diff --git a/app/models/ordergroup.rb b/app/models/ordergroup.rb index b6498649..6999ff8a 100644 --- a/app/models/ordergroup.rb +++ b/app/models/ordergroup.rb @@ -48,7 +48,7 @@ class Ordergroup < Group self.account_balance = financial_transactions.sum('amount') self.account_updated = trans.created_on save! - notify_negative_balance(trans) + notify_negative_balance(trans) end end diff --git a/app/models/task.rb b/app/models/task.rb index 8c629435..90b3d686 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -13,6 +13,7 @@ class Task < ActiveRecord::Base validates :name, :presence => true, :length => { :minimum => 3 } validates :required_users, :presence => true validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 0 + validates_length_of :description, maximum: 250 after_save :update_ordergroup_stats diff --git a/app/models/user.rb b/app/models/user.rb index c7cd3bd2..adc785fe 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -72,6 +72,10 @@ class User < ActiveRecord::Base [first_name, last_name].join(" ") end + def receive_email? + settings['messages.sendAsEmail'] == "1" && email.present? + end + def ordergroup_name ordergroup.name if ordergroup end diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb index b5b570d2..5b201932 100644 --- a/app/models/workgroup.rb +++ b/app/models/workgroup.rb @@ -6,9 +6,10 @@ class Workgroup < Group has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC' validates_presence_of :task_name, :weekday, :task_required_users, :next_weekly_tasks_number, - :if => :weekly_task + :if => :weekly_task validates_numericality_of :next_weekly_tasks_number, :greater_than => 0, :less_than => 21, :only_integer => true, - :if => :weekly_task + :if => :weekly_task + validates_length_of :task_description, maximum: 250 validate :last_admin_on_earth, :on => :update before_destroy :check_last_admin_group diff --git a/app/views/finance/financial_transactions/new.html.haml b/app/views/finance/financial_transactions/new.html.haml index d675f91a..3fd7ae20 100644 --- a/app/views/finance/financial_transactions/new.html.haml +++ b/app/views/finance/financial_transactions/new.html.haml @@ -1,8 +1,10 @@ - title "Neue Transaktion" +%p Hier kannst du der Bestellgruppe #{@ordergroup.name} Geld gutschreiben/abziehen. + = simple_form_for @financial_transaction, :url => finance_ordergroup_transactions_path(@ordergroup), :validate => true do |f| - = f.association :ordergroup + = f.hidden_field :ordergroup_id = f.input :amount = f.input :note, :as => :text = f.submit diff --git a/app/views/foodcoop/workgroups/_workgroup.html.haml b/app/views/foodcoop/workgroups/_workgroup.html.haml index 8f060606..72b7c011 100644 --- a/app/views/foodcoop/workgroups/_workgroup.html.haml +++ b/app/views/foodcoop/workgroups/_workgroup.html.haml @@ -4,7 +4,7 @@ .column_content = render :partial => 'shared/group', :locals => { :group => workgroup } %p - = link_to "Alle Aufgaben zeigen", :controller => "/tasks", :action => "workgroup", :id => workgroup + = link_to "Alle Aufgaben zeigen", workgroup_tasks_path(workgroup_id: workgroup) | = link_to "Mitgliedern eine Nachricht schicken", new_message_path(:message => {:group_id => workgroup.id}) - if workgroup.member?(@current_user) diff --git a/app/views/ordering/_form.html.haml b/app/views/group_orders/_form.html.haml similarity index 99% rename from app/views/ordering/_form.html.haml rename to app/views/group_orders/_form.html.haml index cc1332fb..eb7aca4b 100644 --- a/app/views/ordering/_form.html.haml +++ b/app/views/group_orders/_form.html.haml @@ -147,6 +147,6 @@ € #order-button = submit_tag( "Bestellung speichern", :id => 'submit_button' ) - oder #{link_to "abbrechen", :controller => 'ordering'} + oder #{link_to "abbrechen", group_orders_path} %input#total_balance{:name => "total_balance", :type => "hidden", :value => @ordergroup.account_balance - @group_order.price}/ %input{:name => "version", :type => "hidden", :value => @version}/ \ No newline at end of file diff --git a/app/views/ordering/_orders.html.haml b/app/views/group_orders/_orders.html.haml similarity index 85% rename from app/views/ordering/_orders.html.haml rename to app/views/group_orders/_orders.html.haml index 82970631..70d14b1a 100644 --- a/app/views/ordering/_orders.html.haml +++ b/app/views/group_orders/_orders.html.haml @@ -11,7 +11,7 @@ - group_order = order.group_order(@ordergroup) # Get GroupOrder if possible - order_class = group_order ? "" : "color:grey" %tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class} - %td= link_to order.name, :action => 'my_order_result', :id => order + %td= group_order.present? ? link_to(order.name, group_order_path(group_order)) : order.name %td= format_time(order.ends) %td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--" \ No newline at end of file diff --git a/app/views/ordering/_switch_order.html.haml b/app/views/group_orders/_switch_order.html.haml similarity index 100% rename from app/views/ordering/_switch_order.html.haml rename to app/views/group_orders/_switch_order.html.haml diff --git a/app/views/ordering/archive.html.haml b/app/views/group_orders/archive.html.haml similarity index 89% rename from app/views/ordering/archive.html.haml rename to app/views/group_orders/archive.html.haml index f3193129..f3426c84 100644 --- a/app/views/ordering/archive.html.haml +++ b/app/views/group_orders/archive.html.haml @@ -1,7 +1,7 @@ - title "Bestellungen der #{@ordergroup.name}" %p Siehe hier alle - = link_to "laufenden Bestellungen.", ordering_path + = link_to "laufenden Bestellungen.", group_orders_path .single_column{:style => "width:50em"} .box_title diff --git a/app/views/ordering/edit.html.haml b/app/views/group_orders/edit.html.haml similarity index 100% rename from app/views/ordering/edit.html.haml rename to app/views/group_orders/edit.html.haml diff --git a/app/views/ordering/index.html.haml b/app/views/group_orders/index.html.haml similarity index 100% rename from app/views/ordering/index.html.haml rename to app/views/group_orders/index.html.haml diff --git a/app/views/ordering/new.html.haml b/app/views/group_orders/new.html.haml similarity index 100% rename from app/views/ordering/new.html.haml rename to app/views/group_orders/new.html.haml diff --git a/app/views/ordering/order.html.haml b/app/views/group_orders/order.html.haml similarity index 100% rename from app/views/ordering/order.html.haml rename to app/views/group_orders/order.html.haml diff --git a/app/views/ordering/show.html.haml b/app/views/group_orders/show.html.haml similarity index 100% rename from app/views/ordering/show.html.haml rename to app/views/group_orders/show.html.haml diff --git a/app/views/home/_start_nav.haml b/app/views/home/_start_nav.haml index 789a0c4b..5a45a8b9 100644 --- a/app/views/home/_start_nav.haml +++ b/app/views/home/_start_nav.haml @@ -15,7 +15,7 @@ Bestellungen %ul - if has_ordergroup - %li= link_to "Bestellübersicht", :controller => "ordering" + %li= link_to "Bestellübersicht", group_orders_path - if has_orders_role %li= link_to "Bestellungen beenden", :controller => 'orders' // Articles diff --git a/app/views/layouts/_main_tabnav.html.erb b/app/views/layouts/_main_tabnav.html.erb index d109256f..bb6924de 100644 --- a/app/views/layouts/_main_tabnav.html.erb +++ b/app/views/layouts/_main_tabnav.html.erb @@ -24,10 +24,10 @@ { :name => "Alle Seiten", :url => all_pages_path } ] }, - { :name => "Bestellungen", :url => u.ordergroup ? ordering_path : orders_path, + { :name => "Bestellungen", :url => u.ordergroup ? group_orders_path : orders_path, :active => ["orders", "ordering"], :subnav => [ - { :name => "Bestellen!", :url => ordering_path }, + { :name => "Bestellen!", :url => group_orders_path }, { :name => "Meine Bestellungen", :url => archive_group_orders_path }, { :name => "Bestellverwaltung", :url => orders_path, :access_denied? => (!u.role_orders?) } ] diff --git a/app/views/login/forgot_password.html.haml b/app/views/login/forgot_password.html.haml index 4515a8d5..0419169a 100644 --- a/app/views/login/forgot_password.html.haml +++ b/app/views/login/forgot_password.html.haml @@ -5,12 +5,7 @@ Dazu musst hier die E-Mail-Adresse eingeben, mit der Du in der FoodSoft angemeldet bist. Du erhälst dann eine E-Mail mit weiteren Instruktionen. -.edit_form{:style => "width:25em"} - - form_tag(:action => 'reset_password') do - %p - E-Mail: - %br/ - = text_field 'login', 'email' - = submit_tag 'Neues Passwort anfordern' - | - = link_to 'Abbrechen', login_path += simple_form_for User.new, url: {action: 'reset_password'} do |form| + = form.input :email + = form.submit "Neues Passwort anfordern" + = link_to "Abbrechen", :back \ No newline at end of file diff --git a/app/views/login/password.html.haml b/app/views/login/password.html.haml index b83e435a..3b6b7ceb 100644 --- a/app/views/login/password.html.haml +++ b/app/views/login/password.html.haml @@ -1,16 +1,6 @@ - title "Neues Passwort" %p=h "Bitte neues Passwort für #{@user.nick} eingeben." -.edit_form{:style => "width:25em"} - - form_for @user, :url => {:action => 'update_password', :id => @user.id, :token => @user.reset_password_token} do |form| - = form.error_messages :header_message => "" - %p - Neues Passwort - %br/ - = form.password_field :password - %p - Passwort wiederholen - %br/ - = form.password_field :password_confirmation - = form.submit 'Speichern' - | - = link_to 'Abbrechen', login_path += simple_form_for @user, :url => {:action => 'update_password', :id => @user.id, :token => @user.reset_password_token} do |form| + = form.input :password + = form.input :password_confirmation + = form.submit \ No newline at end of file diff --git a/app/views/mailer/feedback.erb b/app/views/mailer/feedback.text.erb similarity index 100% rename from app/views/mailer/feedback.erb rename to app/views/mailer/feedback.text.erb diff --git a/app/views/mailer/foodsoft_message.text.erb b/app/views/mailer/foodsoft_message.text.erb index fbeae93e..9dc136f0 100644 --- a/app/views/mailer/foodsoft_message.text.erb +++ b/app/views/mailer/foodsoft_message.text.erb @@ -1,9 +1,3 @@ -Foodsoft-Nachricht - -Von: <%= @message.sender.nick %> - -====================================================================== - <%= @message.body %> ====================================================================== diff --git a/app/views/mailer/invite.html.erb b/app/views/mailer/invite.text.erb similarity index 78% rename from app/views/mailer/invite.html.erb rename to app/views/mailer/invite.text.erb index 25143e9d..0eecc686 100644 --- a/app/views/mailer/invite.html.erb +++ b/app/views/mailer/invite.text.erb @@ -2,7 +2,7 @@ Hallo! <%= @invite.user.first_name %> <%= @invite.user.last_name %> (<%= @invite.user.email %>) hat dich in die Gruppe "<%= @invite.group.name %>" eingeladen. Um die Einladung anzunehmen und der Foodcoop beizutreten, gehe zu: <%= @link %> -Dieser Link kann nur einmal aufgerufen werden und ist nur bis <%= @invite.expires_at.strftime('%A den %d.%m.%Y um %H:%M') %> gültig. +Dieser Link kann nur einmal aufgerufen werden und ist nur bis <%= I18n.l @invite.expires_at %> gültig. Grüße sendet die Foodsoft! @@ -12,6 +12,6 @@ Hi! <%= @invite.user.first_name %> <%= @invite.user.last_name %> (<%= @invite.user.email %>) has invited you to join the group "<%= @invite.group.name %>". To accept the invitation and to join the foodcoop please follow this link: <%= @link %> -This link works only once and expires on <%= @invite.expires_at.strftime('%A den %d.%m.%Y um %H:%M') %>. +This link works only once and expires on <%= I18n.l @invite.expires_at, locale: :en %>. Greetings, your FoodSoft Team! diff --git a/app/views/mailer/negative_balance.html.erb b/app/views/mailer/negative_balance.text.erb similarity index 100% rename from app/views/mailer/negative_balance.html.erb rename to app/views/mailer/negative_balance.text.erb diff --git a/app/views/mailer/not_enough_users_assigned.erb b/app/views/mailer/not_enough_users_assigned.erb deleted file mode 100644 index c85dd912..00000000 --- a/app/views/mailer/not_enough_users_assigned.erb +++ /dev/null @@ -1,11 +0,0 @@ -Liebe(r) <%= @user.first_name %>, - -Der Job <%= @task.name -%> Deiner Arbeitsgruppe ist am <%= @task.due_date.strftime("%d. %b") -%> fällig -und es fehlen noch Mitstreiterinnen! - -Sofern Du Dich noch nicht für diese Aufgabe eingetragen hast ist das jetzt die Chance: - <%= @task_url %> - --- -Deine Aufgaben: <%= url_for(:controller => "home", :actions => "user") %> - diff --git a/app/views/mailer/not_enough_users_assigned.text.erb b/app/views/mailer/not_enough_users_assigned.text.erb new file mode 100644 index 00000000..c08ffc97 --- /dev/null +++ b/app/views/mailer/not_enough_users_assigned.text.erb @@ -0,0 +1,11 @@ +Liebe(r) <%= @user.first_name %>, + +Der Job '<%= @task.name -%>' Deiner Arbeitsgruppe ist am <%= I18n.l @task.due_date, format: "%d. %b" %> fällig +und es fehlen noch Mitstreiterinnen! + +Sofern Du Dich noch nicht für diese Aufgabe eingetragen hast ist das jetzt die Chance: + <%= workgroup_tasks_url(workgroup_id: task.workgroup_id) %> + +-- +Deine Aufgaben: <%= user_tasks_url %> + diff --git a/app/views/mailer/order_result.html.erb b/app/views/mailer/order_result.text.erb similarity index 65% rename from app/views/mailer/order_result.html.erb rename to app/views/mailer/order_result.text.erb index 6381856f..ce03bcea 100644 --- a/app/views/mailer/order_result.html.erb +++ b/app/views/mailer/order_result.text.erb @@ -1,6 +1,6 @@ Liebe <%= @group_order.ordergroup.name %>, -die Bestellung für "<%= @order.name %>" wurde am <%= @order.ends.strftime('%d.%m.%Y um %H:%M') %> von <%= @order.updated_by.nick %> beendet. +die Bestellung für "<%= @order.name %>" wurde am <%= I18n.l @order.ends %> von <%= @order.updated_by.nick %> beendet. Für Euch wurden die folgenden Artikel bestellt: <% for group_order_article in @group_order.group_order_articles.ordered.all(:include => :order_article) @@ -9,6 +9,6 @@ Für Euch wurden die folgenden Artikel bestellt: <% end -%> Gesamtpreis: <%= @group_order.price %> -Bestellung online einsehen: <%= url_for(:controller => "ordering", :action => "my_order_result", :id => @order.id) %> +Bestellung online einsehen: <%= group_order_url(@group_order) %> Viele Grüße von <%= Foodsoft.config[:name] %> \ No newline at end of file diff --git a/app/views/mailer/reset_password.html.erb b/app/views/mailer/reset_password.text.erb similarity index 80% rename from app/views/mailer/reset_password.html.erb rename to app/views/mailer/reset_password.text.erb index 6f83c130..d49b528f 100644 --- a/app/views/mailer/reset_password.html.erb +++ b/app/views/mailer/reset_password.text.erb @@ -2,7 +2,7 @@ Hallo <%= @user.nick %>, du (oder jemand anderes) hat auf der FoodSoft-Website ein neues Passwort angefordert. Um ein neues Passwort einzugeben, gehe zu: <%= @link %> -Dieser Link kann nur einmal aufgerufen werden und läuft am <%= @user.reset_password_expires.strftime('%A (%d.%m.%Y %H:%M)') %> ab. +Dieser Link kann nur einmal aufgerufen werden und läuft am <%= I18n.l @user.reset_password_expires %> ab. Wenn du das Passwort nicht ändern möchtest oder diese Email nicht ausgelöst hast, brauchst du nichts zu tun. Dein bisheriges Passwort wurde nicht geändert. Grüße sendet die Foodsoft! :) @@ -12,7 +12,7 @@ Grüße sendet die Foodsoft! :) Hi <%= @user.nick %>, you have (or someone else has) requested a new password. In order to choose a new password follow this link: <%= @link %> -This link works only once and expires on <%= @user.reset_password_expires.strftime('%A (%d.%m.%Y %H:%M)') %>. +This link works only once and expires on <%= I18n.l @user.reset_password_expires, locale: :en %>. If you don't want to change your password, just ignore this message. Your password hasn't been changed yet. Greetings, your FoodSoft Team! diff --git a/app/views/mailer/upcoming_tasks.html.erb b/app/views/mailer/upcoming_tasks.html.erb deleted file mode 100644 index cadeddf5..00000000 --- a/app/views/mailer/upcoming_tasks.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -Liebe(r) <%= @user.name %>, - -Du bist für "<%= @task.name -%>" eingetragen. Die Aufgabe ist morgen (<%= @task.due_date.strftime("%d. %b") -%>) fällig! - -<% if @user.next_tasks.size > 1 -%> -Aufgaben für die nächste Woche: - <% for next_task in @user.next_tasks -%> - <% unless next_task == @task -%> -* <%= next_task.due_date.strftime("%d.%m.") -%> <%= next_task.name %> - <% end -%> - <% end -%> -<% end -%> - -Meine Aufgaben: <%= url_for(:controller => "home", :actions => "user") %> - -Viele Grüße von <%= Foodsoft.config[:name] %> \ No newline at end of file diff --git a/app/views/mailer/upcoming_tasks.text.erb b/app/views/mailer/upcoming_tasks.text.erb new file mode 100644 index 00000000..b2349a25 --- /dev/null +++ b/app/views/mailer/upcoming_tasks.text.erb @@ -0,0 +1,15 @@ +Liebe(r) <%= @user.name %>, + +Du bist für "<%= @task.name -%>" eingetragen. Die Aufgabe ist morgen (<%= I18n.l @task.due_date, format: "%d. %b" %>) fällig! + +<% if @user.next_tasks.size > 0 %> +Aufgaben für die nächste Woche: + <% for next_task in @user.next_tasks -%> + <% next if next_task == @task -%> +* <%= I18n.l next_task.due_date, format: "%d. %b" -%> <%= next_task.name %> + <% end -%> +<% end -%> + +Meine Aufgaben: <%= user_tasks_url %> + +Viele Grüße von <%= Foodsoft.config[:name] %> \ No newline at end of file diff --git a/app/views/shared/_group_form_fields.html.haml b/app/views/shared/_group_form_fields.html.haml index 670bde91..b12e2379 100644 --- a/app/views/shared/_group_form_fields.html.haml +++ b/app/views/shared/_group_form_fields.html.haml @@ -11,7 +11,7 @@ = f.input :task_name = f.input :task_required_users = f.input :task_duration, :as => :select, :collection => (1..3) - = f.input :task_description + = f.input :task_description, as: :text, input_html: {rows: 10} = f.input :next_weekly_tasks_number = f.input :user_tokens, :as => :string, :input_html => { 'data-pre' => f.object.users.map { |u| u.token_attributes }.to_json } diff --git a/app/views/tasks/_form.html.haml b/app/views/tasks/_form.html.haml index 2ac7d9b6..7f16c69a 100644 --- a/app/views/tasks/_form.html.haml +++ b/app/views/tasks/_form.html.haml @@ -12,7 +12,7 @@ = simple_form_for @task do |f| = f.input :name - = f.input :description + = f.input :description, as: :text, input_html: {rows: 10} = f.input :duration, :as => :select, :collection => 1..3 = f.input :user_list, :as => :string, :input_html => { 'data-pre' => @task.users.map { |u| u.token_attributes }.to_json } = f.input :required_users diff --git a/app/views/tasks/_nav.haml b/app/views/tasks/_nav.haml index 24d8d263..3f3e13d7 100644 --- a/app/views/tasks/_nav.haml +++ b/app/views/tasks/_nav.haml @@ -16,4 +16,4 @@ Gruppenaufgaben %ul - for group in Workgroup.all - %li= link_to group.name, :controller => 'tasks', :action => "workgroup", :id => group \ No newline at end of file + %li= link_to group.name, workgroup_tasks_path(workgroup_id: group.id) \ No newline at end of file diff --git a/app/views/tasks/show.haml b/app/views/tasks/show.haml index a1569ee7..64aac846 100644 --- a/app/views/tasks/show.haml +++ b/app/views/tasks/show.haml @@ -23,7 +23,7 @@ %td Arbeitsgruppe %td - if @task.workgroup - = link_to @task.workgroup.name, :action => "workgroup", :id => @task.workgroup + = link_to @task.workgroup.name, workgroup_tasks_path(workgroup_id: @task.workgroup_id) %tr %td{:colspan => "2"} diff --git a/app/views/tasks/workgroup.haml b/app/views/tasks/workgroup.haml index a3de1603..5d74b50e 100644 --- a/app/views/tasks/workgroup.haml +++ b/app/views/tasks/workgroup.haml @@ -8,7 +8,7 @@ %h2 Wöchentliche Aufgaben verwalten .column_content - if @group.weekly_task - %p= "Jeden #{weekday(@group.weekday)} hat diese Arbeitsgruppe folgenden Job: #{@group.task_name}" + %p Jeden #{weekday(@group.weekday)} hat diese Arbeitsgruppe folgenden Job: #{@group.task_name} %p Die Wochenaufgaben werden von der Foodsoft automatisch erstellt. Eintragen müsst Ihr Euch aber selber. - else Noch keine Wochenaufgaben angelegt. diff --git a/config/routes.rb b/config/routes.rb index cc9d2f7a..9e6dd7ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,10 +44,9 @@ Foodsoft::Application.routes.draw do end end - resources :group_orders, :controller => 'ordering', :path => 'ordering' do + resources :group_orders do get :archive, :on => :collection end - match '/ordering' => 'ordering#index', :as => 'ordering' resources :order_comments, :only => [:new, :create]