Skip to content

Commit

Permalink
Fixed upload form to read source from tab settings
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Aug 6, 2015
1 parent 373dfef commit a5d4120
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/website/hid/tabs/view_and_edit_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def get_context_data(self, request, **kwargs):
)

# Build the upload form
upload_form = UploadForm(initial={'source': 'geopoll'})
source = kwargs.get('source')
upload_form = UploadForm(initial={'source': source})

# Build the actions drop down
actions = [
Expand Down
12 changes: 12 additions & 0 deletions django/website/hid/tests/views_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from mock import Mock
import pytest

from django.contrib.messages.storage.fallback import FallbackStorage
Expand Down Expand Up @@ -162,6 +163,17 @@ def test_get_category_options_orders_by_lowercase_name():
assert options == expected


@pytest.mark.django_db
def test_upload_form_source_read_from_settings():
tab = ViewAndEditTableTab()

request = Mock(GET={})
context_data = tab.get_context_data(request, source='rapidpro')

form = context_data['upload_form']
assert form.initial == {'source': 'rapidpro'}


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'
Expand Down

0 comments on commit a5d4120

Please sign in to comment.