120 Commits

Author SHA1 Message Date
Jan Sandbrink f9d8bc6614 Introduce SubclassResponsibility error
This error is intended for cases when a method is
intentionally not implemented, because the module/class defining
it expects a subclass (or class including the module) to implement
the method.

This is intended to distinguish it from other cases, such as:
* feature not implemented yet
* edge case of a method call not yet supported

Notably it avoids the misuse of the Ruby-defined NotImplementedError,
which is only intended for much more specific scenarios:

> Raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception [...]

Also see https://docs.ruby-lang.org/en/master/NotImplementedError.html
2026-03-27 08:14:56 +01:00
Klaus Zanders cdaf14a82a Fix flaky BCF projects API spec returning 403 instead of 422
When the BCF API receives a request to change the project id
(e.g. `{ project_id: 0 }`), the SetAttributesService sets
`model.id = 0` in memory before the contract validates.

The contract's `validate_user_allowed_to_manage` correctly uses
`with_unchanged_id` to restore the original id before checking
permissions. However, `writable_attributes` was not protected the
same way — it checked permissions against the model with the
user-modified id (0), which doesn't exist.

This caused the UserPermissibleService's permission cache to be
populated with an entry for the model keyed at hash(0) with empty
permissions. When `validate_user_allowed_to_manage` later restored
the id and queried the cache at hash(original_id), Ruby's Hash could
exhibit undefined behavior due to the mutable key — during rehash
operations, the stale entry (empty permissions) could shadow the
correct one, causing the authorization check to intermittently fail
with 403 instead of the expected 422 (id not writable).

Wrap `writable_attributes` in `with_unchanged_id` so permission
checks always run against the original project, consistent with
`validate_user_allowed_to_manage`.
2026-03-25 11:59:15 +01:00
Ivan Kuchin 138d6500b2 handle writeableness of comments in project create contract 2026-02-25 20:07:03 +01:00
Ivan Kuchin d664e70c5f handle comment attribute in all contracts 2026-02-25 20:07:02 +01:00
Ivan Kuchin ca36e18701 allow custom comment attributes through project update contract 2026-02-25 16:00:28 +01:00
OpenProject Actions CI 69a38bf0c0 Merge branch 'release/17.1' into dev 2026-02-11 04:20:17 +00:00
Dombi Attila c8665b74d4 Make the assignee and comment fields optional in the project creation wizard. 2026-02-10 14:08:18 +02:00
Ivan Kuchin c747d98162 unify and mark with question boolean methods in update contract 2026-02-05 14:15:17 +01:00
Ivan Kuchin 06842e19cf rename method in projects update contract to reduce confusion
with_all_available_custom_fields_only =>
with_all_available_custom_fields, as it allows other changes too
2026-02-05 14:15:17 +01:00
Ivan Kuchin 891da06266 require enterprise feature in projects create contract 2025-11-26 20:12:57 +01:00
Jens Ulferts ca0770eeb2 Merge pull request #21144 from opf/implementation/67278-add-api-v3-workspaces-endpoints
Adding workspace types endpoints
2025-11-26 12:05:24 +01:00
Christophe Bliard bd4049142f Fix assignable check in create artifact work package contract
The `:work_package_assigned` permission has `granted_to_admin: false` so
`#allowed_in_project?(:work_package_assigned, project)` will always
return `false` for admins. Not sure why it's designed like this.

