Complete refactoring of messaging module. From now messages are saved only once and send afterwards via a the 'send_emails'-rake-task.

This commit is contained in:
Benjamin Meichsner 2009-01-15 18:26:37 +01:00
parent 6ce6c2c75a
commit e8d55e50c0
30 changed files with 220 additions and 349 deletions

View file

@ -1,26 +0,0 @@
- unless @messages.empty?
- form_tag :action => 'destroy' do
%table.list
%thead
%tr
%th
%input{:type => 'checkbox', :name => 'checkall', :id => 'checkall', :onclick => 'checkUncheckAll(this)'}
%th Betreff
%th Absender
%th Datum
%th
%tbody
- for message in @messages
- style = message.read? ? '' : 'font-weight:bold'
%tr{:class => cycle('even','odd', :name => 'inbox'), :style => style, :id => message.id, :onclick => "checkRow('#{message.id}')"}
%td
%input{:type => 'checkbox', :name => 'ids[]', :id => "checkbox_#{message.id}", :value => message.id, :onclick => "checkRow('#{message.id}')"}
%td= link_to(h(message.subject), {:controller => 'messages', :action => 'show', :id => message})
%td= message.sender ? h(message.sender.nick) : 'FoodSoft'
%td= format_time(message.created_on)
%td
= link_to(image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'löschen'), {:controller => 'messages', :action => 'destroy', :id => message}, :method => "post")
= link_to('Antworten', :controller => 'messages', :action => 'reply', :id => message) unless message.system_message?
%tr
%td{:colspan => 5}= submit_tag 'Löschen'

View file

@ -0,0 +1,12 @@
- unless @messages.empty?
- form_tag :action => 'destroy' do
%table.list
%tbody
- for message in @messages
%tr{:class => cycle('even','odd', :name => 'messages')}
%td
%b= h(message.sender_name)
%td= format_subject(message)
%td= format_time(message.created_at)
%td= link_to('Antworten', reply_message_path(message))

View file

@ -1,15 +0,0 @@
- unless @messages.empty?
%table.list
%thead
%tr
%th Betreff
%th Absender
%th Datum
%tbody
- for message in @messages
%tr{:class => cycle('even','odd', :name => 'inbox')}
%td= link_to(h(message.subject), {:controller => 'messages', :action => 'show', :id => message})
%td= message.sender ? h(message.sender.nick) : 'FoodSoft'
%td= format_time(message.created_on)

View file

@ -1,5 +0,0 @@
%h1 Nachrichten - Eingang
%p= link_to('Neue Nachricht', :action => 'new')
= render :partial => 'list'

View file

@ -0,0 +1,6 @@
- title "Nachrichten im Überblick"
%p= link_to('Neue Nachricht', :action => 'new')
#messages
= render :partial => 'messages'

View file

@ -1,6 +1,6 @@
Hallo <%= user.nick %>!
Liebe <%= group.name %>,
Der Kontostand deiner Bestellgruppe <%= group.name %> ist durch eine Buchung am <%= transaction.created_on.strftime('%d.%m.%Y um %H:%M') %> ins Minus gerutscht: <%= group.account_balance %>
euer Kontostand ist durch eine Buchung am <%= transaction.created_on.strftime('%d.%m.%Y um %H:%M') %> ins Minus gerutscht: <%= group.account_balance %>
Es wurden <%= transaction.amount %> für "<%= transaction.note %>" abgebucht, die Buchung wurde von <%= transaction.user.nick %> erstellt.

View file

