def validate_type(self, attrs, source): type = attrs[source] if type not in WidgetDataSourceTypes.TYPE_NAMES: raise ValidationError( 'Widget data source type %s not recognized.' % type) attrs[source] = WidgetDataSourceTypes.get_id_for_type_name(type) return attrs
def assert_widget_data_sources(self, widget_id, data): result_data_sources = sorted(WidgetDataSource.objects.filter( widget_id=widget_id, status=ObjectStatus.VISIBLE), key=lambda x: x.order) data.sort(key=lambda x: x['order']) for ds, expected_ds in zip(result_data_sources, data): assert ds.name == expected_ds['name'] assert ds.type == WidgetDataSourceTypes.get_id_for_type_name( expected_ds['type']) assert ds.order == expected_ds['order'] assert ds.data == expected_ds['data']
def assert_widget_data_sources(self, widget_id, data): result_data_sources = sorted( WidgetDataSource.objects.filter( widget_id=widget_id, status=ObjectStatus.VISIBLE ), key=lambda x: x.order ) data.sort(key=lambda x: x['order']) for ds, expected_ds in zip(result_data_sources, data): assert ds.name == expected_ds['name'] assert ds.type == WidgetDataSourceTypes.get_id_for_type_name(expected_ds['type']) assert ds.order == expected_ds['order'] assert ds.data == expected_ds['data']
def validate_type(self, type): if type not in WidgetDataSourceTypes.TYPE_NAMES: raise ValidationError( "Widget data source type %s not recognized." % type) type = WidgetDataSourceTypes.get_id_for_type_name(type) return type
def validate_type(self, attrs, source): type = attrs[source] if type not in WidgetDataSourceTypes.TYPE_NAMES: raise ValidationError('Widget data source type %s not recognized.' % type) attrs[source] = WidgetDataSourceTypes.get_id_for_type_name(type) return attrs