mirror of
https://github.com/kennethreitz-archive/python-convore.git
synced 2026-06-05 23:40:18 +00:00
Grabbing groups you haven't joined in place.
This commit is contained in:
@@ -17,6 +17,8 @@ class Groups(UserList):
|
||||
self.data = []
|
||||
self.sync()
|
||||
|
||||
def joined(self):
|
||||
"""Returns list of """
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
||||
@@ -27,6 +29,18 @@ class Groups(UserList):
|
||||
if key in (group.id, group.slug):
|
||||
return group
|
||||
|
||||
try:
|
||||
r = requests.get(API_URL + 'groups/%s.json' % key)
|
||||
r.raise_for_status()
|
||||
|
||||
group = models.Group()
|
||||
group.import_from_api(json.loads(r.content)['group'])
|
||||
|
||||
return group
|
||||
|
||||
except requests.HTTPError:
|
||||
return None
|
||||
|
||||
def __contains__(self, key):
|
||||
|
||||
if isinstance(key, int):
|
||||
@@ -51,4 +65,5 @@ class Groups(UserList):
|
||||
|
||||
group = models.Group()
|
||||
group.import_from_api(_group)
|
||||
group.joined = True
|
||||
self.data.append(group)
|
||||
|
||||
Reference in New Issue
Block a user