Skip to content

Commit

Permalink
Merge pull request #472 from Cadasta/bugfix/#315
Browse files Browse the repository at this point in the history
Fixes #315 -- Set _errors when contact is removed
  • Loading branch information
ian-ross authored Jul 20, 2016
2 parents c1275be + dfa35de commit 97aeb90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cadasta/organization/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from core.util import slugify
from django.utils.translation import ugettext as _
from django.db import transaction
from django.forms.utils import ErrorDict

from leaflet.forms.widgets import LeafletWidget
from tutelary.models import Role
Expand Down Expand Up @@ -63,6 +64,7 @@ def full_clean(self):
if self.data.get(self.prefix + '-remove') != 'on':
super().full_clean()
else:
self._errors = ErrorDict()
self.cleaned_data = {'remove': True}

def clean(self):
Expand Down
2 changes: 2 additions & 0 deletions cadasta/organization/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from zipfile import ZipFile

from django.conf import settings
from django.forms.utils import ErrorDict

from buckets.test import utils as bucket_uitls
from buckets.test.storage import FakeS3Storage
Expand Down Expand Up @@ -561,6 +562,7 @@ def test_full_clean_remove(self):
form = forms.ContactsForm(data=data, prefix='contacts')
form.full_clean()
assert form.cleaned_data == {'remove': True}
assert isinstance(form._errors, ErrorDict)

def test_validate_valid_form_with_email(self):
data = {
Expand Down

0 comments on commit 97aeb90

Please sign in to comment.