Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 535636f

Browse filesBrowse files
kernelportJohnVillalovos
authored andcommitted
fix: allow updating of sub-pages in wikis
Make it possible to update subpages in wikis Update SaveMixin to use utils._url_encode() on the ID if it is a string. Closes: #1079
1 parent ac81272 commit 535636f
Copy full SHA for 535636f

File tree

Expand file treeCollapse file tree

2 files changed

+20
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-2
lines changed
Open diff view settings
Collapse file

‎gitlab/mixins.py‎

Copy file name to clipboardExpand all lines: gitlab/mixins.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def _get_updated_data(self) -> Dict[str, Any]:
527527

528528
return updated_data
529529

530-
def save(self, **kwargs: Any) -> None:
530+
def save(self, **kwargs: Any) -> Optional[Dict[str, Any]]:
531531
"""Save the changes made to the object to the server.
532532
533533
The object is updated to match what the server returns.
@@ -542,15 +542,18 @@ def save(self, **kwargs: Any) -> None:
542542
updated_data = self._get_updated_data()
543543
# Nothing to update. Server fails if sent an empty dict.
544544
if not updated_data:
545-
return
545+
return None
546546

547547
# call the manager
548548
obj_id = self.get_id()
549549
if TYPE_CHECKING:
550550
assert isinstance(self.manager, UpdateMixin)
551+
if isinstance(obj_id, str):
552+
obj_id = utils._url_encode(obj_id)
551553
server_data = self.manager.update(obj_id, updated_data, **kwargs)
552554
if server_data is not None:
553555
self._update_attrs(server_data)
556+
return server_data
554557

555558

556559
class ObjectDeleteMixin(_RestObjectBase):
Collapse file

‎tests/functional/api/test_wikis.py‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
GitLab API:
3+
https://docs.gitlab.com/ee/api/wikis.html
4+
"""
5+
6+
7+
def test_wikis(project):
8+
9+
page = project.wikis.create({"title": "title/subtitle", "content": "test content"})
10+
page.content = "update content"
11+
page.title = "subtitle"
12+
13+
page.save()
14+
15+
page.delete()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.