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
introduce new controller for time entry activities
Klaus Zanders1945b856042c
diff --git a/modules/costs/app/controllers/admin/costs_settings_controller.rb b/modules/costs/app/controllers/admin/costs_settings_controller.rbindex 28a71168d4f..9d8ff23ce6a 100644--- a/modules/costs/app/controllers/admin/costs_settings_controller.rb+++ b/modules/costs/app/controllers/admin/costs_settings_controller.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbHdiff --git a/modules/costs/app/controllers/admin/time_entry_activities_controller.rb b/modules/costs/app/controllers/admin/time_entry_activities_controller.rbnew file mode 100644index 00000000000..2f2bd265594--- /dev/null+++ b/modules/costs/app/controllers/admin/time_entry_activities_controller.rb@@ -0,0 +1,53 @@+# 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.+#++++module Admin+ class TimeEntryActivitiesController < ApplicationController+ # Allow only admins here+ before_action :require_admin+ layout "admin"++ menu_item :time_entry_activities++ def index; end++ def new; end++ def edit; end++ def create; end++ def update; end++ def destroy; end++ def move; end+ end+enddiff --git a/modules/costs/app/controllers/costlog_controller.rb b/modules/costs/app/controllers/costlog_controller.rbindex 8b00024b59c..b1811eb2420 100644--- a/modules/costs/app/controllers/costlog_controller.rb+++ b/modules/costs/app/controllers/costlog_controller.rb@@ -119,21 +119,21 @@ class CostlogController < ApplicationController@user = if @cost_entry.present? && @cost_entry.user_id == user_id@cost_entry.userelse- User.find_by_id(user_id)+ User.find_by(id: user_id)endwork_package_id = cost_entry_params.delete(:work_package_id)@work_package = if @cost_entry.present? && @cost_entry.work_package_id == work_package_id@cost_entry.work_packageelse- WorkPackage.find_by_id(work_package_id)+ WorkPackage.find_by(id: work_package_id)endcost_type_id = cost_entry_params.delete(:cost_type_id)@cost_type = if @cost_entry.present? && @cost_entry.cost_type_id == cost_type_id@cost_entry.cost_typeelse- CostType.find_by_id(cost_type_id)+ CostType.find_by(id: cost_type_id)endend@@ -142,7 +142,7 @@ class CostlogController < ApplicationControllerce.project = @projectce.work_package = @work_packagece.user = User.current- ce.spent_on = Date.today+ ce.spent_on = Time.zone.today# notice that cost_type is set to default cost_type in the modelendenddiff --git a/modules/costs/app/controllers/hourly_rates_controller.rb b/modules/costs/app/controllers/hourly_rates_controller.rbindex 50feea32249..73f1d4fc1b0 100644--- a/modules/costs/app/controllers/hourly_rates_controller.rb+++ b/modules/costs/app/controllers/hourly_rates_controller.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -72,10 +74,10 @@ class HourlyRatesController < ApplicationController@rates = DefaultHourlyRate.where(user_id: @user).order("#{DefaultHourlyRate.table_name}.valid_from desc").to_a- @rates << @user.default_rates.build(valid_from: Date.today) if @rates.empty?+ @rates << @user.default_rates.build(valid_from: Time.zone.today) if @rates.empty?else@rates = @user.rates.select { |r| r.project_id == @project.id }.sort { |a, b| b.valid_from <=> a.valid_from }.to_a- @rates << @user.rates.build(valid_from: Date.today, project: @project) if @rates.empty?+ @rates << @user.rates.build(valid_from: Time.zone.today, project: @project) if @rates.empty?endrender action: :edit, layout: !request.xhr?@@ -115,20 +117,20 @@ class HourlyRatesController < ApplicationControllerelseif @project.nil?@rates = @user.default_rates- @rates << @user.default_rates.build(valid_from: Date.today) if @rates.empty?+ @rates << @user.default_rates.build(valid_from: Time.zone.today) if @rates.empty?else@rates = @user.rates.select { |r| r.project_id == @project.id }- .sort { |a, b| b.valid_from || Date.today <=> a.valid_from || Date.today }- @rates << @user.rates.build(valid_from: Date.today, project: @project) if @rates.empty?+ .sort { |a, b| b.valid_from || Time.zone.today <=> a.valid_from || Time.zone.today }+ @rates << @user.rates.build(valid_from: Time.zone.today, project: @project) if @rates.empty?endrender action: :edit, layout: !request.xhr?endenddef set_rate- today = Date.today+ today = Time.zone.todayrate = @user.rate_at(today, @project)rate = HourlyRate.new if rate.nil? || rate.valid_from != todaydiff --git a/modules/costs/app/controllers/my/timer_controller.rb b/modules/costs/app/controllers/my/timer_controller.rbindex 46a33596e31..d3bde9cd283 100644--- a/modules/costs/app/controllers/my/timer_controller.rb+++ b/modules/costs/app/controllers/my/timer_controller.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbHdiff --git a/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb b/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rbindex f8231321fe5..0a877c0a1f7 100644--- a/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb+++ b/modules/costs/app/controllers/projects/settings/time_entry_activities_controller.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbHdiff --git a/modules/costs/app/views/admin/time_entry_activities/_form.html.erb b/modules/costs/app/views/admin/time_entry_activities/_form.html.erbnew file mode 100644index 00000000000..e69de29bb2ddiff --git a/modules/costs/app/views/admin/time_entry_activities/edit.html.erb b/modules/costs/app/views/admin/time_entry_activities/edit.html.erbnew file mode 100644index 00000000000..e69de29bb2ddiff --git a/modules/costs/app/views/admin/time_entry_activities/index.html.erb b/modules/costs/app/views/admin/time_entry_activities/index.html.erbnew file mode 100644index 00000000000..a1225ab52c3--- /dev/null+++ b/modules/costs/app/views/admin/time_entry_activities/index.html.erb@@ -0,0 +1,41 @@+<%#-- 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.++++#%>++<% html_title t(:label_administration), t(:enumeration_activities) %>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { I18n.t(:enumeration_activities) }+ header.with_breadcrumbs([+ { href: admin_index_path, text: t("label_administration") },+ { href: url_for({ controller: "/admin/costs_settings", action: "show" }), text: t(:project_module_costs) },+ I18n.t(:enumeration_activities)+ ])+ end+%>diff --git a/modules/costs/app/views/admin/time_entry_activities/new.html.erb b/modules/costs/app/views/admin/time_entry_activities/new.html.erbnew file mode 100644index 00000000000..e69de29bb2ddiff --git a/modules/costs/config/routes.rb b/modules/costs/config/routes.rbindex 1b9dc1a5690..e00afb5d3ce 100644--- a/modules/costs/config/routes.rb+++ b/modules/costs/config/routes.rb@@ -69,6 +69,10 @@ Rails.application.routes.draw doresources :hourly_rates, only: %i[edit update]namespace :admin do+ resources :time_entry_activities, except: [:show] do+ post :move+ end+resources :cost_types, only: %i[index new edit update create destroy] domember do# TODO: check if this can be replaced with update methoddiff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rbindex c196ed508db..eea7274ea30 100644--- a/modules/costs/lib/costs/engine.rb+++ b/modules/costs/lib/costs/engine.rb@@ -133,10 +133,17 @@ module Costsmenu :admin_menu,:cost_types,- { controller: "/admin/cost_types", action: "index" },+ { controller: "/admin/cost_types", action: :index },if: ->(*) { User.current.admin? },parent: :admin_costs,caption: :label_cost_type_plural++ menu :admin_menu,+ :time_entry_activities,+ { controller: "/admin/time_entry_activities", action: :index },+ if: ->(*) { User.current.admin? },+ parent: :admin_costs,+ caption: :enumeration_activitiesendinitializer "costs.settings" do