notification_plugin_profile_controller.rb
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class NotificationPluginProfileController < ProfileController
# append_view_path File.join(File.dirname(__FILE__) + '/../../views')
#FIXME make this test
# needs_profile
protect 'see_loby_notes', :profile
def lobby_notes
@date = params[:date].nil? ? Date.today : Date.parse(params[:date])
@events = profile.lobby_notes.by_day(@date).paginate(:per_page => per_page, :page => params[:page])
if request.xhr?
render :partial => 'event', :collection => @events
else
render :file => 'notification_plugin_profile/lobby_notes', :layout => 'embed'
end
end
def index
@events = current_person.lobby_notes.find(:all, :conditions => {:profile => profile } )
@event = NotificationPlugin::LobbyNoteContent.new
end
def create
@event = NotificationPlugin::LobbyNoteContent.new(params[:event])
@event.profile = profile
@event.created_by = current_person
@events = current_person.lobby_notes
unless @event.save
flash[:error] = _('Note not saved')
end
render :partial => 'event', :collection => @events
end
def notifications
@date = params[:date].nil? ? Date.today : Date.parse(params[:date])
if request.xhr?
@event = NotificationPlugin::NotificationContent.new(params[:event])
@event.profile = profile
@event.created_by = current_person
@event.save!
@events = profile.notifications.paginate(:per_page => per_page, :page => params[:page])
render :partial => 'event', :collection => @events
else
@events = profile.notifications.paginate(:per_page => per_page, :page => params[:page])
render :file => 'notification_plugin_profile/notifications'
end
end
end