26 Commits

Author SHA1 Message Date
Beverly Nguyen
166a03cbbd adding creator by id to schema 2025-08-19 12:44:46 -07:00
Beverly Nguyen
3926619fd4 flake8 2025-08-19 12:12:02 -07:00
Beverly Nguyen
0ba6c06a21 Only the person who creates the folder and admin gets permissions 2025-08-19 12:08:04 -07:00
Kenneth Kehl
58a8b51f59 more input checking 2025-06-26 10:35:46 -07:00
Kenneth Kehl
00fd3a72bb code review feedback, fix setup.cfg and reformat 2023-08-25 08:10:33 -07:00
Kenneth Kehl
026dc14021 notify-api-412 use black to enforce python style standards 2023-08-23 10:35:43 -07:00
Katie Smith
b440f3f904 Use Draft-07 and Draft7Validator everywhere
We were using the Draft4Validator in one place, so this updates it to
the Draft7Validator instead.

The schemas were mostly using draft 4 of the JSON schema, though there
were a couple of schemas that were already of version 7. This updates
them all to version 7, which is the latest version fully supported by
the jsonschema Python package. There are some breaking changes in the
newer version of the schema, but I could not see anywhere would these
affect us. Some of these schemas were not valid in version 4, but are
now valid in version 7 because `"required": []` was not valid in earlier
versions.
2022-04-14 14:46:10 +01:00
Rebecca Law
d4009ffc52 Rename database management functions.
Rename @transactional to @autocommit.
Rename nested_transaction to tranaction.
2021-04-19 10:56:00 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Pea Tyczynska
dabcbc20db Update folder viewing permissions when updating a folder 2019-03-18 17:49:47 +00:00
Pea Tyczynska
64c0c19419 Set user permissions when creating a folder
If the new folder has a parent folder, it inherits user permissions
from its parent. Else if the new folder is at root level, all users
will have a permission to view it.
2019-03-12 16:11:20 +00:00
Leo Hemsted
474acc5bba new chillmaid approved error messages
these get shown on the front-end so make sure their content is good
2018-12-10 12:59:16 +00:00
Rebecca Law
870b42919a Merge pull request #2227 from alphagov/fix-error-msg
Remove the extra "to" in the message.
2018-11-13 14:35:20 +00:00
Rebecca Law
63c0c68afa Remove the extra "to" in the message. 2018-11-12 16:28:16 +00:00
Alexey Bezhan
89516f95a9 Merge pull request #2225 from alphagov/rename_rename
Change name of update method for template folder
2018-11-12 15:51:47 +00:00
Rebecca Law
83d720bb7b Change error message, the folder id is not useful infomation to the user. 2018-11-12 15:25:48 +00:00
Pea Tyczynska
103033a330 Change name of update method for template folder
It was initialy called "rename" which does not comply with
RESTful CRUD (create, update, read, delete) naming practice.
We remove the 'rename' operation in favour of template folder
resource update endpoint as it allows us to extend it with other
attributes.
2018-11-12 14:28:07 +00:00
Rebecca Law
68cea04210 Fixed error message 2018-11-09 16:40:58 +00:00
Rebecca Law
63b305441c Add a check that the folder is not moved into itself.
By the way, the database will not let this happen, but this is a nicer error and is explicit to read as an invalid move.
2018-11-09 16:08:33 +00:00
Rebecca Law
1f86796949 Renamed url to /template-folder/<id>/contents, it's a more restful name.
Updated unit tests
Removed redundant logger
2018-11-09 15:54:39 +00:00
Rebecca Law
64f7f4c302 Change status code to 204 when there is no content in response. 2018-11-09 14:55:19 +00:00
Leo Hemsted
98de2591a7 change aborts to invalidrequest exceptions 2018-11-08 17:21:58 +00:00
Leo Hemsted
d9aa220aa6 move folders and templates to other folders
new endpoints:
/services/<service_id>/move-to-folder
/services/<service_id>/move-to-folder/<target_template_folder_id>

* takes in a dict containing lists of `templates` and `folders` uuids.
* sets parent of templates and folders to the folder specified in the
  URL. Or None, if there was no id specified.
* if any template or folder has a differen service id, then the whole
  update fails
* if any folder is an ancestor of the target folder, then the whole
  update fails (as that would cause a cyclical folder structure).
* the whole function is wrapped in a single `transactional` decorator,
  so in case of error nothing will be saved.
2018-11-08 17:13:00 +00:00
Alexey Bezhan
36f41c23e1 Always use both folder and service ID when getting template folder
Currently there aren't any permission checks based on folder IDs in
the admin app or the API, so it's possible for a user to modify the
folder ID to perform operations on folders outside their service.

Our usual way to avoid this is to always use service_id filter when
fetching objects from the database.
2018-11-07 13:51:37 +00:00
Alexey Bezhan
1dbb24065d Ensure that new template folder belongs to the same service as parent
Since template folders are only linked by ID to their parent we need
to check that the parent folder belongs to the same service as the
one being created. Otherwise, admin users could modify parent ID to
create a folder outside their service.

Ideally, this check would be performed by a DB constraint, but since
parent_id can be nullable this is only possible to express using DB
triggers.

Instead, we perform the check in the API endpoint code.
2018-11-07 13:51:37 +00:00
Leo Hemsted
fbe34041d6 add template folder CRUD
* create template folder
* rename template folder
* get list of template folders for service (not nested/presented in any
  particular way)
* delete template folder

Also removed `lazy=dynamic` from the `template_folder.templates`
relationship. lazy=dynamic returns a query object (which you can then
filter further). We just want to return the entire fetched list, at
least for now.
2018-10-31 14:28:16 +00:00