Skip to content

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

fix some ToDos

Christophe Bliard080a4686bc29
diff --git a/modules/storages/app/cells/storages/storages_row_cell.rb b/modules/storages/app/cells/storages/storages_row_cell.rb
index 493a9fe5bf6..ad1a49a1110 100644
--- a/modules/storages/app/cells/storages/storages_row_cell.rb
+++ b/modules/storages/app/cells/storages/storages_row_cell.rb
@@ -1,6 +1,6 @@
# Purpose: Defines the row model for the table of Storage objects
# Used by: Storage table in storages_table_cell.rb
-# Reference: RubyCells???
+# Reference: https://trailblazer.to/2.0/gems/cells.html
module Storages
class StoragesRowCell < ::RowCell
include ::IconsHelper # Global helper for icons, defines op_icon and icon_wrapper?
@@ -12,7 +12,7 @@ module Storages
end
# Delegate delegates the execution of certain methods to :model.
- # ToDo: I'm not sure why this makes sense here.
+ # https://www.rubydoc.info/gems/activesupport/Module:delegate
delegate :host, to: :model
delegate :provider_type, to: :model
diff --git a/modules/storages/app/cells/storages/storages_table_cell.rb b/modules/storages/app/cells/storages/storages_table_cell.rb
index c846d9b86d8..dcbcc696d4a 100644
--- a/modules/storages/app/cells/storages/storages_table_cell.rb
+++ b/modules/storages/app/cells/storages/storages_table_cell.rb
@@ -2,13 +2,12 @@
# objects in the global admin section of OpenProject
# Used by: the admin list of all storages in the system
# (storages/app/views/storages/admin/index.html.erb)
-# Reference: RailsCells???, ToDo: no documentation found
+# Reference: https://trailblazer.to/2.0/gems/cells.html
# See also: storage_row_cell.rb with the row model of the table
module Storages
class StoragesTableCell < ::TableCell
include ::IconsHelper # Global helper for icons, defines op_icon(...)
- # ???
class << self
def row_class
::Storages::StoragesRowCell
@@ -30,8 +29,8 @@ module Storages
false
end
- # Used by: ???
- # Purpose: ???
+ # Used by: app/cells/views/table/show.erb and
+ # Purpose: return the link to be used to create the storage
def inline_create_link
link_to(new_storage_path,
class: 'wp-inline-create--add-link',
diff --git a/modules/storages/app/contracts/storages/file_links/delete_contract.rb b/modules/storages/app/contracts/storages/file_links/delete_contract.rb
index d0a97558c63..b4a9c62133c 100644
--- a/modules/storages/app/contracts/storages/file_links/delete_contract.rb
+++ b/modules/storages/app/contracts/storages/file_links/delete_contract.rb
@@ -26,15 +26,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-# ToDo: Why is there only one contract for FileLinks?
-# Used by: ???
-# Why here two module blocks instead of Storages::FileLinks?
+# Purpose: validate the model before deletion
+# Used by: Storages::FileLinks::DeleteService (looked up in BaseServices::Delete#default_contract_class)
module Storages
module FileLinks
class DeleteContract < ::ModelContract
# ToDo: What is this? Where is this used?
def self.model
- Storages::FileLink
+ ::Storages::FileLink
end
# Check permissions to delete(?) this FileLink
diff --git a/modules/storages/app/contracts/storages/storages/base_contract.rb b/modules/storages/app/contracts/storages/storages/base_contract.rb
index 0a0dc95d04b..81d2f52ec64 100644
--- a/modules/storages/app/contracts/storages/storages/base_contract.rb
+++ b/modules/storages/app/contracts/storages/storages/base_contract.rb
@@ -29,8 +29,8 @@
require 'net/http'
require 'uri'
-# Called by: Somewhere from within a service (ToDo:)
-# UpdateServer by default checks if UpdateContract exists
+# Purpose: common functionalities shared by CreateContract and UpdateContract
+# UpdateService by default checks if UpdateContract exists
# and uses the contract to validate the model under consideration
# (normally it's a model).
module Storages::Storages
diff --git a/modules/storages/app/contracts/storages/storages/concerns/manage_storages_guarded.rb b/modules/storages/app/contracts/storages/storages/concerns/manage_storages_guarded.rb
index a1166c3043d..cece3d1fd99 100644
--- a/modules/storages/app/contracts/storages/storages/concerns/manage_storages_guarded.rb
+++ b/modules/storages/app/contracts/storages/storages/concerns/manage_storages_guarded.rb
@@ -35,9 +35,7 @@
# Reference: Here is a tutorial about concerns. They basically inject
# the content of the "included do ... end" block into their target.
# http://vaidehijoshi.github.io/blog/2015/10/13/stop-worrying-and-start-being-concerned-activesupport-concerns/
-# Used by: ToDo: Check usage.
-# ToDo: Why is this in a different from before_xxx authenticate?
-# ToDo: Is this really used multiple times?
+# Used by: Storages::Storages::BaseContract and Storages::Storages::DeleteContract
# Returns: An array of errors with section and code
module Storages::Storages
module Concerns
@@ -54,7 +52,7 @@ module Storages::Storages
private
- # Small procedure to check that the current user is (global?)admin and active
+ # Small procedure to check that the current user is admin and active
def validate_user_allowed_to_manage
unless user.admin? && user.active?
errors.add :base, :error_unauthorized
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 045cd894426..33818a725fc 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -29,23 +29,21 @@
#++
# Purpose: CRUD the global admin page of Storages (=Nextcloud servers)
-# ToDo: Why not use double "module"
-# ToDo: What Wieland already explained ::Module vs. Module (without ::)
class Storages::Admin::StoragesController < ApplicationController
- # ToDo: Where is this used?
- # I assume this will create a page layout for a global OpenProject admin page
+ # See https://guides.rubyonrails.org/layouts_and_rendering.html for reference on layout
layout 'admin'
- # I assume this is necessary because of the non-standard path of this controller?
+ # specify which model #find_model_object should look up
model_object Storages::Storage
# Before executing any action below: Make sure the current user is an admin
- # and set the @<controller_name> variable to the object refernced in the URL.???
+ # and set the @<controller_name> variable to the object referenced in the URL.
before_action :require_admin
before_action :find_model_object, only: %i[show destroy edit update]
- # ToDo: Where is this used?
- # I understand this will create(???) a menu item in Admin to Storages
+ # menu_item is defined in the Redmine::MenuManager::MenuController
+ # module, included from ApplicationController.
+ # The menu item is defined in the engine.rb
menu_item :storages_admin_settings
# Index page with a list of Storages objects
@@ -65,39 +63,33 @@ class Storages::Admin::StoragesController < ApplicationController
end
# Show the admin page to create a new Storage object.
- # Sets the attributes provider_type and name for the service(???)
- # as default values and then renders the new page (allowing the user
- # to overwrite these values and to fill in other attributes).
+ # Sets the attributes provider_type and name as default values and then
+ # renders the new page (allowing the user to overwrite these values and to
+ # fill in other attributes).
# Used by: The index page above, when the user presses the (+) button.
# Called by: Global app/config/routes.rb to serve Web page
def new
# Set default parameters using a "service".
# See also: storages/services/storages/storages/set_attributes_services.rb
- # See also: ToDo: Service documentation from Wieland
+ # See also: https://www.openproject.org/docs/development/concepts/contracted-services/
# That service inherits from ::BaseServices::SetAttributes
- # ToDo: I don't understand where call(...) is defined, and what this
- # service actually does.
@object = ::Storages::Storages::SetAttributesService
.new(user: current_user,
model: Storages::Storage.new,
contract_class: EmptyContract)
- .call({ provider_type: 'nextcloud', name: I18n.t('storages.provider_types.nextcloud') })
+ .call(provider_type: 'nextcloud', name: I18n.t('storages.provider_types.nextcloud'))
.result
- # What about error processing in case the service returns nil???
# Render the new page in a slightly off-standard location
+ # Error handling is done in the view page
render 'storages/admin/new'
end
- # ToDo: RuboCop: Metrics/AbcSize: Assignment Branch Condition size for create is too high. [<7, 21, 2> 22.23/17]
- # ToDo: Move the comments back into the method
# Actually create a Storage object.
# Overwrite the creator_id with the current_user. Is this this pattern always used?
# Use service pattern to create a new Storage
# See also: storages/services/storages/storages/create_service.rb
- # storage_path is automagically created by Ruby controller for the Storage object.
- # Just render a response to (un-)successful creation.
- # respond_to takes a URL parameter about the format. Only HTML is supported here.
+ # See also: https://www.openproject.org/docs/development/concepts/contracted-services/
# Called by: Global app/config/routes.rb to serve Web page
# rubocop:disable Metrics/AbcSize
def create
@@ -106,19 +98,12 @@ class Storages::Admin::StoragesController < ApplicationController
@object = service_result.result
if service_result.success?
- respond_to do |format|
- format.html do
- flash[:notice] = I18n.t(:notice_successful_create)
- redirect_to storage_path(@object)
- end
- end
+ flash[:notice] = I18n.t(:notice_successful_create)
+ # storage_path is automagically created by Ruby routes.
+ redirect_to storage_path(@object)
else
@errors = service_result.errors
- respond_to do |format|
- format.html do
- render 'storages/admin/new'
- end
- end
+ render 'storages/admin/new'
end
end
# rubocop:enable Metrics/AbcSize
@@ -131,28 +116,20 @@ class Storages::Admin::StoragesController < ApplicationController
end
# Update is similar to create above
- # Also see: create above
+ # See also: create above
+ # See also: https://www.openproject.org/docs/development/concepts/contracted-services/
# Called by: Global app/config/routes.rb to serve Web page
def update
- # ToDo: Multi-line call to service instead of one-line above
service_result = ::Storages::Storages::UpdateService
.new(user: current_user,
model: @object)
.call(permitted_storage_params)
if service_result.success?
- respond_to do |format|
- format.html do
- flash[:notice] = I18n.t(:notice_successful_update)
- redirect_to storage_path(@object)
- end
- end
+ flash[:notice] = I18n.t(:notice_successful_update)
+ redirect_to storage_path(@object)
else
- respond_to do |format|
- format.html do
- render action: :edit
- end
- end
+ render action: :edit
end
end
@@ -163,19 +140,14 @@ class Storages::Admin::StoragesController < ApplicationController
.new(user: User.current, model: @object)
.call
- # ToDo: Where is "flash" defined
# Displays a message box on the next page
flash[:info] = I18n.t(:notice_successful_delete)
# Redirect to the index page
- respond_to do |format|
- format.html do
- redirect_to storages_path
- end
- end
+ redirect_to storages_path
end
- # Used by: ToDo:
+ # Used by: admin layout
# Breadcrumbs is something like OpenProject > Admin > Storages.
# This returns the name of the last part (Storages admin page)
def default_breadcrumb
@@ -197,7 +169,6 @@ class Storages::Admin::StoragesController < ApplicationController
# Called by create and update above in order to check if the
# update parameters are correctly set.
def permitted_storage_params
- # ToDo: How does :storages_storage work? Isn't this "id"? Who transforms?
params
.require(:storages_storage)
.permit('name', 'provider_type', 'host')
diff --git a/modules/storages/app/models/queries/storages/file_links/file_link_query.rb b/modules/storages/app/models/queries/storages/file_links/file_link_query.rb
index 7b3418e4976..cafc0df9841 100644
--- a/modules/storages/app/models/queries/storages/file_links/file_link_query.rb
+++ b/modules/storages/app/models/queries/storages/file_links/file_link_query.rb
@@ -28,12 +28,9 @@
# Purpose: When returning a collection of file links, our standard index endpoint needs a query class to have a
# reference to the embedded model.
-# Used by: ???
-# Reference: ToDo: Link to documentation about queries
# The namespace is programmatically derived from the model name. See app/services/params_to_query_service.rb:130
class Queries::Storages::FileLinks::FileLinkQuery < Queries::BaseQuery
- # What is class << self?
class << self
# We need to overwrite the model method, as the standard implementation cannot derive the name from nested
# namespaces. See app/models/queries/base_query.rb:31
diff --git a/modules/storages/app/models/storages/file_link.rb b/modules/storages/app/models/storages/file_link.rb
index 33bb7e13155..0157be05ebe 100644
--- a/modules/storages/app/models/storages/file_link.rb
+++ b/modules/storages/app/models/storages/file_link.rb
@@ -49,9 +49,11 @@ class Storages::FileLink < ApplicationRecord
# A standard Rails custom query:
# https://www.rubyguides.com/2019/10/scopes-in-ruby-on-rails/
- # Purpose: ToDo: not clear what this condition means
- # Used by: ToDo:
+ # Purpose: limit to FileLink visible by given user.
+ # Used by: FileLinksAPI#visible_file_links_scope and WorkPackagesFileLinksAPI#visible_file_links_scope
scope :visible, ->(user = User.current) {
+ # join projects through the container, and filter on projects visible from
+ # the user
includes(:container)
.includes(container: :project)
.references(:projects)
diff --git a/modules/storages/app/services/storages/project_storages/set_attributes_service.rb b/modules/storages/app/services/storages/project_storages/set_attributes_service.rb
index 93556160ce0..3ea38952125 100644
--- a/modules/storages/app/services/storages/project_storages/set_attributes_service.rb
+++ b/modules/storages/app/services/storages/project_storages/set_attributes_service.rb
@@ -26,8 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-# ToDo: Where is this used?
-# It's called by CreateService when setting attributes
+# Used by: CreateService when setting attributes
module Storages::ProjectStorages
class SetAttributesService < ::BaseServices::SetAttributes
end