| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 08f19b3 commit 96a1a78
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,7 @@ | |||
| 33 | 33 | # user create | |
| 34 | 34 | alice = gl.users.list(username='alice')[0] | |
| 35 | 35 | user_project = alice.projects.create({'name': 'project'}) | |
| 36 | + user_projects = alice.projects.list() | ||
| 36 | 37 | # end user create | |
| 37 | 38 | ||
| 38 | 39 | # update | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,7 +181,7 @@ class UserProject(RESTObject): | |||
| 181 | 181 | pass | |
| 182 | 182 | ||
| 183 | 183 | ||
| 184 | - class UserProjectManager(CreateMixin, RESTManager): | ||
| 184 | + class UserProjectManager(ListMixin, CreateMixin, RESTManager): | ||
| 185 | 185 | _path = '/projects/user/%(user_id)s' | |
| 186 | 186 | _obj_cls = UserProject | |
| 187 | 187 | _from_parent_attrs = {'user_id': 'id'} | |
@@ -192,6 +192,31 @@ class UserProjectManager(CreateMixin, RESTManager): | |||
| 192 | 192 | 'public', 'visibility', 'description', 'builds_enabled', | |
| 193 | 193 | 'public_builds', 'import_url', 'only_allow_merge_if_build_succeeds') | |
| 194 | 194 | ) | |
| 195 | + _list_filters = ('archived', 'visibility', 'order_by', 'sort', 'search', | ||
| 196 | + 'simple', 'owned', 'membership', 'starred', 'statistics', | ||
| 197 | + 'with_issues_enabled', 'with_merge_requests_enabled') | ||
| 198 | + | ||
| 199 | + def list(self, **kwargs): | ||
| 200 | + """Retrieve a list of objects. | ||
| 201 | + | ||
| 202 | + Args: | ||
| 203 | + all (bool): If True, return all the items, without pagination | ||
| 204 | + per_page (int): Number of items to retrieve per request | ||
| 205 | + page (int): ID of the page to return (starts with page 1) | ||
| 206 | + as_list (bool): If set to False and no pagination option is | ||
| 207 | + defined, return a generator instead of a list | ||
| 208 | + **kwargs: Extra options to send to the Gitlab server (e.g. sudo) | ||
| 209 | + | ||
| 210 | + Returns: | ||
| 211 | + list: The list of objects, or a generator if `as_list` is False | ||
| 212 | + | ||
| 213 | + Raises: | ||
| 214 | + GitlabAuthenticationError: If authentication is not correct | ||
| 215 | + GitlabListError: If the server cannot perform the request | ||
| 216 | + """ | ||
| 217 | + | ||
| 218 | + path = '/users/%s/projects' % self._parent.id | ||
| 219 | + return ListMixin.list(self, path=path, **kwargs) | ||
| 195 | 220 | ||
| 196 | 221 | ||
| 197 | 222 | class User(SaveMixin, ObjectDeleteMixin, RESTObject): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,9 @@ | |||
| 92 | 92 | new_user.block() | |
| 93 | 93 | new_user.unblock() | |
| 94 | 94 | ||
| 95 | + # user projects list | ||
| 96 | + assert(len(new_user.projects.list()) == 0) | ||
| 97 | + | ||
| 95 | 98 | foobar_user = gl.users.create( | |
| 96 | 99 | {'email': 'foobar@example.com', 'username': 'foobar', | |
| 97 | 100 | 'name': 'Foo Bar', 'password': 'foobar_password'}) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments