Address trivial TODOs

- Add share type access to type view builder
- Remove unnecessary docstring TODO

TrivialFix

Change-Id: I856a3318f498800eab5932b7ad250621ccf4292f
This commit is contained in:
Goutham Pacha Ravi 2018-06-16 23:28:29 -07:00
parent 4580938bab
commit 4435deb48f
3 changed files with 9 additions and 8 deletions

View File

@ -283,13 +283,7 @@ class ShareTypesController(wsgi.Controller):
expl = _("Access list not available for public share types.")
raise webob.exc.HTTPNotFound(explanation=expl)
# TODO(vponomaryov): move to views.
rval = []
for project_id in share_type['projects']:
rval.append(
{'share_type_id': share_type['id'], 'project_id': project_id}
)
return {'share_type_access': rval}
return self._view_builder.share_type_access(req, share_type)
@wsgi.action('addProjectAccess')
@wsgi.Controller.authorize('add_project_access')

View File

@ -88,6 +88,14 @@ class ViewBuilder(common.ViewBuilder):
return dict(volume_types=share_types_list,
share_types=share_types_list)
def share_type_access(self, request, share_type):
"""Return a dictionary view of the projects with access to type."""
projects = [
{'share_type_id': share_type['id'], 'project_id': project_id}
for project_id in share_type['projects']
]
return {'share_type_access': projects}
def _filter_extra_specs(self, extra_specs, valid_keys):
return {key: value for key, value in extra_specs.items()
if key in valid_keys}

View File

@ -54,7 +54,6 @@ def destroy(context, type_id):
def get_all(context, inactive=0, search_opts=None):
"""Get all non-deleted share group types."""
# TODO(ameade): Fix docstring
search_opts = search_opts or {}
filters = {}