Esempio n. 1
0
 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
Esempio n. 2
0
 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']
Esempio n. 3
0
 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']
Esempio n. 4
0
 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
Esempio n. 5
0
 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