81 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
Dombi Attila 2e624b1326 [#70982] 'For all projects' project attributes are not displayed during new project creation
https://community.openproject.org/work_packages/70982
2026-01-26 14:16:26 +02:00
Dombi Attila 42c4713734 Use custom_field_values, because that one has all the values initialized. 2026-01-11 00:04:42 +02:00
Dombi Attila 54bb7a6468 Move the project custom field validation changes to the service level instead of the model level. 2026-01-11 00:04:42 +02:00
Dombi Attila afe40b9239 Omit selective custom field validation, when the customizable object is not peristed. 2026-01-10 11:40:47 +02:00
Oliver Günther 5d9272818a Ensure we take over the project role in members dependent service 2025-12-04 18:42:17 +01:00
Oliver Günther 28fae53f35 Ensure a project role is created before copy of dependencies 2025-12-04 18:42:17 +01:00
Dombi Attila 53b0c14191 Skip validating custom fields when creating a project from a template. 2025-11-19 20:14:10 +02:00
Dombi Attila f116987350 Fix rubocop complaint. 2025-10-14 12:01:58 +02:00
Dombi Attila eb0a59fc60 Do not clear the custom_values_to_validate in the set attribute service, if there are no custom fields to be validated.
This behaviour change allows the custom_values_to_validate array to be
set in other services that are using the WorkPackage::UpdateService.
Currently only the CustomActions::UpdateWorkPackageService is using the
validation array.
2025-10-14 12:01:58 +02:00
Dombi Attila e37be13dc9 Add work package api resource specs 2025-10-14 12:01:58 +02:00
Dombi Attila 27c7db953f Update the SetAttributesService to handle different custom field setters when finding cfs to validate. 2025-10-14 12:01:58 +02: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
Alexander Brandon Coles 5e9f3827f5 Freeze string literals in app/services
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze app/services
2025-07-18 17:45:24 +01:00
Pavel Balashou d187b2aab7 Merge remote-tracking branch 'origin/dev' into feature/62107-add-scim-server-api 2025-07-01 10:02:12 +02:00
Jan Sandbrink 40aff02f11 Remove params argument from BaseCallable#perform
This is making the interface of BaseCallable more consistent.
Previously it was unclear, whether the params passed to perform
should be used to reference parameters or whether the attribute accessor
should be used. Different code used different approaches.

To apply this change more consistently, BaseContracted also removed
params from the methods called inside its own perform method, e.g.
before_perform or after_validate.

At a later point we might consider removing this argument from other large
inheritors as well, for example `BaseServices::SetAttributes#set_attributes`.
2025-06-30 11:47:03 +02:00
Pavel Balashou 5fe52f3a64 [#62107] Update a few SCIM related things.
- Enable SCIM Patch.
- Use user_auth_provider_links instead of users.identity_url.
- Extend SCIM ActiveRecord base scopes to join and preload appropriate associations.
- Set a stub for user.firstname and user.lastname if they are not provided by SCIM client.
- Handle user unique constraint vialation according to SCIM spec.
- Move user_auth_provider_links association to principal as group needs it as well.
- Set user.mail dynamically from the list of emails provided by SCIM client.
- Change BaseServices::Create contract to accept model instance as a constructor parameter.
  It gives an option to build associations before model creation.
- extend SCIM server API schema to include externalId.
- Adjust specs.
2025-06-17 11:03:28 +02:00
Jens Ulferts 064ac20fa3 Merge pull request #18672 from opf/feature/61610-date-picker-to-edit-phases-and-phase-gates-of-a-project-lifecyle-2
Feature/61610 date picker to edit phases and phase gates of a project lifecycle (2/2)
2025-05-28 17:12:11 +02:00
Dombi Attila a6c8cb9a0c Move phase setter methods to the set attribute service 2025-05-27 23:17:40 +03:00
Christophe Bliard 45504b2437 refactor: Conflate WithReversibleState into BaseCallable
`WithReversibleState` was only used by `BaseCallable`. Having it inlined
makes it easier to understand the code.
2025-05-26 10:59:59 +02:00
Christophe Bliard 886d4c917c Do not switch scheduling mode if it's during a bulk copy
This fixes the failing test which tested a bluk copy of two manually
scheduled work packages being parent and child. The test was failing
because the parent switched to automatic scheduling mode.
spec is `./spec/controllers/work_packages/moves_controller_spec.rb:504`

It uses the `state` present in services inheriting from `BaseCallable`
to pass a `bulk_copy_in_progress` flag which is then checked in the
`UpdateAncestorsService`.
2025-03-17 10:47:26 +01:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Ivan Kuchin 192e21cd9e manual rubocop corrections 2024-05-30 19:54:08 +02:00
Ivan Kuchin fa5d03eae0 rubocop safe autocorrect all except Rails/WhereRange 2024-05-30 19:54:08 +02:00
Aaron Contreras 9ac2f1cd18 Run rubocop -a on app/services 2024-03-01 18:16:56 -05:00
Christophe Bliard c795874f7f Update copyright year for 2024
command used: `rg -l 'Copyright \(C\) 2012-202\d the OpenProject' | xargs -n 100 sed -i -r 's/Copyright \(C\) 2012-202. the OpenProject/Copyright (C) 2012-2024 the OpenProject/'`
2024-01-02 16:23:54 +01:00
ulferts e6e5f9caab enable default notifications on project copy 2023-03-06 15:54:46 +01:00
Christophe Bliard a06e519ed7 Set send_notifications only when not nil
When calling a service with `send_notifications: false`, the
`Journal::NotificationConfiguration.active?` will be set to `false` and
subsequent calls to set it to `true` will have no effect and log a
warning.

For this reason, it's better to use `nil` as default value for
`send_notifications` so that
`Journal::NotificationConfiguration.active?` is changed only when the
value is explicitly `true` or `false`, and ignored when the value is
`nil`.
2023-02-27 17:47:34 +01:00
Christophe Bliard 31725683a6 refactor: use keyword arg for send_notifications
This makes rubocop happier
2023-02-27 14:16:04 +01:00
Oliver Günther 863ffe3341 Merge remote-tracking branch 'origin/release/12.4' into dev 2023-02-23 16:18:51 +01:00
Oliver Günther 447151fc98 Restore suppressing of notifications in groups service 2023-02-22 14:24:01 +01:00
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01:00
ulferts 65f42b56c3 allow defining dependencies for copy dependencies
It is then used to move the attachment dependencies into the copy dependencies of WorkPackage and Wiki
2022-10-05 12:50:35 +02:00
ulferts 0a63b01039 reuse superclasses for copy service 2022-10-05 12:50:32 +02:00
ulferts d6ca654903 decrease overwriting of superclass method 2022-10-05 12:50:32 +02:00
Christophe Bliard b50855a955 Use ServiceResult factory methods where possible
All was automatic through the use of `rubocop --autocorrect --only
OpenProject/UseServiceResultFactoryMethods app lib lib_static modules
spec`.
2022-06-16 10:01:57 +02:00
ulferts 8868186415 skip validating automatically calculated values 2022-06-13 15:41:53 +02:00
Christophe Bliard 48a4f1b6ad lint with rubocop --autocorrect (safe cops only) 2022-06-02 10:40:10 +02:00
Oliver Günther 9243094347 Replace create_query helper with default endpoint 2022-04-04 09:56:39 +02:00
Christophe Bliard 0138610c3c refactor: make syntax more explicit 2022-03-23 15:14:47 +01:00
Christophe Bliard 4aab84d6ff Merge remote-tracking branch 'origin/dev' into feature/file-links 2022-03-11 14:22:15 +01:00
Christophe Bliard a33524ef6d remove ruby magic comment for utf-8
ruby interprets source encoding as utf-8 since 2.0.0, making magic comment redundant and useless
2022-03-10 19:36:58 +01:00
Christophe Bliard d983d7601f Merge branch 'dev' into feature/file-links 2022-03-02 14:03:03 +01:00
Christophe Bliard bc8d423ec2 update copyright information for 2022 2022-03-01 17:05:59 +01:00
Christophe Bliard 064c085bb7 make some code easier to read 2022-02-15 15:32:58 +01:00
ulferts e63eebeca0 only keyword parameters on service calls 2022-01-07 13:28:53 +01:00
Oliver Günther 7908c7eebe Validate a separate params contract 2021-09-27 10:55:26 +02:00
Oliver Günther ccfa29c728 Move license and copyright docs to root, fix names and references 2021-09-02 21:50:46 +02:00
Oliver Günther e9d7c374cc [37868] Whitelist for attachment mime types and extensions on upload (#9431)
* Add setting for whitelist

* Make attachments API BaseServices compatible

* Add prepare service and contract

* Correctly pass the filename to the UploadedFile

* Add presence check to filename

* Fix expected validation message

* We no longer raise a multipart error when metadata is empty

* Fix filesize validation on prepared uploads

* Add parser error if invalid metadata json

* When attachment is not saved, use filename property

* Return correct error message on JSON parser erroro

* Fix specs

* Use attachment upload representer

* Fix direct uploads mocks with new service layer

* Lint

* Fix export job using attachment service

* Fix IFC controller using attachment prepare service

* Fix export job

* RenameRename params_getter to params_source

* Fix mail handler using attachment service

* Fix usage of attachment create service in documents

* Reuse shared examples for document attachment spec

* Fix stubbed attachment service in export job spec

* Use admin user in backup spec

* Fix export job for bim

* Fix attachment integration spec

* Fix issues_controller spec

* Make budget resource spec reuse common examples

* Fix attachment parsing representer spec

* Replace prepare part of attachment spec into separate service spec

* Clear cache for login spec

* Convert document create/update into services

* Budget services

* Allow options to be passed to property twin

* Remove setting author on budget initialize

* Replace meetings update with services

* Replace ifc models attachment handling with services

* Don't check uploader if changed by system

* Fix uploader being changed by system

* Replace wiki page attach_files with attachable services

* Replace avatar  saving

* Replace snapshot attach_files

* Skip double validation when container present

* Set snapshot through attachment service

* Remove attach_files

* Validate content type in contract

* Enforce writing the content type without accepting user input

* Expect changed content_type

* Fix content of viewpoint image to get correct content type

* Fix tsv spec

* Add create contract spec

* Bypass whitelist in internal services when conflicting with user

* Fix expects in specs after whitelist bypass

* Render contract errors for wiki

* Add before_hook to bodied to allow to pre-authorize permissions

* Budget errors from contract

* Document errors from contract
2021-07-14 14:43:19 +02:00
ulferts d1f419385f Feature/member custom notifications (#9173)
* include custom message in membership forms

* keep pristine params to be able to pass it to the state

* fix indentation on projects api docs

* pass grape instance around in default endpoints

The grape instance has readily available access to all the objects (params, current_user) so less individual parameters need to be passed. This also avoids having to store the grape endpoint in a potentials not thread safe variable

* send custom message out on membership creation

* send custom message on membership update

* send custom message even if setting disabled

* restore params interface

* add custom message description to schema

* describe notificationMessage in the api documentation

* extract meta payload functionality into mixin

* ensure password in spec meets requirements

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

* Update docs/api/apiv3/endpoints/members.apib

Co-authored-by: Oliver Günther <mail@oliverguenther.de>

Co-authored-by: Oliver Günther <mail@oliverguenther.de>
2021-04-26 16:26:04 +02:00