Add author and participants as watchers. #2419

Participants are added as watcher the first time they are added as either invitee or attendant.
pull/6827/head
Felix Schäfer 14 years ago
parent 440809f131
commit 5087138571
  1. 3
      app/controllers/meetings_controller.rb
  2. 12
      app/models/meeting.rb
  3. 8
      app/models/meeting_participant.rb
  4. 1
      app/views/meetings/show.html.erb

@ -5,6 +5,9 @@ class MeetingsController < ApplicationController
before_filter :find_meeting, :except => [:index, :new, :create]
before_filter :convert_params, :only => [:create, :update]
before_filter :authorize
helper :watchers
include WatchersHelper
def index
# Wo sollen Meetings ohne Termin hin?

@ -7,10 +7,14 @@ class Meeting < ActiveRecord::Base
has_one :minutes, :dependent => :destroy, :class_name => 'MeetingMinutes'
has_many :participants, :dependent => :destroy, :class_name => 'MeetingParticipant'
accepts_nested_attributes_for :participants
acts_as_watchable
accepts_nested_attributes_for :participants, :reject_if => proc {|attrs| !(attrs['attended'] || attrs['invited'])}
validates_presence_of :title, :start_time
after_create :add_author_as_watcher
def self.find_time_sorted(*args)
by_start_year_month_date = ActiveSupport::OrderedHash.new
self.find(*args).group_by(&:start_year).each do |year,objs|
@ -57,4 +61,10 @@ class Meeting < ActiveRecord::Base
self.start_time ||= Date.tomorrow + 10.hours
self.duration ||= 1
end
private
def add_author_as_watcher
add_watcher(author)
end
end

@ -7,6 +7,8 @@ class MeetingParticipant < ActiveRecord::Base
named_scope :invited, :conditions => {:invited => true}
named_scope :attended, :conditions => {:attended => true}
after_create :add_participant_as_watcher
def name
user.present? ? user.name : self.name
end
@ -20,4 +22,10 @@ class MeetingParticipant < ActiveRecord::Base
end
alias :to_s :name
private
def add_participant_as_watcher
meeting.add_watcher(user)
end
end

@ -1,4 +1,5 @@
<div class="contextual">
<%= watcher_tag @meeting, User.current %>
<%= link_to_if_authorized(l(:button_edit), {:action => 'edit'}, :class => 'icon icon-edit')%>
<%= link_to_if_authorized(l(:button_copy), {:controller => 'meetings', :action => 'new', :project_id => @project, :copy_from_id => @meeting}, :class => 'icon icon-copy')%>
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy'}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del')%>

Loading…
Cancel
Save