Skip to content

Commit 535636f

Browse 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

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

gitlab/mixins.py

Lines 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):

tests/functional/api/test_wikis.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy