From 89a915169f4469ca3f23b9e109f20ed58a2591f2 Mon Sep 17 00:00:00 2001
From: Alexander Helmboldt
Date: Mon, 8 Nov 2021 13:33:44 +0100
Subject: [PATCH] Added option for example sheet link to import form
---
gsheets_import/__init__.py | 2 +-
gsheets_import/admin.py | 5 +++++
gsheets_import/templates/admin/gsheets_import/import.html | 6 ++++++
tests/testapp/literature/admin.py | 1 +
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/gsheets_import/__init__.py b/gsheets_import/__init__.py
index ffcc925..156d6f9 100644
--- a/gsheets_import/__init__.py
+++ b/gsheets_import/__init__.py
@@ -1 +1 @@
-__version__ = '0.0.3'
+__version__ = '0.0.4'
diff --git a/gsheets_import/admin.py b/gsheets_import/admin.py
index 78406d6..663e5d2 100644
--- a/gsheets_import/admin.py
+++ b/gsheets_import/admin.py
@@ -79,6 +79,10 @@ class ImportGoogleMixin(ImportMixin):
## available import formats
formats = DEFAULT_FORMATS_EXT
+ ## link to an example sheet that is shown on the import page
+ ## (An empty string or None implies that the example text + link is not shown)
+ import_example_sheet_link = None
+
## use the customized import template instead of the default one
def get_import_form(self):
return forms.CustomImportForm
@@ -93,6 +97,7 @@ def get_import_context_data(self, **kwargs):
else:
context['gs_format_display_name'] = GS_FORMAT_DISPLAY_NAME
context['dummy_choice_txt'] = forms.DUMMY_CHOICE_TXT
+ context['import_example_sheet_link'] = self.import_example_sheet_link
context.update(gsheets_import_context)
return context
diff --git a/gsheets_import/templates/admin/gsheets_import/import.html b/gsheets_import/templates/admin/gsheets_import/import.html
index edc3016..d50e43c 100644
--- a/gsheets_import/templates/admin/gsheets_import/import.html
+++ b/gsheets_import/templates/admin/gsheets_import/import.html
@@ -77,6 +77,12 @@
{{ fields|join:", " }}
+ {% if import_example_sheet_link %}
+
+ An example Google Sheet with the correct format can be found here.
+
+ {% endif %}
+