Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
commit
89d15e7673
@ -0,0 +1,54 @@
|
||||
class ActivityNotifysController < ApplicationController
|
||||
# layout 'base_projects'#by young
|
||||
# default_search_scope :messages
|
||||
before_filter :find_project_by_project_id#, :find_board_if_available
|
||||
# before_filter :authorize, :except => [:new, :show, :create, :index]
|
||||
# accept_rss_auth :index, :show
|
||||
|
||||
helper :activities
|
||||
def index
|
||||
query = nil
|
||||
if @course
|
||||
query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',@course.id,'Course',User.current.id);
|
||||
else
|
||||
@events_by_day = []
|
||||
end
|
||||
|
||||
if( query != nil )
|
||||
logger.info('xxoo')
|
||||
limit = 10;
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all();
|
||||
events=[];
|
||||
for item in list
|
||||
event = item.activity;
|
||||
event.set_notify_id(item.id)
|
||||
event.set_notify_is_read(item.is_read)
|
||||
events << event
|
||||
end
|
||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||
@controller_name = 'ActivityNotifys'
|
||||
logger.info('aavv')
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {render :template => 'courses/show', :layout => 'base_courses'}
|
||||
end
|
||||
end
|
||||
|
||||
def chang_read_flag
|
||||
if @course
|
||||
if(params[:an_id] != nil )
|
||||
query = ActivityNotify.where('id=? and notify_to=?',params[:an_id],User.current.id)
|
||||
else
|
||||
query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=? and is_read=0',@course.id,'Course',User.current.id)
|
||||
end
|
||||
@result = query.update_all('is_read=1');
|
||||
else
|
||||
@result = false;
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{render :layout => nil}
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,3 @@
|
||||
class ActivityNotify < ActiveRecord::Base
|
||||
belongs_to :activity, polymorphic: true
|
||||
end
|
@ -0,0 +1 @@
|
||||
<%= @result == false ? 'false' : 'true' %>
|
@ -0,0 +1,17 @@
|
||||
class CreateActivityNotifies < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :activity_notifies do |t|
|
||||
t.integer :activity_container_id
|
||||
t.string :activity_container_type
|
||||
t.integer :activity_id
|
||||
t.string :activity_type
|
||||
t.integer :notify_to
|
||||
t.datetime :created_on
|
||||
t.integer :is_read
|
||||
|
||||
end
|
||||
add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to"
|
||||
add_index "activity_notifies", ["created_on"], :name => "index_an_created_on"
|
||||
add_index "activity_notifies", ["activity_container_id","activity_container_type"], :name => "index_an_activity_container_id"
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 4.1 KiB |
Loading…
Reference in new issue