Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
pull content into sms form from url param
Browse files Browse the repository at this point in the history
  • Loading branch information
monty5811 committed Aug 9, 2016
1 parent 18c02ac commit c5c75c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Added
- Allow prefilling of sending forms using URL params

### Changed
- Move to Django 1.10
- Serialize phone numbers in api if user should see them
Expand Down
5 changes: 5 additions & 0 deletions apostello/views/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def get_form(self, **kwargs):
prepopulated_recipients = self.request.GET.getlist('recipient')
if prepopulated_recipients:
form.initial['recipients'] = prepopulated_recipients

prepopulated_message = self.request.GET.get('content')
if prepopulated_message is not None:
form.initial['content'] = prepopulated_message

form.user = self.request.user
return form

Expand Down
12 changes: 12 additions & 0 deletions tests/functional_tests/apostello/test_send_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ def test_prepopulated(
last_out_sms = SmsOutbound.objects.all()[0]
assert last_out_sms.recipient.pk == recipients['calvin'].pk

def test_prepopulated_content(
self, live_server, browser_in, users, driver_wait_time, recipients
):
"""Test the multiple recipients in prepopulated field."""
# load the incoming log
uri = '{0}?content={1}'.format(
ADHOC_URI,
'DO%20NOT%20REPLY'
)
b = load_page(browser_in, driver_wait_time, live_server + uri)
assert 'DO NOT REPLY' in b.page_source


@pytest.mark.django_db(transaction=True)
@pytest.mark.slow
Expand Down

0 comments on commit c5c75c4

Please sign in to comment.