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

r766:4b83dfaa53e2 - - 7 files changed: 54 inserted, 50 deleted

@@ -0,0 +1,24
1 + .announcementbox
2 + %span{:class => 'title'}
3 + How to submit clarification requests
4 + .announcement
5 + %p
6 + :markdown
7 + The clarification requests should be phrased as yes/no questions.
8 + The answers will be one of the following:
9 + (1) **YES**,
10 + (2) <b>NO</b>,
11 + (3) **ANSWERED IN TASK DESCRIPTION (EXPLICITLY OR IMPLICITLY)**,
12 + (4) **INVALID QUESTION**, and
13 + (5) **NO COMMENT**.
14 +
15 + = form_for 'message', :url => { :action => 'create'} do |f|
16 + %p
17 + %b New clarification request
18 + = submit_tag "Post"
19 + %br/
20 + = f.text_area :body, :rows => 5, :cols => 100
21 +
22 + %hr/
23 +
24 + = render :partial => 'message', :collection => @messages, :locals => {:reply => false}
@@ -1,54 +1,50
1 1 class MessagesController < ApplicationController
2 2
3 - before_action :authenticate
3 + before_action :check_valid_login
4 4
5 + before_action :set_message, only: ['show', 'reply']
5 6
6 - before_filter :admin_authorization, :only => ['console','show',
7 + before_action :admin_authorization, :only => ['console','show',
7 8 'reply','hide','list_all']
8 9
9 - def list
10 - @user = User.find(session[:user_id])
11 - @messages = Message.find_all_sent_by_user(@user)
10 + def index
11 + @messages = Message.find_all_sent_by_user(@current_user)
12 12 end
13 13
14 14 def console
15 - @user = User.find(session[:user_id])
16 15 @messages = Message.find_all_system_unreplied_messages
17 16 end
18 17
19 18 def show
20 - @message = Message.find(params[:id])
21 19 end
22 20
23 21 def list_all
24 - @user = User.find(session[:user_id])
25 22 @messages = Message.where(receiver_id: nil).order(:created_at)
26 23 end
27 24
28 25 def create
29 - user = User.find(session[:user_id])
30 - @message = Message.new(params[:message])
31 - @message.sender = user
26 + @message = Message.new(message_params)
27 + @message.sender = @current_user
32 28 if @message.body == '' or !@message.save
33 29 flash[:notice] = 'An error occurred'
34 30 else
35 31 flash[:notice] = 'New message posted'
36 32 end
37 - redirect_to :action => 'list'
33 + redirect_to action: 'index'
38 34 end
39 35
40 36 def reply
41 - user = User.find(session[:user_id])
42 - @message = Message.new(params[:r_message])
43 - @message.sender = user
37 + @r_message = Message.new(message_params)
38 + @r_message.receiver = @message.sender
39 + @r_message.sender = @current_user
44 40 if @message.body == '' or !@message.save
45 41 flash[:notice] = 'An error occurred'
46 42 redirect_to :action => 'show', :id => @message.replying_message_id
47 43 else
48 44 flash[:notice] = 'Message replied'
49 - rep_msg = @message.replying_message
50 - rep_msg.replied = true
51 - rep_msg.save
45 + @message.replied = true
46 + @message.replying_message = @r_message
47 + @message.save
52 48 redirect_to :action => 'console'
53 49 end
54 50 end
@@ -81,4 +77,12
81 77 end
82 78 end
83 79
80 + def set_message
81 + @message = Message.find(params[:id])
84 82 end
83 +
84 + def message_params
85 + params.require(:message).permit(:body)
86 + end
87 +
88 + end
@@ -1,4 +1,3
1 - = user_title_bar(@user)
2 1
3 2 %h1 Console: active messages
4 3
@@ -1,5 +1,3
1 - = user_title_bar(@user)
2 -
3 1 %h1 Console: all messages
4 2
5 3 = link_to '[active messages]', :action => 'list_all'
@@ -6,10 +6,10
6 6 .body= simple_format(@message.body)
7 7
8 8 %h3 Your reply:
9 - = form_for 'r_message', :url => { :action => 'reply'} do |f|
9 + = form_for 'message', url: reply_message_path(@message) do |f|
10 10 = f.text_area :body, :rows => 5, :cols => 100
11 - = f.hidden_field :receiver_id, {:value => @message.sender_id }
12 - = f.hidden_field :replying_message_id, {:value => @message.id }
11 + -#= f.hidden_field :receiver_id, {:value => @message.sender_id }
12 + -#= f.hidden_field :replying_message_id, {:value => @message.id }
13 13 = submit_tag "Post"
14 14
15 15 %p
@@ -12,8 +12,13
12 12 resources :test
13 13
14 14 resources :messages do
15 + member do
16 + get 'hide'
17 + post 'reply'
18 + end
15 19 collection do
16 20 get 'console'
21 + get 'list_all'
17 22 end
18 23 end
19 24
deleted file
You need to be logged in to leave comments. Login now