Skip to content

Commit f044184

Browse files
author
Kenneth Reitz
committed
basics for editable datapoints
1 parent 388e252 commit f044184

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

github3/models.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class BaseResource(object):
1616
_dates = []
1717
_bools = []
1818
_map = {}
19+
_writeable = []
1920

2021

2122
def __init__(self):
@@ -53,21 +54,48 @@ def new_from_dict(cls, d, gh=None):
5354
_gh = gh
5455
)
5556

57+
def update(self):
58+
pass
59+
60+
def setattr(self, k, v):
61+
# TODO: when writable key changed,
62+
pass
5663

5764
class User(BaseResource):
5865
"""Github User object model."""
5966

60-
_strings = ['login', 'gravatar_url', 'url', 'name', 'company',
61-
'blog', 'location', 'email', 'bio', 'html_url']
67+
_strings = [
68+
'login','gravatar_url', 'url', 'name', 'company', 'blog', 'location',
69+
'email', 'bio', 'html_url']
6270

6371
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following']
6472
_datetimes = ['created_at',]
6573
_booleans = ['hireable', ]
6674
_map = {}
75+
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
6776

6877

6978
def __init__(self):
7079
super(User, self).__init__()
7180

7281
def __repr__(self):
73-
return '<user {0}>'.format(self.login)
82+
return '<user {0}>'.format(self.login)
83+
84+
85+
def _update(self):
86+
"""Update the authenticated user."""
87+
88+
# TODO: check that user is authenticated
89+
90+
args = to_api(
91+
dict(
92+
favorite=self.favorite,
93+
archive=self.archive,
94+
read_percent=self.read_percent,
95+
),
96+
int_keys=('favorite', 'archive')
97+
)
98+
99+
r = self._rdd._post_resource(('bookmarks', self.id), **args)
100+
101+
return r

0 commit comments

Comments
 (0)