-
Notifications
You must be signed in to change notification settings - Fork 169
/
tab.py
40 lines (28 loc) · 1.18 KB
/
tab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import absolute_import, division, print_function, unicode_literals
from six import python_2_unicode_compatible
from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs
@python_2_unicode_compatible
class Tab(CanvasObject):
def __str__(self):
return "{} ({})".format(self.label, self.id)
def update(self, **kwargs):
"""
Update a tab for a course.
Note: Home and Settings tabs are not manageable, and can't be
hidden or moved.
:calls: `PUT /api/v1/courses/:course_id/tabs/:tab_id \
<https://canvas.instructure.com/doc/api/tabs.html#method.tabs.update>`_
:rtype: :class:`canvasapi.tab.Tab`
"""
if not hasattr(self, 'course_id'):
raise ValueError('Can only update tabs from a Course.')
response = self._requester.request(
'PUT',
'courses/{}/tabs/{}'.format(self.course_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)
response_json = response.json()
response_json.update({'course_id': self.course_id})
super(Tab, self).set_attributes(response.json())
return self