The check has been reworked to use the same logic as in
`WorkPackages::BaseContract#assignable_assignees` to prevent any other
potential issues.
2025-11-26 10:02:11 +01:00
ulferts d03bf6a763 adding workspace types endpoints 2025-11-25 16:32:58 +01:00
Mir Bhatia a637fcf59b Merge pull request #21169 from opf/implementation/69173-add-validations-and-update-strings-if-necessary-for-the-request-submission-tab
[#69173] Add validations and update strings if necessary for the request submission tab
2025-11-25 16:08:12 +01:00
Christophe Bliard 0df352215b Remove unneeded permission check for comment edition
Now that the work package is created directly with the right comment
through `journal_notes`, less permissions are needed.
2025-11-25 15:24:52 +01:00
Christophe Bliard 59613e98de Comment and mention the assignee in the artifact work package 2025-11-25 15:02:53 +01:00
Mir Bhatia d0fcf1ca50 Add submission tab validations 2025-11-25 14:45:57 +01:00
Christophe Bliard 8d2ac0835f Merge branch 'dev' into feature/68862-create-work-package-to-submit-project-initiation-request 2025-11-25 11:36:01 +01:00
Christophe Bliard 564c19f545 Assign artifact work package to the designated user
In a project initation request, the created artifact work package is
assigned to the user pointed by a user custom field. The user custom
field to get this user from is given by
`project.project_creation_wizard_assignee_custom_field_id`.
2025-11-24 17:50:25 +01:00
Christophe Bliard 2e15e26b6c Fix rubocop warnings about ABC metrics size 2025-11-24 16:11:32 +01:00
Christophe Bliard b1c6989ca4 Check :add_work_package permission for artifact work package creation 2025-11-24 15:34:35 +01:00
Christophe Bliard 9eb18a7331 Ensure only one error is shown if PIR is disabled
When Project Initiation Request is disabled, no need to display errors about the status being not set (for instance).
2025-11-24 15:34:34 +01:00
Ivan Kuchin 5554fba3c2 use invalid instead of does not exist error when parent is not amongst assignable 2025-11-24 13:51:08 +01:00
Christophe Bliard 5e5a01e37f Create artifact work package on project initiation request submission
https://community.openproject.org/wp/68862

A service takes care of creating the artifact work package.
2025-11-24 09:52:00 +01:00
Mir Bhatia ae668ba737 Update submission attribute names 2025-11-21 13:32:54 +01:00
Oliver Günther e46fc48429 Merge pull request #21099 from opf/implementation/69041-name-tab
[#69041] Name tab
2025-11-20 14:15:06 +01:00
Dombi Attila c4984ade97 [#69034] Change enforcement of project attributes on creation for templates
https://community.openproject.org/work_packages/69034
2025-11-19 20:14:09 +02:00
Mir Bhatia ed5b5197c6 Add form with placeholder select list 2025-11-19 17:25:34 +01:00
Mir Bhatia 93e1c17b93 Incorporate PR feedback 2025-11-19 13:40:27 +01:00
Mir Bhatia fd15e46458 Add specs 2025-11-18 17:57:56 +01:00
Dombi Attila 2aae862d8a [#63550] Allow editing of individual work package/project attributes even if certain other attributes are invalid (eg. required field empty)
https://community.openproject.org/work_packages/63550
2025-10-14 12:01:58 +02:00
Dombi Attila 7b1fd5f09a Add program creation form and global permission. 2025-08-22 15:23:16 +03:00
Christophe Bliard bd3aa2a031 Move Project.workspace_type validation from contract to model
This is to prevent being able to save a project with a nil workspace
type. That would lead to an error due to a non-null constraint
violation.
2025-08-22 10:56:57 +02:00
ulferts 5104117b52 move assignable_parents loging into scope 2025-08-21 10:30:02 +03:00
ulferts 64805d3bba add portfolio creation using existing project creation 2025-08-21 10:29:56 +03:00
Alexander Brandon Coles f304839f1d Merge branch 'dev' into merge-release/16.3-20250815034933 2025-08-15 13:42:46 +01:00
Dombi Attila 59bf8ccfc9 Use where condition on all_available_custom_fields and move it to a private contract method. 2025-08-13 00:44:47 +03:00
Dombi Attila 8c4c2b104d [#66298] It is possible to assign disabled and/or admin only project attributes given only edit permission
https://community.openproject.org/work_packages/66298
2025-08-08 09:00:19 +03:00
ulferts 6958eb8b62 use create service as base
That way, when copying e.g. workspace_type is a writable attribute
2025-08-04 16:43:46 +02:00
ulferts 3475661416 writable workspace_type attribute on project creation 2025-08-04 16:43:45 +02:00
Alexander Brandon Coles 0091ee164d Freeze string literals in app/contracts
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze app/contracts
2025-07-18 17:51:41 +01:00
Jan Sandbrink c753ce6e30 Replace with_merged_former_errors by validate_and_merge_errors
The main problem with the previous method was that it only worked
if the contract being validated inside the block was sharing the same
errors object as the contract calling it. The old implementation
was incapable of incorporating errors from a contract that had its
own errors object.

In my opinion it's a code smell that our contracts use the #errors
of the model they are validating as the place to store their validation
result, however I didn't dare touching this yet, because changing that
would certainly be a huge change. I can also imagine that some places rely
on it for historic reasons (because using "classic" validations also
puts the errors on the model). However, I think that no two contracts
should RELY on using the SAME errors object, just because the way we implemented
them happens to cause them to share the same object.
2025-02-11 10:51:49 +01:00
Dombi Attila d2ecd68ea5 Use single line method definitions for defining context validations 2025-01-23 16:43:36 +02:00
Dombi Attila 14725bce40 [#60666] User can't save lifecycle modal if project is invalid
https://community.openproject.org/work_packages/60666
2025-01-20 20:40:03 +02:00
Dombi Attila 850fd795cd Invert visible logic to admin_only? 2024-08-07 15:38:27 +03:00
Oliver Günther 12ee9e6b83 Merge remote-tracking branch 'origin/idea/56781-remove-years-from-copyrights' into dev 2024-08-06 10:17:59 +02:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Dombi Attila 4ba63551eb Allow writable attributes on the Projects::Create contract when the user has copy_projects permission 2024-07-29 16:47:45 +03:00
Dombi Attila 1611630ef4 Update the Projects::CreateContract to set writable custom fields based on permissions
When the user has :add_project or :edit_project_attributes set the
project attributes to be writable
2024-07-29 16:47:45 +03:00
Dombi Attila 2ed8c330a2 Move Project's available custom fields overrides to their corresponding Project contract class 2024-07-29 16:47:42 +03:00