Skip to content

Commit

Permalink
Fix #528: Include contacts when adding a project
Browse files Browse the repository at this point in the history
  • Loading branch information
seav committed Aug 9, 2016
1 parent 8578f3f commit 066f15b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cadasta/organization/tests/test_views_default_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ def _get_xls_form(self, form_name):
'details-url': 'http://www.test.org',
'details-contacts-TOTAL_FORMS': 1,
'details-contacts-INITIAL_FORMS': 0,
'details-contacts-0-name': '',
'details-contacts-0-email': '',
'details-contacts-0-name': "John Lennon",
'details-contacts-0-email': '[email protected]',
'details-contacts-0-tel': ''
}
PERMISSIONS_POST_DATA = {
Expand Down Expand Up @@ -499,6 +499,9 @@ def test_full_flow_valid(self):
proj = Project.objects.get(organization=self.org, name='Test Project')
assert proj.slug == 'test-project'
assert proj.description == 'This is a test project'
assert len(proj.contacts) == 1
assert proj.contacts[0]['name'] == "John Lennon"
assert proj.contacts[0]['email'] == '[email protected]'
assert ProjectRole.objects.filter(project=proj).count() == 3
for r in ProjectRole.objects.filter(project=proj):
if r.user.username == 'org_member_1':
Expand Down Expand Up @@ -535,6 +538,9 @@ def test_full_flow_invalid_xlsform(self):
proj = Project.objects.get(organization=self.org, name='Test Project')
assert proj.slug == 'test-project'
assert proj.description == 'This is a test project'
assert len(proj.contacts) == 1
assert proj.contacts[0]['name'] == "John Lennon"
assert proj.contacts[0]['email'] == '[email protected]'
for r in ProjectRole.objects.filter(project=proj):
if r.user.username == 'org_member_1':
assert r.role == 'PM'
Expand Down Expand Up @@ -576,6 +582,9 @@ def test_full_flow_long_slug(self):
proj = Project.objects.get(organization=self.org, slug=expected_slug)
assert proj.slug == expected_slug
assert proj.description == 'This is a test project'
assert len(proj.contacts) == 1
assert proj.contacts[0]['name'] == "John Lennon"
assert proj.contacts[0]['email'] == '[email protected]'
assert ProjectRole.objects.filter(project=proj).count() == 3
for r in ProjectRole.objects.filter(project=proj):
if r.user.username == 'org_member_1':
Expand Down
8 changes: 5 additions & 3 deletions cadasta/organization/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,14 @@ def get_form_kwargs(self, step=None):
def done(self, form_list, form_dict, **kwargs):
form_data = [form.cleaned_data for form in form_list]
extent = form_data[0]['extent']
organization = form_data[1]['organization']
name = form_data[1]['name']
description = form_data[1]['description']
organization = form_data[1]['organization']
access = form_data[1].get('access')
url = form_data[1]['url']
questionaire = form_data[1].get('questionaire')
access = form_data[1].get('access')
contacts = form_data[1].get('contacts')

org = Organization.objects.get(slug=organization)

user_roles = []
Expand All @@ -444,7 +446,7 @@ def done(self, form_list, form_dict, **kwargs):
project = Project.objects.create(
name=name, organization=org,
description=description, urls=[url], extent=extent,
access=access
access=access, contacts=contacts
)
for username, role in user_roles:
user = User.objects.get(username=username)
Expand Down

0 comments on commit 066f15b

Please sign in to comment.