示例#1
0
    def validate_displayType(self, attrs, source):
        display_type = attrs[source]
        if display_type not in WidgetDisplayTypes.TYPE_NAMES:
            raise ValidationError('Widget displayType %s not recognized.' % display_type)

        attrs[source] = WidgetDisplayTypes.get_id_for_type_name(display_type)
        return attrs
示例#2
0
    def validate_displayType(self, attrs, source):
        display_type = attrs[source]
        if display_type not in WidgetDisplayTypes.TYPE_NAMES:
            raise ValidationError('Widget displayType %s not recognized.' %
                                  display_type)

        attrs[source] = WidgetDisplayTypes.get_id_for_type_name(display_type)
        return attrs
示例#3
0
 def serialize(self, obj, attrs, user, **kwargs):
     return {
         "id": six.text_type(obj.id),
         "order": six.text_type(obj.order),
         "title": obj.title,
         "displayType": WidgetDisplayTypes.get_type_name(obj.display_type),
         "displayOptions": obj.display_options,
         "dateAdded": obj.date_added,
         "dashboardId": six.text_type(obj.dashboard_id),
         "dataSources": attrs["dataSources"],
     }
示例#4
0
 def serialize(self, obj, attrs, user, *args, **kwargs):
     return {
         'id': six.text_type(obj.id),
         'order': six.text_type(obj.order),
         'title': obj.title,
         'displayType': WidgetDisplayTypes.get_type_name(obj.display_type),
         'displayOptions': obj.display_options,
         'dateAdded': obj.date_added,
         'dashboardId': six.text_type(obj.dashboard_id),
         'dataSources': attrs['dataSources'],
     }
 def serialize(self, obj, attrs, user, **kwargs):
     return {
         'id': six.text_type(obj.id),
         'order': six.text_type(obj.order),
         'title': obj.title,
         'displayType': WidgetDisplayTypes.get_type_name(obj.display_type),
         'displayOptions': obj.display_options,
         'dateAdded': obj.date_added,
         'dashboardId': six.text_type(obj.dashboard_id),
         'dataSources': attrs['dataSources'],
     }
 def assert_widget(self, data, expected_widget):
     assert data["id"] == six.text_type(expected_widget.id)
     assert data["title"] == expected_widget.title
     assert data["displayType"] == WidgetDisplayTypes.get_type_name(expected_widget.display_type)
     assert data["displayOptions"] == expected_widget.display_options
示例#7
0
    def validate_displayType(self, display_type):
        if display_type not in WidgetDisplayTypes.TYPE_NAMES:
            raise ValidationError("Widget displayType %s not recognized." %
                                  display_type)

        return WidgetDisplayTypes.get_id_for_type_name(display_type)
示例#8
0
 def assert_widget(self, data, expected_widget):
     assert data['id'] == six.text_type(expected_widget.id)
     assert data['title'] == expected_widget.title
     assert data['displayType'] == WidgetDisplayTypes.get_type_name(
         expected_widget.display_type)
     assert data['displayOptions'] == expected_widget.display_options
 def assert_widget(self, data, expected_widget):
     assert data['id'] == six.text_type(expected_widget.id)
     assert data['title'] == expected_widget.title
     assert data['displayType'] == WidgetDisplayTypes.get_type_name(expected_widget.display_type)
     assert data['displayOptions'] == expected_widget.display_options