35 Commits

Author SHA1 Message Date
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
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
Christophe Bliard 3c5a6f50d5 Switch to manual scheduling mode during rescheduling of dependencies
When a work package no longer have any predecessors (direct or indirect)
nor children, then it must switch to manual scheduling mode to keep its
dates.

This is now handled directly by the `WorkPackages::SetScheduleService`.
This simplifies the logic of `Relations::DeleteService` which no longer
has to switch a successor to manual by itself. It's all handled in the
ScheduleService.
2025-02-25 09:18:26 +01:00
Christophe Bliard 311ce0fea4 [59539] Reschedule successor when deleting a follows relation
When there are multiple predecessors for one work package, and one of
them is deleted, the successor must be rescheduled.

Common rescheduling code with `CreateService` and `UpdateService` has
been moved to `Relations::Concerns::Rescheduling` module.
2025-02-25 09:12:31 +01:00
Christophe Bliard 26fbc5522a [59539] switch scheduling mode when modifying follows relations
When a work package becomes a successor of another work package, its
scheduling mode is switched to automatic if it has no children so that
it can be scheduled as soon as possible automatically.

Similarly, when a work package is no longer a successor of any other
work package, its scheduling mode is switched to manual if it has no
children and no dates so that it can keep its current dates.
2025-02-25 09:12:25 +01:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Oliver Günther e3e8d78972 Rename delay to lag
https://community.openproject.org/work_packages/44054
2024-04-08 19:31:38 +02: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 d2ea6e9f66 remove typed_dag error handling - no longer raisable 2023-10-24 11:53:17 +02:00
Christophe Bliard 9e865b4f7b lint: Run rubocop safe autocorrect
Command is `rubocop --safe --autocorrect app lib lib_static modules spec`
2023-03-09 10:25:57 +01:00
Christophe Bliard c43fccf246 lint: autocorrect Style/HashSyntax
command is

    rubocop -A --only Style/HashSyntax app lib lib_static modules spec
