Description:
Implement list_all action for message console
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r357:686426417ab0 - - 2 files changed: 8 inserted, 2 deleted

@@ -1,36 +1,41
1 1 class MessagesController < ApplicationController
2 2
3 3 before_filter :authenticate
4 4
5 5 verify :method => :post, :only => ['create'],
6 6 :redirect_to => { :action => 'list' }
7 7
8 8 before_filter :admin_authorization, :only => ['console','show',
9 - 'reply','hide']
9 + 'reply','hide','list_all']
10 10
11 11 def list
12 12 @user = User.find(session[:user_id])
13 13 @messages = Message.find_all_sent_by_user(@user)
14 14 end
15 15
16 16 def console
17 17 @user = User.find(session[:user_id])
18 18 @messages = Message.find_all_system_unreplied_messages
19 19 end
20 20
21 21 def show
22 22 @message = Message.find(params[:id])
23 23 end
24 24
25 + def list_all
26 + @user = User.find(session[:user_id])
27 + @messages = Message.where(receiver_id: nil).order(:created_at)
28 + end
29 +
25 30 def create
26 31 user = User.find(session[:user_id])
27 32 @message = Message.new(params[:message])
28 33 @message.sender = user
29 34 if !@message.save
30 35 render :action => 'list' and return
31 36 else
32 37 flash[:notice] = 'New message posted'
33 38 redirect_to :action => 'list'
34 39 end
35 40 end
36 41
@@ -1,11 +1,12
1 1 %tr
2 2 - if short_message.sender
3 3 %td=h short_message.sender.full_name
4 4 - else
5 5 %td (user deleted)
6 6 %td= "#{short_message.created_at}"
7 7 %td=h truncate(short_message.body)
8 8 %td
9 9 - if short_message.sender
10 10 = link_to "[reply]", :action => 'show', :id => short_message.id
11 - = link_to "[hide]", :action => 'hide', :id => short_message.id
11 + - if params[:action] != 'list_all'
12 + = link_to "[hide]", :action => 'hide', :id => short_message.id
You need to be logged in to leave comments. Login now