OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
# frozen_string_literal: true
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# 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 COPYRIGHT and LICENSE files for more details.
#++
class Activities::MeetingActivityProvider < Activities::BaseActivityProvider
activity_provider_for type: "meetings",
activities: %i[meeting],
permission: :view_meetings
def event_query_projection
case activity
when :meeting
[
activity_journal_projection_statement(:title, "meeting_title"),
activity_journal_projection_statement(:start_time, "meeting_start_time"),
activity_journal_projection_statement(:duration, "meeting_duration"),
activity_journal_projection_statement(:project_id, "project_id")
]
else
[
projection_statement(meetings_table, :id, "meeting_id"),
projection_statement(meetings_table, :title, "meeting_title"),
projection_statement(meetings_table, :project_id, "project_id")
]
end
end
def activitied_type
Meeting
end
def projects_reference_table
case activity
when :meeting
activity_journals_table
else
meetings_table
end
end
def activity_journals_table
@activity_journals_table ||= Meeting.journal_class.arel_table
end
protected
def event_title(event)
start_time =
if event["meeting_start_time"].is_a?(String)
DateTime.parse(event["meeting_start_time"])
else
event["meeting_start_time"]
end
end_time = start_time + event["meeting_duration"].to_f.hours
fstart_with = format_date start_time
fstart_without = format_time start_time, include_date: false
fend_without = format_time end_time, include_date: false
"#{I18n.t(:label_meeting)}: #{event['meeting_title']} (#{fstart_with} #{fstart_without}-#{fend_without})"
end
def event_type(event)
"meeting"
end
def event_path(event)
id = activity_id(event)
url_helpers.meeting_path(id)
end
def event_url(event)
id = activity_id(event)
url_helpers.meeting_url(id)
end
def event_selection_query(user, from, to, options)
query = journals_with_data_query
query = extend_event_query(query)
query = filter_for_event_datetime(query, from, to)
query = restrict_user(query, options)
query = restrict_meeting(query, options)
restrict_projects(query, user, options)
end
def restrict_meeting(query, options)
query = query.where(journals_table[:journable_id].eq(options[:meeting].id)) if options[:meeting]
query
end
private
def meetings_table
@meetings_table ||= Meeting.arel_table
end
def activity_id(event)
activity == :meeting ? event["journable_id"] : event["meeting_id"]
end
end