@ -1,23 +1,20 @@
%h1 Neue Nachricht
- form_tag(:action => 'create') do
= error_messages_for 'message'
- form_for @message do |f|
= f.error_messages
%p
%label{:for => "message_recipient"} An
%fieldset
<input type="checkbox" name="everyone" value="yes"
= "checked='checked'" if @everyone
onchange="Element.toggle('recipients')" />
= f.check_box :sent_to_all, :onchange => "Element.toggle('recipients')"
gesamte Foodcoop
%table{:id => 'recipients', :style => (@everyone ? 'display:none;' : '')}
%table#recipients
%tr
%td
%b BenutzerInnen:
%br/
%small{:style => "color:grey"} (Mehrere Benutzerinnen mit Komma trennen)
%br/
= text_field_with_auto_complete(:recipient, :nicks, {:value => @recipient_nicks}, {:tokens => ","})
= text_field_with_auto_complete(:message, :recipients_nicks, {:value => @message.recipients_nicks}, {:tokens => ","})
:javascript
var userListLoaded = false;
function checkUserList() {
@ -27,23 +24,21 @@
return !userListLoaded;
}
= link_to_remote('Liste', :update => 'user-list', :url => {:action => 'user_list'}, :complete => 'userListLoaded = true', :condition => 'checkUserList()')
%div{:id => 'user-list', :class => 'auto_complete'}
#user-list.auto_complete
%tr
%td
%b Gruppe:
%br/
%select{:name => 'recipient[group_id]'}
%option{:value => '-1'} -- Gruppe --
= options_from_collection_for_select(Group.find(:all, :order => 'name', :include => :memberships).reject{|g| g.memberships.empty?}, "id", "name", (@group ? @group.id : nil))
= f.select :group_id, groups_for_select, :prompt => " -- Gruppe auswählen --"
%p
%label{:for => "message_subject"} Betreff
= f.label :subject, "Betreff"
%br/
= text_field 'message', 'subject'
= f.text_field :subject
%p
%label{:for => "message_body"} Nachricht
= f.label :body, "Nachricht"
%br/
= preserve(text_area 'message', 'body', :cols => '80', :rows => '20')
~ f.text_area :body, :cols => '80', :rows => '20'
= submit_tag "Senden"

View file

@ -1,8 +1,8 @@
Hallo <%= user.nick %>!
Liebe <%= group.name %>,
Die Bestellung "<%= order.name %>" wurde am <%= order.ends.strftime('%d.%m.%Y um %H:%M') %> von <%= order.updated_by.nick %> beendet.
die Bestellung "<%= order.name %>" wurde am <%= order.ends.strftime('%d.%m.%Y um %H:%M') %> von <%= order.updated_by.nick %> beendet.
Für deine Bestellgruppe <%= group.name %> wurden die folgenden Artikel bestellt:
Für Euch wurden die folgenden Artikel bestellt:
<% for result in results
article = result.order_article_result -%>
<%= article.name %>: <%= result.quantity %> x <%= article.unit %> = <%= result.quantity * article.gross_price %>

View file

@ -1,28 +1,21 @@
%h1 Nachricht anzeigen
- title "Nachricht anzeigen"
%div{:style => "width:40em"}
- if @message
%table{:style => "width:25em"}
%tr
%td Von:
%td=h @message.system_message? ? 'FoodSoft' : @message.sender.nick
%tr
%td An:
%td=h @message.recipients
%tr
%td Betreff:
%td
%b=h @message.subject
%tr
%td Gesendet:
%td= format_time(@message.created_on)
%hr/
%p= simple_format(h(@message.body))
%hr/
%p
= link_to('Antworten', :action => 'reply', :id => @message) + ' | ' unless @message.system_message?
= link_to('Löschen', {:action => 'destroy', :id => @message}, :method => "post")
|
= link_to 'Nachrichteneingang', :action => 'inbox'
- else
%p Nachricht kann nicht angezeigt werden.
%table{:style => "width:25em"}
%tr
%td Von:
%td=h @message.sender_name
%tr
%td Betreff:
%td
%b=h @message.subject
%tr
%td Gesendet:
%td= format_time(@message.created_at)
%hr/
%p= simple_format(h(@message.body))
%hr/
%p
= link_to('Antworten', reply_message_path(@message))
|
= link_to 'Nachricht im Überblick', messages_path