Skip to content

Commit

Permalink
Added option for example sheet link to import form
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkuhhaut committed Nov 8, 2021
1 parent 7df8d4b commit 89a9151
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gsheets_import/__init__.py
@@ -1 +1 @@
__version__ = '0.0.3'
__version__ = '0.0.4'
5 changes: 5 additions & 0 deletions gsheets_import/admin.py
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions gsheets_import/templates/admin/gsheets_import/import.html
Expand Up @@ -77,6 +77,12 @@
<code>{{ fields|join:", " }}</code>
</p>

{% if import_example_sheet_link %}
<p>
An example Google Sheet with the correct format can be found <a href="{{ import_example_sheet_link }}" target="_blank">here</a>.
</p>
{% endif %}

<fieldset class="module aligned">
{% for field in form %}
<div class="form-row">
Expand Down
1 change: 1 addition & 0 deletions tests/testapp/literature/admin.py
Expand Up @@ -18,6 +18,7 @@ class AuthorAdmin(ImportGoogleModelAdmin):
##
class WorkAdmin(ImportGoogleModelAdmin):
resource_class = WorkResource
import_example_sheet_link = 'https://docs.google.com/spreadsheets/d/1-VADSGcNxWWbhZxkhpgKZS59lTh6GDJtoriHKaE5arY/edit#gid=1386862396'



Expand Down

0 comments on commit 89a9151

Please sign in to comment.