Description:
added message hiding for admin in msg console
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@371 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r173:d8e86bba9b6f - - 3 files changed: 18 inserted, 1 deleted
@@ -1,20 +1,21 | |||||
|
1 | class MessagesController < ApplicationController |
|
1 | class MessagesController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :authenticate |
|
3 | before_filter :authenticate |
|
4 |
|
4 | ||
|
5 | verify :method => :post, :only => ['create'], |
|
5 | verify :method => :post, :only => ['create'], |
|
6 | :redirect_to => { :action => 'list' } |
|
6 | :redirect_to => { :action => 'list' } |
|
7 |
|
7 | ||
|
8 |
- before_filter :admin_authorization, :only => ['console','show', |
|
8 | + before_filter :admin_authorization, :only => ['console','show', |
|
|
9 | + 'reply','hide'] | ||
|
9 |
|
10 | ||
|
10 | def list |
|
11 | def list |
|
11 | @user = User.find(session[:user_id]) |
|
12 | @user = User.find(session[:user_id]) |
|
12 | @messages = Message.find_all_sent_by_user(@user) |
|
13 | @messages = Message.find_all_sent_by_user(@user) |
|
13 | end |
|
14 | end |
|
14 |
|
15 | ||
|
15 | def console |
|
16 | def console |
|
16 | @user = User.find(session[:user_id]) |
|
17 | @user = User.find(session[:user_id]) |
|
17 | @messages = Message.find_all_system_unreplied_messages |
|
18 | @messages = Message.find_all_system_unreplied_messages |
|
18 | end |
|
19 | end |
|
19 |
|
20 | ||
|
20 | def show |
|
21 | def show |
@@ -39,24 +40,32 | |||||
|
39 | @message.sender = user |
|
40 | @message.sender = user |
|
40 | if !@message.save |
|
41 | if !@message.save |
|
41 | render :action => 'show' and return |
|
42 | render :action => 'show' and return |
|
42 | else |
|
43 | else |
|
43 | flash[:notice] = 'Message replied' |
|
44 | flash[:notice] = 'Message replied' |
|
44 | rep_msg = @message.replying_message |
|
45 | rep_msg = @message.replying_message |
|
45 | rep_msg.replied = true |
|
46 | rep_msg.replied = true |
|
46 | rep_msg.save |
|
47 | rep_msg.save |
|
47 | redirect_to :action => 'console' |
|
48 | redirect_to :action => 'console' |
|
48 | end |
|
49 | end |
|
49 | end |
|
50 | end |
|
50 |
|
51 | ||
|
|
52 | + def hide | ||
|
|
53 | + message = Message.find(params[:id]) | ||
|
|
54 | + message.replied = true | ||
|
|
55 | + message.save | ||
|
|
56 | + flash[:notice] = 'Message hided (just marked replied)' | ||
|
|
57 | + redirect_to :action => 'console' | ||
|
|
58 | + end | ||
|
|
59 | + | ||
|
51 | protected |
|
60 | protected |
|
52 | def build_replying_message_hierarchy(user) |
|
61 | def build_replying_message_hierarchy(user) |
|
53 | @all_messages = {} |
|
62 | @all_messages = {} |
|
54 |
|
63 | ||
|
55 |
|
64 | ||
|
56 | # manually build replies hierarchy (to improve efficiency) |
|
65 | # manually build replies hierarchy (to improve efficiency) |
|
57 | [@messages, @replied_messages].each do |collection| |
|
66 | [@messages, @replied_messages].each do |collection| |
|
58 | collection.each do |m| |
|
67 | collection.each do |m| |
|
59 | @all_messages[m.id] = {:msg => m, :replies => []} |
|
68 | @all_messages[m.id] = {:msg => m, :replies => []} |
|
60 | end |
|
69 | end |
|
61 | end |
|
70 | end |
|
62 |
|
71 |
@@ -1,6 +1,7 | |||||
|
1 | %tr |
|
1 | %tr |
|
2 | %td=h short_message.sender.full_name |
|
2 | %td=h short_message.sender.full_name |
|
3 | %td= "#{short_message.created_at}" |
|
3 | %td= "#{short_message.created_at}" |
|
4 | %td=h truncate(short_message.body) |
|
4 | %td=h truncate(short_message.body) |
|
5 | %td |
|
5 | %td |
|
6 | = link_to "[reply]", :action => 'show', :id => short_message.id |
|
6 | = link_to "[reply]", :action => 'show', :id => short_message.id |
|
|
7 | + = link_to "[hide]", :action => 'hide', :id => short_message.id |
@@ -2,12 +2,19 | |||||
|
2 |
|
2 | ||
|
3 | .message |
|
3 | .message |
|
4 | .stat |
|
4 | .stat |
|
5 | = "#{@message.sender.full_name} at #{@message.created_at}" |
|
5 | = "#{@message.sender.full_name} at #{@message.created_at}" |
|
6 | .body= simple_format(@message.body) |
|
6 | .body= simple_format(@message.body) |
|
7 |
|
7 | ||
|
8 | %h3 Your reply: |
|
8 | %h3 Your reply: |
|
9 | - form_for 'r_message', nil, :url => { :action => 'reply'} do |f| |
|
9 | - form_for 'r_message', nil, :url => { :action => 'reply'} do |f| |
|
10 | = f.text_area :body, :rows => 5, :cols => 100 |
|
10 | = f.text_area :body, :rows => 5, :cols => 100 |
|
11 | = f.hidden_field :receiver_id, {:value => @message.sender_id } |
|
11 | = f.hidden_field :receiver_id, {:value => @message.sender_id } |
|
12 | = f.hidden_field :replying_message_id, {:value => @message.id } |
|
12 | = f.hidden_field :replying_message_id, {:value => @message.id } |
|
13 | = submit_tag "Post" |
|
13 | = submit_tag "Post" |
|
|
14 | + | ||
|
|
15 | + %p | ||
|
|
16 | + If you do not want to reply, but want to hide this message from | ||
|
|
17 | + console, you can | ||
|
|
18 | + = link_to "[hide]", :action => 'hide', :id => @message.id | ||
|
|
19 | + this message. (This message will be marked as replied.) | ||
|
|
20 | + |
You need to be logged in to leave comments.
Login now