Skip to content
Snippets Groups Projects
Commit 9e718a79 authored by Martin Burchell's avatar Martin Burchell
Browse files

Stopped upload button from displaying on all tab

If there is no source set on the tab configuration, the upload
button will no longer be displayed.
parent 3db034ee
No related branches found
No related tags found
1 merge request!27Stopped upload button from displaying on all tab
......@@ -138,19 +138,22 @@ class ViewAndEditTableTab(object):
)
# Build the upload form
source = kwargs.get('source')
next_url = reverse(
'tabbed-page',
kwargs={
'name': tab_instance.page.name,
'tab_name': tab_instance.name,
source = kwargs.get('source', None)
upload_form = None
if source is not None:
next_url = reverse(
'tabbed-page',
kwargs={
'name': tab_instance.page.name,
'tab_name': tab_instance.name,
})
upload_form = UploadForm(initial={
'source': source,
'next': next_url,
})
upload_form = UploadForm(initial={
'source': source,
'next': next_url,
})
# Build the actions drop down
actions = [
self._build_action_dropdown_group(
......
......@@ -6,6 +6,7 @@
<span class="fa fa-table fa-fw"></span>
<h2>{{ type_label }}</h2>
<div class="pull-right">
{% if upload_form %}
<form action="{% url "sources-upload" %}"
method="post"
enctype="multipart/form-data"
......@@ -14,6 +15,7 @@
{% bootstrap_form upload_form show_label=False %}
<a class="btn item-source-upload btn-block btn-primary upload-button" type="button" value="Upload" href="{% url "tabbed-page" name="main" tab_name="all" %}"><span class="fa fa-upload fa-fw"></span>{% blocktrans %}Upload {{ type_label }}{% endblocktrans %}</a>
</form>
{% endif %}
</div>
</div>
<div class="panel-body">
......
......@@ -207,6 +207,21 @@ def test_upload_form_next_url_read_from_tab_instance():
assert form.initial.get('next') == expected_url
@pytest.mark.django_db
def test_no_upload_form_when_source_not_set():
page = TabbedPageFactory(name='main')
tab_instance = TabInstanceFactory(page=page, name='all')
request = Mock(GET={})
tab = ViewAndEditTableTab()
context_data = tab.get_context_data(tab_instance,
request)
form = context_data['upload_form']
assert form is None
def test_views_item_get_request_parameters_renames_items_of_active_location():
query = QueryDict(
'action=something-bottom&item-top=top-value&item-bottom=bottom-value'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment