def defaults(self): defaults = super(ReservationDataEditForm, self).defaults() reservation = self.get_reservation() defaults['start_time'] = reservation.start end = reservation.end if end: end += timedelta(microseconds=1) defaults['end_time'] = end defaults['description'] = reservation.description defaults['email'] = reservation.email if not self.context.formsets: return defaults data = self.get_reservation_data() errors = [e.widget.__name__ for e in self.extracted_errors] for form in data: for value in data[form]['values']: if isinstance(value['value'], basestring): decoded = utils.userformdata_decode(value['value']) fieldvalue = decoded or value['value'] else: fieldvalue = value['value'] fieldkey = '{}.{}'.format(form, value['key']) if fieldkey in self.extracted_data or fieldkey in errors: continue else: defaults[fieldkey] = fieldvalue return defaults
def defaults(self): defaults = super(ReservationDataEditForm, self).defaults() if not self.context.formsets: return defaults data = self.get_reservation_data() errors = [e.widget.__name__ for e in self.extracted_errors] for form in data: for value in data[form]['values']: if isinstance(value['value'], basestring): decoded = utils.userformdata_decode(value['value']) fieldvalue = decoded or value['value'] else: fieldvalue = value['value'] fieldkey = '{}.{}'.format(form, value['key']) if fieldkey in self.extracted_data or fieldkey in errors: continue else: defaults[fieldkey] = fieldvalue return defaults
def defaults(self): defaults = super(ReservationDataEditForm, self).defaults() if not self.reservation: return defaults defaults["email"] = self.reservation.email self.working, self.broken = self.separate_broken_data() data = self.working errors = [e.widget.__name__ for e in self.extracted_errors] for form in data: for value in data[form]["values"]: if isinstance(value["value"], six.string_types): decoded = utils.userformdata_decode(value["value"]) fieldvalue = decoded or value["value"] else: fieldvalue = value["value"] fieldkey = "{}.{}".format(form, value["key"]) if fieldkey in self.extracted_data or fieldkey in errors: continue else: defaults[fieldkey] = fieldvalue return defaults
def defaults(self): defaults = super(ReservationDataEditForm, self).defaults() if not self.reservation: return defaults defaults['email'] = self.reservation.email self.working, self.broken = self.separate_broken_data() data = self.working errors = [e.widget.__name__ for e in self.extracted_errors] for form in data: for value in data[form]['values']: if isinstance(value['value'], six.string_types): decoded = utils.userformdata_decode(value['value']) fieldvalue = decoded or value['value'] else: fieldvalue = value['value'] fieldkey = '{}.{}'.format(form, value['key']) if fieldkey in self.extracted_data or fieldkey in errors: continue else: defaults[fieldkey] = fieldvalue return defaults