Description:
Merge pull request #4 from sarunint/master
Implement list_all action for message console and update rails version.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r359:b0de2bc4926f - - 4 files changed: 21 inserted, 2 deleted
@@ -0,0 +1,13 | |||||
|
|
1 | + = user_title_bar(@user) | ||
|
|
2 | + | ||
|
|
3 | + %h1 Console: all messages | ||
|
|
4 | + | ||
|
|
5 | + = link_to '[active messages]', :action => 'list_all' | ||
|
|
6 | + | ||
|
|
7 | + %table | ||
|
|
8 | + %tr | ||
|
|
9 | + %th From | ||
|
|
10 | + %th When | ||
|
|
11 | + %th Message | ||
|
|
12 | + %th | ||
|
|
13 | + = render :partial => "short_message", :collection => @messages |
@@ -1,27 +1,27 | |||||
|
1 | source 'https://rubygems.org' |
|
1 | source 'https://rubygems.org' |
|
2 |
|
2 | ||
|
3 |
- gem 'rails', '3.2. |
|
3 | + gem 'rails', '3.2.19' |
|
4 |
|
4 | ||
|
5 | # Bundle edge Rails instead: |
|
5 | # Bundle edge Rails instead: |
|
6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' |
|
6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' |
|
7 |
|
7 | ||
|
8 | gem 'mysql2' |
|
8 | gem 'mysql2' |
|
9 |
|
9 | ||
|
10 | # Gems used only for assets and not required |
|
10 | # Gems used only for assets and not required |
|
11 | # in production environments by default. |
|
11 | # in production environments by default. |
|
12 | group :assets do |
|
12 | group :assets do |
|
13 | gem 'sass-rails', '~> 3.2.3' |
|
13 | gem 'sass-rails', '~> 3.2.3' |
|
14 | gem 'coffee-rails', '~> 3.2.1' |
|
14 | gem 'coffee-rails', '~> 3.2.1' |
|
15 |
|
15 | ||
|
16 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
16 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes |
|
17 | # gem 'therubyracer', :platforms => :ruby |
|
17 | # gem 'therubyracer', :platforms => :ruby |
|
18 |
|
18 | ||
|
19 | gem 'uglifier', '>= 1.0.3' |
|
19 | gem 'uglifier', '>= 1.0.3' |
|
20 | end |
|
20 | end |
|
21 |
|
21 | ||
|
22 | gem 'prototype-rails' |
|
22 | gem 'prototype-rails' |
|
23 |
|
23 | ||
|
24 | # To use ActiveModel has_secure_password |
|
24 | # To use ActiveModel has_secure_password |
|
25 | # gem 'bcrypt-ruby', '~> 3.0.0' |
|
25 | # gem 'bcrypt-ruby', '~> 3.0.0' |
|
26 |
|
26 | ||
|
27 | # To use Jbuilder templates for JSON |
|
27 | # To use Jbuilder templates for JSON |
@@ -1,48 +1,53 | |||||
|
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 | + 'reply','hide','list_all'] |
|
10 |
|
10 | ||
|
11 | def list |
|
11 | def list |
|
12 | @user = User.find(session[:user_id]) |
|
12 | @user = User.find(session[:user_id]) |
|
13 | @messages = Message.find_all_sent_by_user(@user) |
|
13 | @messages = Message.find_all_sent_by_user(@user) |
|
14 | end |
|
14 | end |
|
15 |
|
15 | ||
|
16 | def console |
|
16 | def console |
|
17 | @user = User.find(session[:user_id]) |
|
17 | @user = User.find(session[:user_id]) |
|
18 | @messages = Message.find_all_system_unreplied_messages |
|
18 | @messages = Message.find_all_system_unreplied_messages |
|
19 | end |
|
19 | end |
|
20 |
|
20 | ||
|
21 | def show |
|
21 | def show |
|
22 | @message = Message.find(params[:id]) |
|
22 | @message = Message.find(params[:id]) |
|
23 | end |
|
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 | def create |
|
30 | def create |
|
26 | user = User.find(session[:user_id]) |
|
31 | user = User.find(session[:user_id]) |
|
27 | @message = Message.new(params[:message]) |
|
32 | @message = Message.new(params[:message]) |
|
28 | @message.sender = user |
|
33 | @message.sender = user |
|
29 | if !@message.save |
|
34 | if !@message.save |
|
30 | render :action => 'list' and return |
|
35 | render :action => 'list' and return |
|
31 | else |
|
36 | else |
|
32 | flash[:notice] = 'New message posted' |
|
37 | flash[:notice] = 'New message posted' |
|
33 | redirect_to :action => 'list' |
|
38 | redirect_to :action => 'list' |
|
34 | end |
|
39 | end |
|
35 | end |
|
40 | end |
|
36 |
|
41 | ||
|
37 | def reply |
|
42 | def reply |
|
38 | user = User.find(session[:user_id]) |
|
43 | user = User.find(session[:user_id]) |
|
39 | @message = Message.new(params[:r_message]) |
|
44 | @message = Message.new(params[:r_message]) |
|
40 | @message.sender = user |
|
45 | @message.sender = user |
|
41 | if !@message.save |
|
46 | if !@message.save |
|
42 | render :action => 'show' and return |
|
47 | render :action => 'show' and return |
|
43 | else |
|
48 | else |
|
44 | flash[:notice] = 'Message replied' |
|
49 | flash[:notice] = 'Message replied' |
|
45 | rep_msg = @message.replying_message |
|
50 | rep_msg = @message.replying_message |
|
46 | rep_msg.replied = true |
|
51 | rep_msg.replied = true |
|
47 | rep_msg.save |
|
52 | rep_msg.save |
|
48 | redirect_to :action => 'console' |
|
53 | redirect_to :action => 'console' |
@@ -1,11 +1,12 | |||||
|
1 | %tr |
|
1 | %tr |
|
2 | - if short_message.sender |
|
2 | - if short_message.sender |
|
3 | %td=h short_message.sender.full_name |
|
3 | %td=h short_message.sender.full_name |
|
4 | - else |
|
4 | - else |
|
5 | %td (user deleted) |
|
5 | %td (user deleted) |
|
6 | %td= "#{short_message.created_at}" |
|
6 | %td= "#{short_message.created_at}" |
|
7 | %td=h truncate(short_message.body) |
|
7 | %td=h truncate(short_message.body) |
|
8 | %td |
|
8 | %td |
|
9 | - if short_message.sender |
|
9 | - if short_message.sender |
|
10 | = link_to "[reply]", :action => 'show', :id => short_message.id |
|
10 | = link_to "[reply]", :action => 'show', :id => short_message.id |
|
|
11 | + - if params[:action] != 'list_all' | ||
|
11 | = link_to "[hide]", :action => 'hide', :id => short_message.id |
|
12 | = link_to "[hide]", :action => 'hide', :id => short_message.id |
You need to be logged in to leave comments.
Login now