Description:
update message console
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
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,84 +1,88 | |||
|
1 | 1 | class MessagesController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_action : |
|
|
3 | + before_action :check_valid_login | |
|
4 | 4 | |
|
5 | + before_action :set_message, only: ['show', 'reply'] | |
|
5 | 6 | |
|
6 |
- before_ |
|
|
7 | + before_action :admin_authorization, :only => ['console','show', | |
|
7 | 8 | 'reply','hide','list_all'] |
|
8 | 9 | |
|
9 |
- def |
|
|
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 |
|
|
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 |
- |
|
|
50 | - rep_msg.replied = true | |
|
51 |
- |
|
|
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 |
|
55 | 51 | |
|
56 | 52 | def hide |
|
57 | 53 | message = Message.find(params[:id]) |
|
58 | 54 | message.replied = true |
|
59 | 55 | message.save |
|
60 | 56 | flash[:notice] = 'Message hidden (just marked replied)' |
|
61 | 57 | redirect_to :action => 'console' |
|
62 | 58 | end |
|
63 | 59 | |
|
64 | 60 | protected |
|
65 | 61 | def build_replying_message_hierarchy(user) |
|
66 | 62 | @all_messages = {} |
|
67 | 63 | |
|
68 | 64 | |
|
69 | 65 | # manually build replies hierarchy (to improve efficiency) |
|
70 | 66 | [@messages, @replied_messages].each do |collection| |
|
71 | 67 | collection.each do |m| |
|
72 | 68 | @all_messages[m.id] = {:msg => m, :replies => []} |
|
73 | 69 | end |
|
74 | 70 | end |
|
75 | 71 | |
|
76 | 72 | @all_messages.each do |m| |
|
77 | 73 | rep_id = m.replying_message_id |
|
78 | 74 | if @all_messages[rep_id]!=nil |
|
79 | 75 | @all_messages[rep_id][:replies] << m |
|
80 | 76 | end |
|
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,13 +1,12 | |||
|
1 | - = user_title_bar(@user) | |
|
2 | 1 |
|
|
3 | 2 | %h1 Console: active messages |
|
4 | 3 | |
|
5 | 4 | = link_to '[all messages]', :action => 'list_all' |
|
6 | 5 | |
|
7 | 6 | %table |
|
8 | 7 | %tr |
|
9 | 8 | %th From |
|
10 | 9 | %th When |
|
11 | 10 | %th Message |
|
12 | 11 | %th |
|
13 | 12 | = render :partial => "short_message", :collection => @messages |
@@ -1,13 +1,11 | |||
|
1 | - = user_title_bar(@user) | |
|
2 | - | |
|
3 | 1 |
|
|
4 | 2 | |
|
5 | 3 | = link_to '[active messages]', :action => 'list_all' |
|
6 | 4 | |
|
7 | 5 | %table |
|
8 | 6 | %tr |
|
9 | 7 | %th From |
|
10 | 8 | %th When |
|
11 | 9 | %th Message |
|
12 | 10 | %th |
|
13 | 11 | = render :partial => "short_message", :collection => @messages |
@@ -1,20 +1,20 | |||
|
1 | 1 | %h3 Message |
|
2 | 2 | |
|
3 | 3 | .message |
|
4 | 4 | .stat |
|
5 | 5 | = "#{@message.sender.full_name} at #{@message.created_at}" |
|
6 | 6 | .body= simple_format(@message.body) |
|
7 | 7 | |
|
8 | 8 | %h3 Your reply: |
|
9 |
- = form_for ' |
|
|
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 |
|
16 | 16 | If you do not want to reply, but want to hide this message from |
|
17 | 17 | console, you can |
|
18 | 18 | = link_to "[hide]", :action => 'hide', :id => @message.id |
|
19 | 19 | this message. (This message will be marked as replied.) |
|
20 | 20 |
@@ -1,194 +1,199 | |||
|
1 | 1 | Rails.application.routes.draw do |
|
2 | 2 | resources :tags |
|
3 | 3 | get "sources/direct_edit" |
|
4 | 4 | |
|
5 | 5 | root :to => 'main#login' |
|
6 | 6 | |
|
7 | 7 | #logins |
|
8 | 8 | match 'login/login', to: 'login#login', via: [:get,:post] |
|
9 | 9 | |
|
10 | 10 | resources :contests |
|
11 | 11 | resources :sites |
|
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 | |
|
20 | 25 | resources :announcements do |
|
21 | 26 | member do |
|
22 | 27 | get 'toggle','toggle_front' |
|
23 | 28 | end |
|
24 | 29 | end |
|
25 | 30 | |
|
26 | 31 | resources :problems do |
|
27 | 32 | member do |
|
28 | 33 | get 'toggle' |
|
29 | 34 | get 'toggle_test' |
|
30 | 35 | get 'toggle_view_testcase' |
|
31 | 36 | get 'stat' |
|
32 | 37 | end |
|
33 | 38 | collection do |
|
34 | 39 | get 'turn_all_off' |
|
35 | 40 | get 'turn_all_on' |
|
36 | 41 | get 'import' |
|
37 | 42 | get 'manage' |
|
38 | 43 | get 'quick_create' |
|
39 | 44 | post 'do_manage' |
|
40 | 45 | post 'do_import' |
|
41 | 46 | end |
|
42 | 47 | end |
|
43 | 48 | |
|
44 | 49 | resources :groups do |
|
45 | 50 | member do |
|
46 | 51 | post 'add_user', to: 'groups#add_user', as: 'add_user' |
|
47 | 52 | delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user' |
|
48 | 53 | delete 'remove_all_user', to: 'groups#remove_all_user', as: 'remove_all_user' |
|
49 | 54 | post 'add_problem', to: 'groups#add_problem', as: 'add_problem' |
|
50 | 55 | delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem' |
|
51 | 56 | delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem' |
|
52 | 57 | end |
|
53 | 58 | collection do |
|
54 | 59 | |
|
55 | 60 | end |
|
56 | 61 | end |
|
57 | 62 | |
|
58 | 63 | resources :testcases, only: [] do |
|
59 | 64 | member do |
|
60 | 65 | get 'download_input' |
|
61 | 66 | get 'download_sol' |
|
62 | 67 | end |
|
63 | 68 | collection do |
|
64 | 69 | get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem' |
|
65 | 70 | end |
|
66 | 71 | end |
|
67 | 72 | |
|
68 | 73 | resources :grader_configuration, controller: 'configurations' do |
|
69 | 74 | collection do |
|
70 | 75 | get 'set_exam_right(/:value)', action: 'set_exam_right', as: 'set_exam_right' |
|
71 | 76 | end |
|
72 | 77 | end |
|
73 | 78 | |
|
74 | 79 | resources :users do |
|
75 | 80 | member do |
|
76 | 81 | get 'toggle_activate', 'toggle_enable' |
|
77 | 82 | get 'stat' |
|
78 | 83 | end |
|
79 | 84 | collection do |
|
80 | 85 | get 'profile' |
|
81 | 86 | post 'chg_passwd' |
|
82 | 87 | end |
|
83 | 88 | end |
|
84 | 89 | |
|
85 | 90 | resources :submissions do |
|
86 | 91 | member do |
|
87 | 92 | get 'download' |
|
88 | 93 | get 'compiler_msg' |
|
89 | 94 | get 'rejudge' |
|
90 | 95 | get 'source' |
|
91 | 96 | end |
|
92 | 97 | collection do |
|
93 | 98 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
|
94 | 99 | get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' |
|
95 | 100 | get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status' |
|
96 | 101 | end |
|
97 | 102 | end |
|
98 | 103 | |
|
99 | 104 | |
|
100 | 105 | #user admin |
|
101 | 106 | resources :user_admin do |
|
102 | 107 | collection do |
|
103 | 108 | match 'bulk_manage', via: [:get, :post] |
|
104 | 109 | get 'bulk_mail' |
|
105 | 110 | get 'user_stat' |
|
106 | 111 | get 'import' |
|
107 | 112 | get 'new_list' |
|
108 | 113 | get 'admin' |
|
109 | 114 | get 'active' |
|
110 | 115 | get 'mass_mailing' |
|
111 | 116 | get 'revoke_admin' |
|
112 | 117 | post 'grant_admin' |
|
113 | 118 | match 'create_from_list', via: [:get, :post] |
|
114 | 119 | match 'random_all_passwords', via: [:get, :post] |
|
115 | 120 | end |
|
116 | 121 | member do |
|
117 | 122 | get 'clear_last_ip' |
|
118 | 123 | end |
|
119 | 124 | end |
|
120 | 125 | |
|
121 | 126 | resources :contest_management, only: [:index] do |
|
122 | 127 | collection do |
|
123 | 128 | get 'user_stat' |
|
124 | 129 | get 'clear_stat' |
|
125 | 130 | get 'clear_all_stat' |
|
126 | 131 | get 'change_contest_mode' |
|
127 | 132 | end |
|
128 | 133 | end |
|
129 | 134 | |
|
130 | 135 | #get 'user_admin', to: 'user_admin#index' |
|
131 | 136 | #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin' |
|
132 | 137 | #post 'user_admin', to: 'user_admin#create' |
|
133 | 138 | #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy' |
|
134 | 139 | |
|
135 | 140 | #singular resource |
|
136 | 141 | #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly |
|
137 | 142 | #report |
|
138 | 143 | resource :report, only: [], controller: 'report' do |
|
139 | 144 | get 'login' |
|
140 | 145 | get 'multiple_login' |
|
141 | 146 | get 'problem_hof(/:id)', action: 'problem_hof', as: 'problem_hof' |
|
142 | 147 | get 'current_score(/:group_id)', action: 'current_score', as: 'current_score' |
|
143 | 148 | get 'max_score' |
|
144 | 149 | post 'show_max_score' |
|
145 | 150 | end |
|
146 | 151 | #get 'report/current_score', to: 'report#current_score', as: 'report_current_score' |
|
147 | 152 | #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
148 | 153 | #get "report/login" |
|
149 | 154 | #get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
150 | 155 | #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' |
|
151 | 156 | |
|
152 | 157 | resource :main, only: [], controller: 'main' do |
|
153 | 158 | get 'login' |
|
154 | 159 | get 'logout' |
|
155 | 160 | get 'list' |
|
156 | 161 | get 'submission(/:id)', action: 'submission', as: 'main_submission' |
|
157 | 162 | get 'announcements' |
|
158 | 163 | get 'help' |
|
159 | 164 | post 'submit' |
|
160 | 165 | end |
|
161 | 166 | #main |
|
162 | 167 | #get "main/list" |
|
163 | 168 | #get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
164 | 169 | #post 'main/submit', to: 'main#submit' |
|
165 | 170 | #get 'main/announcements', to: 'main#announcements' |
|
166 | 171 | |
|
167 | 172 | |
|
168 | 173 | # |
|
169 | 174 | get 'tasks/view/:file.:ext' => 'tasks#view' |
|
170 | 175 | get 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
171 | 176 | get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
172 | 177 | |
|
173 | 178 | #grader |
|
174 | 179 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
175 | 180 | namespace :graders do |
|
176 | 181 | get 'task/:id/:type', action: 'task', as: 'task' |
|
177 | 182 | get 'view/:id/:type', action: 'view', as: 'view' |
|
178 | 183 | get 'clear/:id', action: 'clear', as: 'clear' |
|
179 | 184 | get 'stop' |
|
180 | 185 | get 'stop_all' |
|
181 | 186 | get 'clear_all' |
|
182 | 187 | get 'clear_terminated' |
|
183 | 188 | get 'start_grading' |
|
184 | 189 | get 'start_exam' |
|
185 | 190 | |
|
186 | 191 | end |
|
187 | 192 | |
|
188 | 193 | |
|
189 | 194 | # See how all your routes lay out with "rake routes" |
|
190 | 195 | |
|
191 | 196 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
192 | 197 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
193 | 198 | # match ':controller(/:action(/:id))(.:format)', via: [:get, :post] |
|
194 | 199 | end |
deleted file |
You need to be logged in to leave comments.
Login now