@@ -222,7 +222,8 @@ def _delete_json(self, instance, space=None, rel_path=None, extra_params=None):
222222 )
223223 )
224224
225- def _put_json (self , instance , space = None , rel_path = None , extra_params = None ):
225+ def _put_json (self , instance , space = None , rel_path = None , extra_params = None ,
226+ id_field = 'number' ):
226227 """
227228 Base level method for adding new data to the API
228229 """
@@ -245,7 +246,7 @@ def _put_json(self, instance, space=None, rel_path=None, extra_params=None):
245246 settings .API_ROOT_PATH ,
246247 settings .API_VERSION ,
247248 rel_path or model .rel_path ,
248- instance ['number' ],
249+ instance [id_field ],
249250 urllib .urlencode (extra_params ),
250251 )
251252
@@ -345,6 +346,18 @@ def users(self, extra_params=None):
345346 space = self ,
346347 rel_path = self ._build_rel_path ('users' ),
347348 extra_params = extra_params ,
349+ )
350+
351+ @assembla_filter
352+ def wiki_pages (self , extra_params = None ):
353+ """
354+ All Wiki Pages with access to this Space
355+ """
356+ return self .api ._get_json (
357+ WikiPage ,
358+ space = self ,
359+ rel_path = self ._build_rel_path ('wiki_pages' ),
360+ extra_params = extra_params ,
348361 )
349362
350363 def _build_rel_path (self , to_append = None ):
@@ -459,3 +472,29 @@ def tickets(self, extra_params=None):
459472 space .tickets (extra_params = extra_params )
460473 )
461474 return tickets
475+
476+
477+ class WikiPage (AssemblaObject ):
478+ def write (self ):
479+ """
480+ Create or update a Wiki Page on Assembla
481+ """
482+ if not hasattr (self , 'space' ):
483+ raise AttributeError ("A ticket must have a 'space' attribute before you can write it to Assembla." )
484+
485+ self .api = self .space .api
486+
487+ if self .get ('id' ): # We are modifying an existing wiki page
488+ return self .api ._put_json (
489+ self ,
490+ space = self .space ,
491+ rel_path = self .space ._build_rel_path ('wiki_pages' ),
492+ id_field = 'id'
493+ )
494+ else : # Creating a new wiki page
495+ return self .api ._post_json (
496+ self ,
497+ space = self .space ,
498+ rel_path = self .space ._build_rel_path ('wiki_pages' ),
499+ )
500+
0 commit comments