7
7
8
8
from uritemplate import URITemplate
9
9
10
- from . import users
10
+ from . import users , models
11
11
12
12
from .decorators import requires_auth
13
13
from .events import Event
14
- from .models import BaseAccount , GitHubCore
15
14
from .projects import Project
16
15
from .repos import Repository
17
16
18
17
19
- class Team (GitHubCore ):
18
+ class Team (models . GitHubCore ):
20
19
21
20
"""The :class:`Team <Team>` object.
22
21
@@ -230,7 +229,7 @@ def remove_repository(self, repository):
230
229
return self ._boolean (self ._delete (url ), 204 , 404 )
231
230
232
231
233
- class Organization (BaseAccount ):
232
+ class Organization (models . GitHubCore ):
234
233
235
234
"""The :class:`Organization <Organization>` object.
236
235
@@ -248,13 +247,65 @@ class Organization(BaseAccount):
248
247
members_roles = frozenset (['all' , 'admin' , 'member' ])
249
248
250
249
def _update_attributes (self , org ):
251
- super (Organization , self )._update_attributes (org )
252
- self .type = self .type or 'Organization'
250
+ # Set the type of object
251
+ self .type = self ._get_attribute (org , 'type' )
252
+ if not self .type :
253
+ self .type = 'Organization'
254
+
255
+ self ._api = self ._get_attribute (org , 'url' )
256
+
257
+ #: URL of the avatar at gravatar
258
+ self .avatar_url = self ._get_attribute (org , 'avatar_url' )
259
+
260
+ #: URL of the blog
261
+ self .blog = self ._get_attribute (org , 'blog' )
262
+
263
+ #: Name of the company
264
+ self .company = self ._get_attribute (org , 'company' )
265
+
266
+ #: datetime object representing the date the account was created
267
+ self .created_at = self ._strptime_attribute (org , 'created_at' )
268
+
269
+ #: E-mail address of the org
270
+ self .email = self ._get_attribute (org , 'email' )
271
+
272
+ # The number of people following this org
273
+ #: Number of followers
274
+ self .followers_count = self ._get_attribute (org , 'followers' )
275
+
276
+ # The number of people this org follows
277
+ #: Number of people the org is following
278
+ self .following_count = self ._get_attribute (org , 'following' )
279
+
280
+ #: Unique ID of the account
281
+ self .id = self ._get_attribute (org , 'id' )
282
+
283
+ #: Location of the org
284
+ self .location = self ._get_attribute (org , 'location' )
285
+
286
+ #: Name of the organization
287
+ self .login = self ._get_attribute (org , 'login' )
288
+
289
+ # e.g. first_name last_name
290
+ #: Real name of the org
291
+ self .name = self ._get_attribute (org , 'name' )
292
+
293
+ # The number of public_repos
294
+ #: Number of public repos owned by the org
295
+ self .public_repos_count = self ._get_attribute (org , 'public_repos' )
296
+
297
+ # e.g. https://github.com/self._login
298
+ #: URL of the org's profile
299
+ self .html_url = self ._get_attribute (org , 'html_url' )
300
+
301
+ #: Description of the org
302
+ self .description = self ._get_attribute (org , 'description' )
253
303
254
304
#: Events url (not a template)
255
305
self .events_url = self ._get_attribute (org , 'events_url' )
306
+
256
307
#: Number of private repositories.
257
- self .private_repos = self ._get_attribute (org , 'private_repos ' )
308
+ self .private_repos = self ._get_attribute (org , 'owned_private_repos ' )
258
309
259
310
#: Public Members URL Template. Expands with ``member``
260
311
self .public_members_urlt = self ._class_attribute (
@@ -266,6 +317,9 @@ def _update_attributes(self, org):
266
317
#: Repositories url (not a template)
267
318
self .repos_url = self ._get_attribute (org , 'repos_url' )
268
319
320
+ def _repr (self ):
321
+ return '<Organization [{s.login}:{s.name}]>' .format (s = self )
322
+
269
323
@requires_auth
270
324
def add_member (self , username , team_id ):
271
325
"""Add ``username`` to ``team`` and thereby to this organization.
@@ -652,7 +706,7 @@ def team(self, team_id):
652
706
return self ._instance_or_null (Team , json )
653
707
654
708
655
- class Membership (GitHubCore ):
709
+ class Membership (models . GitHubCore ):
656
710
657
711
"""The wrapper for information about Team and Organization memberships."""
658
712
@@ -689,7 +743,7 @@ def edit(self, state):
689
743
"""
690
744
if state and state .lower () == 'active' :
691
745
data = dumps ({'state' : state .lower ()})
692
- json = self ._json (self ._patch (self ._api , data = data ))
746
+ json = self ._json (self ._patch (self ._api , data = data ), 200 )
693
747
self ._update_attributes (json )
694
748
return True
695
749
return False
0 commit comments