aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2013-02-24 01:09:33 +0100
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2013-02-24 17:20:20 +0100
commit84ab328690a800962d59a44e59e5aa214b2920c9 (patch)
tree986ebe970e592d9d3f98909cf76db8bc3f077ce7 /app
parentb1991493127376655516ccced62a403ae84c3012 (diff)
downloadecs2-84ab328690a800962d59a44e59e5aa214b2920c9.tar.gz
ecs2-84ab328690a800962d59a44e59e5aa214b2920c9.zip
Touching "updated_at" attribute of initial event.
If there is already a pending event describing a change of a message, don't create another one. Instead only touch the "updated_at" attribute of the event. In the participant show page there is now the "updated_at" time of the event showed.
Diffstat (limited to 'app')
-rw-r--r--app/models/event.rb12
-rw-r--r--app/views/admin/participants/show.html.haml2
2 files changed, 12 insertions, 2 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 1879241..b77ad9f 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -49,12 +49,22 @@ private
if unique?(event) and event.save
event
else
+ # There is already a pending event describing a change of the
+ # message. So don't create another one. Instead only touch the
+ # "updated_at" attribute of the event.
+ iev= initial_event(event.participant_id, event.message_id, event.ev_type_id)
+ iev.updated_at= Time.now.to_s(:db)
+ iev.save
nil
end
end
def self.unique?(event)
- Event.find_by_participant_id_and_message_id_and_ev_type_id(event.participant_id, event.message_id, event.ev_type_id).blank?
+ initial_event(event.participant_id, event.message_id, event.ev_type_id).blank?
+ end
+
+ def self.initial_event(participant_id, msg_id, event_type_id)
+ Event.find_by_participant_id_and_message_id_and_ev_type_id(participant_id, msg_id, event_type_id)
end
end
diff --git a/app/views/admin/participants/show.html.haml b/app/views/admin/participants/show.html.haml
index 241d0ea..c81b93b 100644
--- a/app/views/admin/participants/show.html.haml
+++ b/app/views/admin/participants/show.html.haml
@@ -108,7 +108,7 @@
%td= event.id
%td= event.message.id
%td= event.ev_type.name
- %td= event.created_at
+ %td= event.updated_at
- unless (messages = Message.for_participant_receiver(@participant).for_not_removed.uniq).blank?
%p