Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #315 -- Set _errors when contact is removed #472

Merged
merged 1 commit into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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