157 Commits

Author SHA1 Message Date
Marcello Rocha 81e5726838 [OP#73293] Creates POST /api/v3/wiki_page_links endpoint (#23529)
* Remove the `render_author` method as it is unnecessary
* Add the necessary paths, clarify the param to wiki_provider path
* Rework the representers, merge upstream changes to the create contract
* Remove unnecessary mixin and make everything read-only
* Create Endpoint for POST /api/v3/wiki_page_links
* Incorporates @Kharonus feedback in testing multiple page link creation
2026-06-04 10:06:13 +02:00
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
Christophe Bliard 0378a9d0ff Add API enpoint class name to grape logs
For instance, it adds "endpoint_name=API::V3::Versions::VersionsAPI" to
the log line.
2025-09-22 18:00:17 +02:00
Kabiru Mwenja cf950cc75f Add attachment by activity comment API spec
Support contaner aliasing needed from "journal" to "activity"
2025-04-11 13:17:15 +03:00
Ivan Kuchin 4911b8a149 remove years from copyrights (except for COPYRIGHT file) 2024-07-31 15:02:49 +02:00
Christophe Bliard 5ee2ba5cca [55656] Remove derivedRemainingTime from form payload
`derivedRemainingTime` is not writeable. That's specified in the work
package contract. But as the payload representer was using a lambda for
`:writable` for `derivedRemainingTime`, the writability given by the
contract was ignored, and it was always added if the lambda returned
`true` (and it always returned true in work-based mode).

It produced issues like when copying a work package having a
`derivedRemainingTime` being set, as reported in
https://community.openproject.org/wp/55656.

Removing the lambda makes the representer solely rely on the contract to
determine the writability of the `derivedRemainingTime` property, and
fixes the issue.
2024-07-08 17:16:15 +02:00
ulferts 50b1ac7a3d adapt content type on errors definition 2024-06-25 20:37:54 +02:00
ulferts dd92b1abd2 bump grape 2024-06-25 20:37:49 +02:00
Ivan Kuchin fa5d03eae0 rubocop safe autocorrect all except Rails/WhereRange 2024-05-30 19:54:08 +02:00
ulferts 3b2121f733 Revert "Merge remote-tracking branch 'origin/release/13.4' into dev"
This reverts commit 40b2bbeb09, reversing
changes made to b4c6cb17cc.
2024-03-21 11:31:17 +01:00
Ivan Kuchin 7787e457a3 Revert "Merge branch 'dev' into release/13.4"
This reverts commit a901541269, reversing
changes made to e573ca00b7.
2024-03-20 20:19:08 +01:00
Ivan Kuchin 9e4934cd0a change quotes using rubocop --only Style/StringLiterals,Style/QuotedSymbols -a 2024-03-20 18:05:22 +01:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01: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
Christophe Bliard 21a696ef9b Update copyright information for 2023 2022-12-30 15:51:26 +01:00
Dombi Attila f02c07a57f [#45032] Custom fields editing looks like it's possible in read-only status (although changes are not saved and there is no error message)
https://community.openproject.org/work_packages/45032
2022-11-28 23:00:11 +02:00
ulferts 4a94e03b04 bump rubocop and apply autofixes for new cops 2022-10-21 22:29:12 +02:00
Oliver Günther 8046203c50 Use common helper to reduce duplication 2022-10-17 14:28:02 +02:00
Dombi Attila 92a7f1ffda Rename :writeable to :writable 2022-06-20 13:30:33 +02:00
Christophe Bliard 48a4f1b6ad lint with rubocop --autocorrect (safe cops only) 2022-06-02 10:40:10 +02:00
ulferts f1111922ed use API::ParserStruct for all API parsing 2022-04-12 13:03:37 +02:00
Christophe Bliard 54c65ea00a add documentation for PayloadRepresenter
and make rubocop happier
2022-03-23 12:12:50 +01:00
Christophe Bliard 2ec5db6e89 refactor: use methods from ServiceResult instead of computing compound results 2022-03-23 11:04:33 +01:00
Christophe Bliard 0e99279bd5 limit creation of file_links to 20 at once 2022-03-21 14:09:20 +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 aebc8fd3f3 Merge branch 'dev' into feature/file-links 2022-03-08 15:22:28 +01:00
ulferts a80767f516 stub for signaling on work package resource 2022-03-03 14:59:31 +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
Eric Schubert ace1b954de Merge branch 'dev' into feature/file-links 2022-02-28 16:04:22 +01:00
Oliver Günther 25986b6aac Merge remote-tracking branch 'origin/release/12.0' into dev 2022-02-22 21:07:37 +01:00
Oliver Günther c7dfd0edae Fix loading of work packages in board autocompleter 2022-02-22 21:05:30 +01:00
Eric Schubert 970f00ae05 [#40228] added error handling for creating file links 2022-02-21 13:31:28 +01:00
Eric Schubert a8df00e619 [#40228] implemented static open
- added contract validation for storage input
- added spec to test it
- ATTENTION: error presentation not working yet for bulk inserts
2022-02-18 14:06:18 +01:00
Christophe Bliard 221a006eef make some code easier to read 2022-02-14 09:42:52 +01:00
Christophe Bliard 3ba029fe16 Make the lookup of Contracts and Services in longer namespaces possible 2022-02-09 10:59:10 +01:00
ulferts e4cbf6deee replace usage of OpenStruct 2022-01-26 17:10:46 +01:00
Oliver Günther 43891b23bb Add a separate setting for max API size 2022-01-25 15:38:21 +01:00
Oliver Günther 38ee719c26 Add pageSize=-1 to dynamic form components (#10048)
* Add pageSize=1000 to dynamic form components

* revive magic number for page size

Providing -1 will result in the maximum page size being chosen. The magic number used to be 0 but that conflicts with the use case of really wanting no results to be included, e.g. when only interested in the total number or sums

Co-authored-by: ulferts <jens.ulferts@googlemail.com>
2022-01-17 08:45:31 +01:00
Oliver Günther 9a3d822b35 [38842] Allow customized not found message
https://community.openproject.org/wp/38842
2021-10-13 08:37:21 +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
luzpaz 2ae53bd252 Fix typos in user facing and non-user facing code (#9497)
* Fix typos in user facing and non-user facing code

Found via `codespell -q 3 -S ./config/locales -L ba,nd,parms,sur,varius`

* Fix strings in specs
2021-07-21 17:26:31 +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
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 4bf7a26eb1 Capabilities API (#9083)
* Capabilities API

* introduce auxilliary capability model

* capability model and query

* render in sql

* fix pagination

* introduce sql representer

* extract abstract sql representer class

* remove yet unused methods

* abstract sql collection representer

* contract_actions as part of permissions

* filter for capability id - used in GET

* id filter validation

* remove unused representer

* remove unused wp representer

* reuse renaming class

* add spec for access control

* add principal filter to capability

* add context filter

* extract capability sql into scope

* admin gets all capabilities

* require to have one filter set to keep performance bearable

* consider active project modules for capabilities

* limit capability based on principal visiblity and user state

* rework capability to be tableless

* spec not being allowed to see on request level

* add actions to capability representer

* add action api

* extract sql index endpoint

* remove unused class

* prepare sending signaling error - not yet frontend exposed

* extract show endpoint for sql rendered responses

* use UNION for better performance

* include navigation links on collections

* remove string replacements

* extract collection representer into hal sql module

* no capabilities when blocked

* remove commented out code
2021-03-23 21:45:38 +01:00
ulferts 1bdd2ab9ae safe automatic fixes by rubocop (#8994) 2021-02-11 16:02:18 +01:00
Oliver Günther 3c9be3bdbe [35507] Allow global permission to add and edit users (#8937)
* Add global permission for add_user

* Rename fieldset for global roles to "Global"

* Add permission to admin actions

* Add index action to add_user permission

* Redirect to first admin item if only one

* Hide status action for non admins

* Break down user form into partials for easier rendering

* Disable some user form tabs for non-admins

* Make users API and services conformant with endpoints

* Fix references to DeleteService#deletion_allowed?

* Authorize add_user on show as well

* Only show invite user toolbar item with permission

* Fix Delete Service spec

* Fix the way user prefs are handled in service

* Ensure session_id is treated as string

This causes a cast error otherwise as it passes rack session locally

* Fix service call on onboarding controller

* Fix service call on users controller

* Add delete spec for global user

* Hide login attribute again when adding a new user

* Render auth source correctly in simple form

* Fix creating invited users through service

The invitation requires the mail attribute to be present.

Previously, there was a manual error added to the mail.

As the errors are now determined by the contract + model, we now

end up with all missing properties as errors.

* Properly constraint attributes for non-admins

* Add specs for global user

* Start working on how to update password from UsersController

that code is a mess...

* Change permitted_params spec to include non-admin params

* Fix create user service spec

* Remove mail_notification param from users controller

It's not part of the contract/params passed to user

* Remove todos

* Extend docs

* Correct the way backlogs patches into the user settings

* Remove superfluous UpdateUserService

* Rewrite duplicated update service examples into common shared example

* Remove duplicate password writable check

* Base Users::DeleteContract on base delete contract

* Move checks for active users into the UserAllowedService

* Restore password writable check as it is not an attribute

* Fix menus for global user

* Allow global users to add custom fields

* Allow global user add permission to reinvite user

* Fix changed var name in update service spec

* Ensure also invited or registered users can be authroized

This ensure that e.g., invited users can also be set as watchers

* fix typo

Co-authored-by: ulferts <jens.ulferts@googlemail.com>
2021-02-01 10:45:13 +01: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