Commit a77e0441db34bd8a1f7b8f788e034f511b6f66a7

Authored by Leandro Santos
2 parents 8d006b66 aef06801

Merge branches 'AI3126-notification-plugin' and 'rails3_stable' into rails3_stable

plugins/notification/controllers/notification_plugin_profile_controller.rb
... ... @@ -6,8 +6,6 @@ class NotificationPluginProfileController < ProfileController
6 6  
7 7 protect 'see_loby_notes', :profile
8 8  
9   - layout 'embed'
10   -
11 9 def lobby_notes
12 10 @date = params[:date].nil? ? Date.today : Date.parse(params[:date])
13 11 @events = profile.lobby_notes.by_day(@date).paginate(:per_page => per_page, :page => params[:page])
... ... @@ -15,6 +13,23 @@ class NotificationPluginProfileController < ProfileController
15 13 if request.xhr?
16 14 render :partial => 'event', :collection => @events
17 15 end
  16 + render :file => 'notification_plugin_profile/lobby_notes', :layout => 'embed'
  17 + end
  18 +
  19 + def index
  20 + @events = current_person.lobby_notes
  21 + @event = NotificationPlugin::LobbyNoteContent.new
  22 + end
  23 +
  24 + def create
  25 + @event = NotificationPlugin::LobbyNoteContent.new(params[:event])
  26 + @event.profile = profile
  27 + @event.created_by = current_person
  28 + @events = current_person.lobby_notes
  29 + unless @event.save
  30 + flash[:error] = _('Note not saved')
  31 + end
  32 + render :partial => 'event', :collection => @events
18 33 end
19 34  
20 35 end
... ...
plugins/notification/lib/ext/profile.rb
... ... @@ -4,3 +4,10 @@ Profile.class_eval do
4 4 has_many :notifications, :source => 'articles', :class_name => 'NotificationPlugin::NotificationContent', :order => 'start_date'
5 5 has_many :lobby_notes, :source => 'articles', :class_name => 'NotificationPlugin::LobbyNoteContent', :order => 'start_date'
6 6 end
  7 +
  8 +Person.class_eval do
  9 +# has_many :notifications, :source => 'articles', :class_name => 'NotificationPlugin::NotificationContent', :order => 'start_date'
  10 + has_many :lobby_notes, :foreign_key => 'created_by_id', :class_name => 'NotificationPlugin::LobbyNoteContent', :order => 'start_date,created_at'
  11 +# named_scope :lobby_notes_by_profile
  12 +end
  13 +
... ...
plugins/notification/views/notification_plugin_profile/index.html.erb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<h1><%= _('Lobby Notes')%></h1>
  2 +
  3 +
  4 +<div id='leave_note'>
  5 + <%= flash[:error] %>
  6 + <%= form_remote_tag :url => {:action => 'create'}, :update => 'lobby_notes', :success => "$('leave_note_content').value=''", :complete => "jQuery('#leave_note_form').removeClass('loading').find('*').attr('disabled', false)", :loading => "jQuery('#leave_note_form').addClass('loading').find('*').attr('disabled', true)", :html => {:id => 'leave_note_form' } do %>
  7 + <%= limited_text_area :event, :body, 420, 'leave_note_content', :cols => 50, :rows => 2, :class => 'autogrow' %>
  8 + <%= submit_button :new, _('New note') %>
  9 + <% end %>
  10 +</div>
  11 +
  12 +
  13 +<ul id='lobby_notes'>
  14 +<% @events.map do |event| %>
  15 + <%= render :partial => 'event', :locals => {:event => event}%>
  16 +<% end %>
  17 +</ul>
... ...