52 lines
1.7 KiB
Ruby
52 lines
1.7 KiB
Ruby
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 )
|
|
limit = 10;
|
|
@obj_count = query.count();
|
|
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
|
list = query.order('is_read,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'
|
|
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 |