Added possibility to give feedbacks via ajax form. Closes #2

* Feedback message will send to error_recipients, configured in app_config.yml
This commit is contained in:
Benjamin Meichsner 2009-08-04 15:22:11 +02:00
parent b84ec884bd
commit c7e37fc7b2
12 changed files with 66 additions and 7 deletions

View file

@ -0,0 +1,20 @@
class FeedbackController < ApplicationController
def new
render :update do |page|
page.replace_html :ajax_box, :partial => "new"
page.show :ajax_box
end
end
def create
unless params[:message].blank?
Mailer.deliver_feedback(current_user, params[:message])
end
render :update do |page|
page.replace_html :ajax_box, :partial => "success"
end
end
end

View file

@ -58,6 +58,15 @@ class Mailer < ActionMailer::Base
:transaction => transaction
end
def feedback(user, message)
subject "[Foodsoft] Feeback von #{user.email}"
recipients Foodsoft.config[:notification]["error_recipients"]
from "#{user.nick} <#{user.email}>"
headers 'Sender' => Foodsoft.config[:notification]["sender_address"],
'Errors-To' => Foodsoft.config[:notification]["sender_address"]
body :user => user, :message => message
end
protected
def prepare_system_message(recipient)

View file

@ -0,0 +1,8 @@
%h2 Fehler gefunden? Vorschlag? Idee? Kritik?
- form_remote_tag :url => {:action => "create"}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do
%p
= text_area_tag :message, nil, :size => "40x15"
= submit_tag "Absenden"
oder
= link_to_function "Abbrechen", "Element.hide('ajax_box')"

View file

@ -0,0 +1,4 @@
%h2 Nachricht wurde verschickt!
%p Vielen Dank, Deine Nachricht wurde soeben dem Foodcooft Team zugestellt.
%p= link_to_function "Schließen", "Element.hide('ajax_box')"

View file

@ -23,6 +23,7 @@
%span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= Foodsoft.config[:name]
#nav= render :partial => 'layouts/main_tabnav'
#ajax_box(style="display:none")
#main
#content
- if flash[:notice]

View file

@ -0,0 +1,3 @@
<%= @user.nick %> schrieb am <%= I18n.l Time.now, :format => :short %>:
<%= @message %>

View file

@ -1,8 +1,10 @@
%ul
%li
= image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => _("User")
= link_to h(@current_user.nick), my_profile_path, { :title => _("User Settings") }
= image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => "Profil"
= link_to h(@current_user.nick), my_profile_path, { :title => "Profil bearbeiten" }
- if Foodsoft.config[:homepage]
%li= link_to Foodsoft.config[:name], Foodsoft.config[:homepage], { :title => _("Go to your FoodCoop-Hompage") }
%li= link_to _("Hilfe"), 'http://dev.foodcoops.net/wiki/FoodsoftDoku'
%li= link_to _("Logout"), :controller => '/login', :action => 'logout'
%li= link_to "Hilfe", 'http://dev.foodcoops.net/wiki/FoodsoftDoku'
%li= link_to_remote "Feedback", :url => {:controller => "/feedback", :action => "new"}, |
:method => :get, :html => {:title => "Fehler gefunden? Vorschlag? Idee? Kritik?"} |
%li= link_to "Abmelden", logout_path

View file

@ -295,7 +295,7 @@ div.edit_form {
margin: 5px 0;
color: black; }
#edit_article, #edit_box {
#edit_article, #edit_box, #ajax_box {
position: fixed;
top: 5em;
left: 10em;

View file

@ -295,7 +295,7 @@ div.edit_form {
margin: 5px 0;
color: black; }
#edit_article, #edit_box {
#edit_article, #edit_box, #ajax_box {
position: fixed;
top: 5em;
left: 10em;

View file

@ -322,7 +322,7 @@ div.edit_form
:margin 5px 0
:color black
#edit_article, #edit_box
#edit_article, #edit_box, #ajax_box
:position fixed
:top 5em
:left 10em

View file

@ -0,0 +1,8 @@
require 'test_helper'
class FeebackControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View file

@ -0,0 +1,4 @@
require 'test_helper'
class FeebackHelperTest < ActionView::TestCase
end