From 1e6f23cd7cc66ce7222ffef48d79048bfbfbb774 Mon Sep 17 00:00:00 2001 From: Arne Wiebalck Date: Fri, 4 Nov 2016 11:43:07 +0100 Subject: [PATCH] Add access key column to rules table To align with the functionality offered by the CLI, this patch adds an "Access Key" column to the rules table. The access key is also added to the share details overview. For completeness, also the access level and the state are now listed in the details overview. Change-Id: I38516e453e300b4c08a7da5de4acf09d2bdac4d2 Closes-Bug: #1638934 --- .../dashboards/project/shares/shares/tables.py | 1 + .../templates/shares/shares/_detail_overview.html | 7 ++++++- .../dashboards/project/shares/shares/tests.py | 15 ++++++++++++++- .../tests/dashboards/project/shares/test_data.py | 11 ++++++----- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/manila_ui/dashboards/project/shares/shares/tables.py b/manila_ui/dashboards/project/shares/shares/tables.py index f9b595aa..d8493017 100644 --- a/manila_ui/dashboards/project/shares/shares/tables.py +++ b/manila_ui/dashboards/project/shares/shares/tables.py @@ -281,6 +281,7 @@ class RulesTable(tables.DataTable): access_level = tables.Column( "access_level", verbose_name=_("Access Level")) status = tables.Column("state", verbose_name=_("Status")) + access_key = tables.Column("access_key", verbose_name=_("Access Key")) def get_object_display(self, obj): return obj.id diff --git a/manila_ui/dashboards/project/shares/templates/shares/shares/_detail_overview.html b/manila_ui/dashboards/project/shares/templates/shares/shares/_detail_overview.html index b79d5d0d..17a13e14 100644 --- a/manila_ui/dashboards/project/shares/templates/shares/shares/_detail_overview.html +++ b/manila_ui/dashboards/project/shares/templates/shares/shares/_detail_overview.html @@ -76,7 +76,12 @@
{% for rule in share.rules %}
{{ rule.access_type }}
-
{{ rule.access_to }}
+

+

Access to: {{ rule.access_to }}
+
Access Level: {{ rule.access_level }}
+
Status: {{ rule.state }}
+
Access Key: {{ rule.access_key }}
+

{% endfor %}
diff --git a/manila_ui/tests/dashboards/project/shares/shares/tests.py b/manila_ui/tests/dashboards/project/shares/shares/tests.py index c2384b4f..36c1f3ad 100644 --- a/manila_ui/tests/dashboards/project/shares/shares/tests.py +++ b/manila_ui/tests/dashboards/project/shares/shares/tests.py @@ -211,7 +211,20 @@ class ShareViewTests(test.TestCase): 2, 200) for rule in rules: self.assertContains(res, "
%s
" % rule.access_type, 1, 200) - self.assertContains(res, "
%s
" % rule.access_to, 1, 200) + self.assertContains( + res, "
Access to: %s
" % rule.access_to, + 1, 200) + if 'cephx' == rule.access_type: + self.assertContains( + res, "
Access Key: %s
" % rule.access_key, + 1, 200) + self.assertContains( + res, "
Access Key:
", + len(rules) - sum(r.access_type == 'cephx' for r in rules), 200) + self.assertContains( + res, "
Access Level: rw
", len(rules), 200) + self.assertContains( + res, "
Status: active
", len(rules), 200) self.assertNoMessages() api_manila.share_rules_list.assert_called_once_with( mock.ANY, self.share.id) diff --git a/manila_ui/tests/dashboards/project/shares/test_data.py b/manila_ui/tests/dashboards/project/shares/test_data.py index 118203bf..20e86c45 100644 --- a/manila_ui/tests/dashboards/project/shares/test_data.py +++ b/manila_ui/tests/dashboards/project/shares/test_data.py @@ -160,15 +160,16 @@ user_export_location = share_export_locations.ShareExportLocation( export_locations = [admin_export_location, user_export_location] -rule = collections.namedtuple('Access', ['access_type', 'access_to', 'status', - 'id']) +rule = collections.namedtuple('Access', ['access_type', 'access_to', 'state', + 'id', 'access_level', 'access_key']) user_rule = rule('user', 'someuser', 'active', - '10837072-c49e-11e3-bd64-60a44c371189') + '10837072-c49e-11e3-bd64-60a44c371189', 'rw', '') ip_rule = rule('ip', '1.1.1.1', 'active', - '2cc8e2f8-c49e-11e3-bd64-60a44c371189') + '2cc8e2f8-c49e-11e3-bd64-60a44c371189', 'rw', '') cephx_rule = rule('cephx', 'alice', 'active', - '235481bc-1a84-11e6-9666-68f728a0492e') + '235481bc-1a84-11e6-9666-68f728a0492e', 'rw', + 'AQAdFCNYDCapMRAANuK/CiEZbog2911a+t5dcQ==') snapshot = share_snapshots.ShareSnapshot( share_snapshots.ShareSnapshotManager(FakeAPIClient),