diff --git a/.gitignore b/.gitignore
index a93e87d..6d96f14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,4 @@ coverage.xml
# Sphinx documentation
docs/_build/
.vscode/
+.DS_Store
\ No newline at end of file
diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py
index 93c6c39..de38e71 100644
--- a/ckanext/officedocs/plugin.py
+++ b/ckanext/officedocs/plugin.py
@@ -26,8 +26,10 @@ def info(self):
def setup_template_variables(self, context, data_dict):
url = quote_plus(data_dict["resource"]["url"])
+ private_package = data_dict["package"]["private"]
return {
- "resource_url": url
+ "resource_url": url,
+ "private_package": private_package
}
def can_view(self, data_dict):
diff --git a/ckanext/officedocs/templates/officedocs/preview.html b/ckanext/officedocs/templates/officedocs/preview.html
index b0ec6a7..c422bc1 100644
--- a/ckanext/officedocs/templates/officedocs/preview.html
+++ b/ckanext/officedocs/templates/officedocs/preview.html
@@ -1,3 +1,6 @@
+{% if private_package %}
+
This resource view will render once the dataset is made public. Microsoft Office preview is unable to access and display private resources.
+{% else %}
+{% endif %}
\ No newline at end of file
diff --git a/ckanext/officedocs/tests/test_plugin.py b/ckanext/officedocs/tests/test_plugin.py
deleted file mode 100644
index 631778a..0000000
--- a/ckanext/officedocs/tests/test_plugin.py
+++ /dev/null
@@ -1,5 +0,0 @@
-"""Tests for plugin.py."""
-import ckanext.gdoc.plugin as plugin
-
-def test_plugin():
- pass
\ No newline at end of file
diff --git a/ckanext/officedocs/tests/test_view.py b/ckanext/officedocs/tests/test_view.py
new file mode 100644
index 0000000..09aab60
--- /dev/null
+++ b/ckanext/officedocs/tests/test_view.py
@@ -0,0 +1,24 @@
+import ckan.plugins as p
+from ckan.tests import factories
+
+def test_view_on_resource_page():
+ sysadmin = factories.Sysadmin()
+ dataset = factories.Dataset()
+ resource = factories.Resource(
+ package_id = dataset['id'],
+ url = 'http://link.to.some.data',
+ format = 'XLS'
+ )
+ resource_view = factories.ResourceView(
+ resource_id = resource['id'],
+ title = 'Preview',
+ view_type = 'officedocs_view'
+ )
+
+ response = p.toolkit.get_action('resource_view_show')(
+ {'user': sysadmin.get('name')},
+ {'id': resource_view.get('id')}
+ )
+
+ assert response.get('title') == 'Preview'
+ assert response.get('view_type') == 'officedocs_view'