2023-03-07 15:07:44 +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
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01: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
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 bc8d423ec2 update copyright information for 2022 2022-03-01 17:05:59 +01:00
ulferts 8d72897f62 use standard interface for relation create service 2021-12-06 11:29:38 +01: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 f50297227b [34444] Projects copy APIv3 (#9149)
* Create copy project endpoint

* Add representers

* Add _meta representer for copy module information

* Add Meta payload representer

* Extract parsing of copy attributes into service

* Extract enqueue job for projects copy

* Keep request object available in the bodied endpoint

this allows us to access grape (e.g., for redirecting)

* Add DelayedModify endpoint that redirects to job status

* Use DelayedModify endpoint for copying projects

* Add api paths for form/copy

* Disable cache on ProjectCopyPayload

* Add spec

* Add resource spec

* Extend schema for meta

* Extend docs

* Don't pass service result, but state as meta to forms

* Use copy dependencies for naming copy options in API

* Add description property for counting

* Remove unused action attribute

* Skip writable checks on meta property for payloads

* Use prepend to allow create(...) usage with meta

* Extend copy spec with custom fields usage

* Add spec for copy flags

* Add todos

* Pass errors correctly to copy settings

* Remove invalid parameters to copy that are now caught through project service

* Remove duplicated validation

* Linting

* Make count a human readable, formattable description string

* Make source count string readable

* Provide the source project for generating the counts

* Extract copying of attachments into sepearate dependent services

This will allow the API to dynamically generate a copy association schema from each dependent service

* Add spec for copy schema representer

* Add payload representer spec

* Also validate the model to pass the validations when copying

* Make description optional and add note to schemas.apib

* Add send_notifications to representer

* Allow to configure sendNotifications

* Allow bodied to receive a state process callback

That allows us to manage the meta state on the API level, not on the service level

* Make other services compatible with BaseCallable

* Fix params passing from BaseCallable

Wrapping a single hash into kwargs obviously loses their key indifference
and we can't expect all services to use a single params object. Older services use kwargs

* Copy wiki page with parent_id

This will save some memory instead of memoizing the entire wiki page

* Fix typo

* Default to true for all copy associations

That means if only a true value is passed, all other options will still be true

* Do not try to copy attachments if the base dependency wasnt copied

* Ensure null identifier gets rendered

* Fix paths to the form and commit

* Change redirect to an URL

* Extend documentation on meta properties as table

* Ensure we pass a default params if incoming params are nil

Now that SetAttributes needs to splat params, they do no longer
correctly get the no-param-default behavior of Ruby, so we need to
explictly assign a default params hash

* Fix expect for trailing path
2021-04-19 12:22:42 +02:00
ulferts 6140f4c7e9 update copyright to 2021 (#8925)
Updates the copyright to 2021 for all files that have a copyright. Files in our source code without the copyright header still do not receive one automatically. Additionally, backlisted files are also excluded.

Previously the copyright of chiliproject which references redmine stated a copyright of redmine up to and including 2017 which is not true for the code we have in here. Because of that I changed that to 2013
2021-01-13 17:47:45 +01:00
Oliver Günther a6ef88fa41 Merge remote-tracking branch 'origin/release/10.4' into dev 2020-03-04 11:36:27 +01:00
ulferts 0cda1869a8 employ advisory lock for all update services 2020-03-02 15:49:30 +01:00
ulferts 9e2287bfcc rename and inflect according to zeitwerk 2020-02-21 20:47:24 +01:00
Henriette Dinger bd7f4e4814 Update copyright notice 2020-01-15 11:31:26 +01:00
ulferts 481fe5b291 use default end points for most of the relations api 2019-12-11 10:19:39 +01:00
ulferts 05a93695d4 automatically reverse relates relationship 2019-05-27 10:22:58 +02:00
Oliver Günther 460edf0122 Fix getting attributes before virtual attribute was ever read
- Lookup existing relation with ID and relation_type not nil (some
relation column > 0)

If you access in this order:
- Get `relation.attributes` -> relation_type is nil
- Get `relation.relaton_type` -> nil always after that

If you access the other way around, everything's okay:
- Get `relation.relaton_type` -> expected value
- Get `relation.attributes` -> expecte dvalue
2018-09-05 21:03:29 +02:00
Oliver Günther aa9897561b [28455] Ensure model contracts are initiaited immediately before saving 2018-09-05 21:03:28 +02:00
Oliver Günther 6ef4211e77 Bump copyright to 2018 (#6171)
[ci skip]
2018-02-12 08:51:12 +01:00
Jens Ulferts 690e0ffc60 wp create/update/destroy via services 2017-11-29 15:27:29 +01:00
ulferts 0c0b16508b Fix/bump representable (#5465)
* bump reform and roar -> bumps representer

* adapt to changed validation interface

* disable initializer patch for now

* adapt to changed representable attr interface

* can no longer have private methods inside a representer

* private no longer possible for representer

* bump reform

* wip - restyle validation

* remove commented out patch

* apply injection as prescribed

* reactivate reform error symbols patch

* remove patch to Hash superfluous wit ruby 2.3

* remove outdated human_attribute_name patch

* whitespace fixes

* adapt filter name after removal of human_attribute_name patch

* adapt filter specs to no longer rely on human_attribute_name patch

* fix version filter name

* remove reliance on no longer existing human_attribute_name patch

* use correct key in journal formatter

* remove private from representer

* adapt to altered setter interface

* reenable i18n for error messages in contracts

* no private methods in representer

* defined model for contracts

* fix validaton

* instantiate correct Object

* define model for contract

* circumvent now existing render method on reform

* replace deprecated constant

* patch correct reform class - not the module - via prepend

* refactor too complex method

* replace deprations

* remove remnants of parentId

* prevent error symbols from existing twice

* adapt user representer to altered setter interface

* adapt watcher representer to altered setter interface

* remove now unnessary patch

* adapt setter to altered interface

* adapt spec

* fix custom field setters

* remove parentId from wp representer

As the parent is a wp resource, clients should use the parent link instead

* adapt spec to changed valid? interface

* remove parentId from wp schema

* replace references of parentId in frontend

* remove TODO

[ci skip]
2017-06-02 09:10:51 +02:00
Oliver Günther 7cf11bb689 Update copyright notice 2017-01-10 15:11:43 +01:00
Markus Kahl 7f6d74a88e basic crud 2016-10-20 10:41:19 +01:00