Skip to content

Add endpoint to rename a project#124

Merged
luxusko merged 3 commits into
developfrom
rename_project_endpoint
Oct 24, 2023
Merged

Add endpoint to rename a project#124
luxusko merged 3 commits into
developfrom
rename_project_endpoint

Conversation

@harminius
Copy link
Copy Markdown
Contributor

Task: https://github.com/MerginMaps/server-private/issues/2003

URL: PATCH /v2/projects/<project_id>
Body: { "name": "new_project_name"}

  • check the user have permission to update the project
  • check the new name uses allowed characters
  • check if a project with the new name already exists

Task: https://github.com/MerginMaps/MerginMaps-Cloud-TEST/issues/1
URL: PATCH /v2/projects/<project_id>
Body:
{
  "name": "new_project_name"
}

- check the user have permission to update the project
- check the new name uses allowed characters
- check if a project with the new name already exists
@harminius harminius requested a review from luxusko October 19, 2023 11:35
@harminius harminius self-assigned this Oct 19, 2023
Comment thread server/mergin/sync/errors.py Outdated
Comment thread server/mergin/sync/public_api.yaml
Comment thread server/mergin/sync/public_api_v2.yaml Outdated
Comment thread server/mergin/sync/public_api_v2.yaml
Comment thread server/mergin/sync/public_api_v2.yaml Outdated
Comment thread server/mergin/sync/public_api_v2_controller.py Outdated
Comment thread server/mergin/sync/public_api_v2_controller.py Outdated
Comment thread server/mergin/sync/public_api_v2_controller.py
Comment thread server/mergin/sync/public_api_v2.yaml Outdated
Comment thread server/mergin/tests/test_public_api_v2.py
Comment thread server/mergin/sync/public_api_v2_controller.py
Comment thread server/mergin/tests/test_public_api_v2.py
Comment thread server/mergin/tests/test_public_api_v2.py
@luxusko luxusko merged commit 9201e0c into develop Oct 24, 2023
400,
)
new_name_exists = Project.query.filter_by(
workspace_id=project.workspace_id, name=new_name
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luxusko I think we should filter by name=new_name.strip(), right?

because if there is a trailing space in new_name, it is not catched by is_name_allowed and here we should check the name which we want to write to db (there could be already a different project without the whitespace)

I didn't notice you moved the .strip() to the end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I did remove it and left it by mistake in the final update of project.name. Why should there be undocumented processing of the string - client sends you string X but we save and use different string Y without any notification. Confusing source of errors. Let validation method be fully responsible passed names. We can't have silent requirements hidden over the code base.

Let me create quick fix PR to remove this forgotten strip() and propose name regex update.

@MarcelGeo MarcelGeo deleted the rename_project_endpoint branch January 17, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants