Commit d135f5e74f931cf46543bb97c1acbfbc34b5262a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'rails3_stable' of gitlab.com:participa/noosfero into rails3_stable
Showing
4 changed files
with
77 additions
and
2 deletions
Show diff stats
plugins/notification/controllers/notification_plugin_profile_controller.rb
| ... | ... | @@ -6,16 +6,48 @@ 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]) |
| 14 | 12 | |
| 15 | 13 | if request.xhr? |
| 16 | 14 | render :partial => 'event', :collection => @events |
| 15 | + else | |
| 16 | + render :file => 'notification_plugin_profile/lobby_notes', :layout => 'embed' | |
| 17 | + end | |
| 18 | + end | |
| 19 | + | |
| 20 | + def index | |
| 21 | + @events = current_person.lobby_notes.find(:all, :conditions => {:profile => profile } ) | |
| 22 | + @event = NotificationPlugin::LobbyNoteContent.new | |
| 23 | + end | |
| 24 | + | |
| 25 | + def create | |
| 26 | + @event = NotificationPlugin::LobbyNoteContent.new(params[:event]) | |
| 27 | + @event.profile = profile | |
| 28 | + @event.created_by = current_person | |
| 29 | + @events = current_person.lobby_notes | |
| 30 | + unless @event.save | |
| 31 | + flash[:error] = _('Note not saved') | |
| 17 | 32 | end |
| 33 | + render :partial => 'event', :collection => @events | |
| 18 | 34 | end |
| 19 | 35 | |
| 36 | + def notifications | |
| 37 | + @date = params[:date].nil? ? Date.today : Date.parse(params[:date]) | |
| 38 | + | |
| 39 | + if request.xhr? | |
| 40 | + @event = NotificationPlugin::NotificationContent.new(params[:event]) | |
| 41 | + @event.profile = profile | |
| 42 | + @event.created_by = current_person | |
| 43 | + @event.save! | |
| 44 | + | |
| 45 | + @events = profile.notifications.paginate(:per_page => per_page, :page => params[:page]) | |
| 46 | + render :partial => 'event', :collection => @events | |
| 47 | + else | |
| 48 | + @events = profile.notifications.paginate(:per_page => per_page, :page => params[:page]) | |
| 49 | + render :file => 'notification_plugin_profile/notifications' | |
| 50 | + end | |
| 51 | + end | |
| 20 | 52 | end |
| 21 | 53 | ... | ... |
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') %> | |
| 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> | ... | ... |
plugins/notification/views/notification_plugin_profile/notifications.html.erb
0 → 100644
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +<h1><%= _('Notifications')%></h1> | |
| 2 | + | |
| 3 | + | |
| 4 | +<div id='leave_note'> | |
| 5 | + <%= flash[:error] %> | |
| 6 | + <%= form_remote_tag :url => {:action => 'notifications'}, :update => 'notifications', :success => "$('leave_notification_content').value='';$('leave_notification_title').value=''", :complete => "jQuery('#leave_notification_form').removeClass('loading').find('*').attr('disabled', false)", :loading => "jQuery('#leave_notification_form').addClass('loading').find('*').attr('disabled', true)", :html => {:id => 'leave_notification_form' } do %> | |
| 7 | + <%= _('Title:') %> | |
| 8 | + <%= text_field :event, :name, :id => 'leave_notification_title' %> | |
| 9 | + <%= limited_text_area :event, :body, 420, 'leave_notification_content', :cols => 50, :rows => 3, :class => 'autogrow' %> | |
| 10 | + <%= submit_button :new, _('New') %> | |
| 11 | + <% end %> | |
| 12 | +</div> | |
| 13 | + | |
| 14 | + | |
| 15 | +<ul id='notifications'> | |
| 16 | +<% @events.map do |event| %> | |
| 17 | + <%= render :partial => 'event', :locals => {:event => event}%> | |
| 18 | +<% end %> | |
| 19 | +</ul> | ... | ... |