Skip to content

Commit

Permalink
fix validation for custom fields, more csrf exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Feb 17, 2011
1 parent 67ecaa6 commit 733da76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions rapidsms_xforms/models.py
Expand Up @@ -175,6 +175,7 @@ def update_submission_from_dict(self, submission, values):
# no new value, we need to remove this one
else:
value.delete()

# now add any remaining values in our dict
for key, value in values.items():
# look up the field by key
Expand Down
6 changes: 4 additions & 2 deletions rapidsms_xforms/views.py
Expand Up @@ -298,12 +298,12 @@ def clean(self):
field_val = str(cleaned_data.get(command))

try:
print "XFormField %s cleaning %s" % (field, field_val)
cleaned_val = field.clean_submission(field_val)
cleaned_data[command] = cleaned_val
except ValidationError as err:
# if there is an error, remove it from our cleaned data and
# add the error to our list of errors for this form
self._errors[field.command] = (self.error_class(err))
self._errors[field.command] = self.error_class(err.messages)
del cleaned_data[field.command]

return cleaned_data
Expand Down Expand Up @@ -399,6 +399,7 @@ def delete_field (req, form_id, field_id):

return redirect("/xforms/%d/edit/" % xform.pk)

@csrf_exempt
def add_constraint(req, form_id, field_id):
xform = XForm.on_site.get(pk=form_id)
field = XFormField.objects.get(pk=field_id)
Expand All @@ -422,6 +423,7 @@ def add_constraint(req, form_id, field_id):
{ 'buttons' : add_button, 'form' : form, 'xform' : xform, 'field' : field },
context_instance=RequestContext(req))

@csrf_exempt
def edit_constraint(req, form_id, field_id, constraint_id) :

xform = XForm.on_site.get(pk=form_id)
Expand Down

0 comments on commit 733da76

Please sign in to comment.