Class: MeetingContentsController

Inherits:
ApplicationController
  • Object
show all
Includes:
PaginationHelper
Defined in:
app/controllers/meeting_contents_controller.rb

Overview

– copyright OpenProject is a project management system. Copyright © 2011-2013 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

See doc/COPYRIGHT.md for more details. ++

Instance Method Summary collapse

Instance Method Details

#default_breadcrumbObject



97
98
99
# File 'app/controllers/meeting_contents_controller.rb', line 97

def default_breadcrumb
  MeetingsController.new.send(:default_breadcrumb)
end

#diffObject



76
77
78
79
80
81
# File 'app/controllers/meeting_contents_controller.rb', line 76

def diff
  @diff = @content.diff(params[:version_to], params[:version_from])
  render 'meeting_contents/diff'
rescue ActiveRecord::RecordNotFound
  render_404
end

#historyObject



66
67
68
69
70
71
72
73
74
# File 'app/controllers/meeting_contents_controller.rb', line 66

def history
  # don't load text
  @content_versions = @content.journals.select("id, user_id, notes, created_at, version")
                                       .order('version DESC')
                                       .page(page_param)
                                       .per_page(per_page_param)

  render 'meeting_contents/history', :layout => !request.xhr?
end

#notifyObject



83
84
85
86
87
88
89
# File 'app/controllers/meeting_contents_controller.rb', line 83

def notify
  unless @content.new_record?
    MeetingMailer.content_for_review(@content, @content_type).deliver
    flash[:notice] = l(:notice_successful_notification)
  end
  redirect_back_or_default :controller => '/meetings', :action => 'show', :id => @meeting
end

#previewObject



91
92
93
94
95
# File 'app/controllers/meeting_contents_controller.rb', line 91

def preview
  (render_403; return) unless @content.editable?
  @text = params[:text]
  render :partial => 'common/preview'
end

#showObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/meeting_contents_controller.rb', line 36

def show
  if params[:id].present? && @content.version == params[:id].to_i
    # Redirect links to the last version
    redirect_to :controller => '/meetings',
                :action => :show,
                :id => @meeting,
                :tab => @content_type.sub(/^meeting_/, '')
    return
  end
  #go to an old version if a version id is given
  @content = @content.at_version params[:id] unless params[:id].blank?
  render 'meeting_contents/show'
end

#updateObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/meeting_contents_controller.rb', line 50

def update
  (render_403; return) unless @content.editable? # TODO: not tested!
  @content.attributes = params[:"#{@content_type}"]
  @content.author = User.current
  if @content.save
    flash[:notice] = l(:notice_successful_update)
    redirect_back_or_default :controller => '/meetings', :action => 'show', :id => @meeting
  else
  end
rescue ActiveRecord::StaleObjectError
  # Optimistic locking exception
  flash.now[:error] = l(:notice_locking_conflict)
  params[:tab] ||= "minutes" if @meeting.agenda.present? && @meeting.agenda.locked?
  render 'meetings/show'
end