Fix for loosing data when there is a form validation error. Issue #42.

Added info message when there is an validation error and items are not shown.
This commit is contained in:
Tom Price
2015-03-31 10:33:57 +01:00
parent 99208f4022
commit 8340fd49d4
3 changed files with 68 additions and 45 deletions

View File

@@ -23,6 +23,14 @@ class EventForm(forms.ModelForm):
items = {}
related_models = {
'person': models.Person,
'organisation': models.Organisation,
'venue': models.Venue,
'mic': models.Profile,
'checked_in_by': models.Profile,
}
@property
def _get_items_json(self):
items = {}
@@ -37,6 +45,10 @@ class EventForm(forms.ModelForm):
self.fields['items_json'].initial = self._get_items_json
def init_items(self):
self.items = self.process_items_json()
return self.items
def process_items_json(self, event=None):
data = simplejson.loads(self.cleaned_data['items_json'])
items = {}