kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
4.9 KiB
164 lines
4.9 KiB
11 years ago
|
#-- copyright
|
||
11 years ago
|
# OpenProject Meeting Plugin
|
||
|
#
|
||
|
# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
11 years ago
|
#++
|
||
|
|
||
14 years ago
|
class MeetingsController < ApplicationController
|
||
8 years ago
|
around_action :set_time_zone
|
||
|
before_action :find_project, only: [:index, :new, :create]
|
||
|
before_action :find_meeting, except: [:index, :new, :create]
|
||
|
before_action :convert_params, only: [:create, :update]
|
||
|
before_action :authorize
|
||
13 years ago
|
|
||
14 years ago
|
helper :watchers
|
||
14 years ago
|
helper :meeting_contents
|
||
14 years ago
|
include WatchersHelper
|
||
12 years ago
|
include PaginationHelper
|
||
14 years ago
|
|
||
10 years ago
|
menu_item :new_meeting, only: [:new, :create]
|
||
13 years ago
|
|
||
14 years ago
|
def index
|
||
13 years ago
|
scope = @project.meetings
|
||
|
|
||
13 years ago
|
# from params => today's page otherwise => first page as fallback
|
||
13 years ago
|
tomorrows_meetings_count = scope.from_tomorrow.count
|
||
12 years ago
|
@page_of_today = 1 + tomorrows_meetings_count / per_page_param
|
||
|
|
||
|
page = params['page'] ?
|
||
|
page_param :
|
||
|
@page_of_today
|
||
13 years ago
|
|
||
12 years ago
|
@meetings = scope.with_users_by_date
|
||
10 years ago
|
.page(page)
|
||
|
.per_page(per_page_param)
|
||
13 years ago
|
|
||
12 years ago
|
@meetings_by_start_year_month_date = Meeting.group_by_time(@meetings)
|
||
14 years ago
|
end
|
||
|
|
||
|
def show
|
||
10 years ago
|
params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
|
||
14 years ago
|
end
|
||
|
|
||
|
def create
|
||
14 years ago
|
@meeting.participants.clear # Start with a clean set of participants
|
||
9 years ago
|
@meeting.participants_attributes = @converted_params.delete(:participants_attributes)
|
||
|
@meeting.attributes = @converted_params
|
||
13 years ago
|
if params[:copied_from_meeting_id].present? && params[:copied_meeting_agenda_text].present?
|
||
|
@meeting.agenda = MeetingAgenda.new(
|
||
10 years ago
|
text: params[:copied_meeting_agenda_text],
|
||
|
comment: "Copied from Meeting ##{params[:copied_from_meeting_id]}")
|
||
13 years ago
|
@meeting.agenda.author = User.current
|
||
|
end
|
||
14 years ago
|
if @meeting.save
|
||
12 years ago
|
text = l(:notice_successful_create)
|
||
12 years ago
|
if User.current.time_zone.nil?
|
||
10 years ago
|
link = l(:notice_timezone_missing, zone: Time.zone)
|
||
10 years ago
|
text += " #{view_context.link_to(link, { controller: '/my', action: :account }, class: 'link_to_profile')}"
|
||
12 years ago
|
end
|
||
|
flash[:notice] = text.html_safe
|
||
|
|
||
10 years ago
|
redirect_to action: 'show', id: @meeting
|
||
14 years ago
|
else
|
||
9 years ago
|
render template: 'meetings/new', project_id: @project
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
|
|
||
|
def new
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
8 years ago
|
current_menu_item :new do
|
||
|
:meetings
|
||
|
end
|
||
|
|
||
14 years ago
|
def copy
|
||
14 years ago
|
params[:copied_from_meeting_id] = @meeting.id
|
||
|
params[:copied_meeting_agenda_text] = @meeting.agenda.text if @meeting.agenda.present?
|
||
10 years ago
|
@meeting = @meeting.copy(author: User.current)
|
||
|
render action: 'new', project_id: @project
|
||
14 years ago
|
end
|
||
|
|
||
|
def destroy
|
||
14 years ago
|
@meeting.destroy
|
||
14 years ago
|
flash[:notice] = l(:notice_successful_delete)
|
||
10 years ago
|
redirect_to action: 'index', project_id: @project
|
||
14 years ago
|
end
|
||
|
|
||
|
def edit
|
||
|
end
|
||
|
|
||
|
def update
|
||
9 years ago
|
@meeting.participants_attributes = @converted_params.delete(:participants_attributes)
|
||
|
@meeting.attributes = @converted_params
|
||
14 years ago
|
if @meeting.save
|
||
|
flash[:notice] = l(:notice_successful_update)
|
||
10 years ago
|
redirect_to action: 'show', id: @meeting
|
||
14 years ago
|
else
|
||
10 years ago
|
render action: 'edit'
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
14 years ago
|
private
|
||
13 years ago
|
|
||
12 years ago
|
def set_time_zone
|
||
|
old_time_zone = Time.zone
|
||
|
zone = User.current.time_zone
|
||
|
if zone.nil?
|
||
|
localzone = Time.now.utc_offset
|
||
10 years ago
|
localzone -= 3600 if Time.now.dst?
|
||
12 years ago
|
zone = ::ActiveSupport::TimeZone[localzone]
|
||
|
end
|
||
|
Time.zone = zone
|
||
|
yield
|
||
|
ensure
|
||
|
Time.zone = old_time_zone
|
||
|
end
|
||
|
|
||
14 years ago
|
def find_project
|
||
|
@project = Project.find(params[:project_id])
|
||
13 years ago
|
@meeting = Meeting.new
|
||
|
@meeting.project = @project
|
||
|
@meeting.author = User.current
|
||
14 years ago
|
end
|
||
13 years ago
|
|
||
14 years ago
|
def find_meeting
|
||
9 years ago
|
@meeting = Meeting
|
||
|
.includes([:project, :author, { participants: :user }, :agenda, :minutes])
|
||
|
.find(params[:id])
|
||
14 years ago
|
@project = @meeting.project
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
13 years ago
|
|
||
14 years ago
|
def convert_params
|
||
9 years ago
|
# We do some preprocessing of `meeting_params` that we will store in this
|
||
|
# instance variable.
|
||
7 years ago
|
@converted_params = meeting_params.to_h
|
||
9 years ago
|
|
||
|
@converted_params[:duration] = @converted_params[:duration].to_hours
|
||
14 years ago
|
# Force defaults on participants
|
||
9 years ago
|
@converted_params[:participants_attributes] ||= {}
|
||
|
@converted_params[:participants_attributes].each { |p| p.reverse_merge! attended: false, invited: false }
|
||
9 years ago
|
end
|
||
|
|
||
|
private
|
||
|
def meeting_params
|
||
|
params.require(:meeting).permit(:title, :location, :start_time, :duration, :start_date, :start_time_hour,
|
||
9 years ago
|
participants_attributes: [:email, :name, :invited, :attended, :user, :user_id, :meeting, :id])
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|