Beispiel #1
0
def table_created(sender, table, user, **kwargs):
    transaction.on_commit(lambda: broadcast_to_group.delay(
        table.database.group_id,
        {
            "type": "table_created",
            "table": TableSerializer(table).data
        },
        getattr(user, "web_socket_id", None),
    ))
Beispiel #2
0
def table_created(sender, table, user, **kwargs):
    transaction.on_commit(lambda: broadcast_to_group.delay(
        table.database.group_id,
        {
            'type': 'table_created',
            'table': TableSerializer(table).data
        },
        getattr(user, 'web_socket_id', None)
    ))
Beispiel #3
0
    def get_tables(self, instance):
        """
        Because the the instance doesn't know at this point it is a Database we have to
        select the related tables this way.

        :param instance: The database application instance.
        :type instance: Application
        :return: A list of serialized tables that belong to this instance.
        :rtype: list
        """

        tables = Table.objects.filter(database_id=instance.pk)
        return TableSerializer(tables, many=True).data
Beispiel #4
0
class DatabaseSerializer(ApplicationSerializer):
    tables = serializers.SerializerMethodField(
        help_text=
        "This field is specific to the `database` application and contains "
        "an array of tables that are in the database.")

    class Meta(ApplicationSerializer.Meta):
        ref_name = "DatabaseApplication"
        fields = ApplicationSerializer.Meta.fields + ("tables", )

    @extend_schema_field(TableSerializer(many=True))
    def get_tables(self, instance):
        """
        Because the the instance doesn't know at this point it is a Database we have to
        select the related tables this way.

        :param instance: The database application instance.
        :type instance: Application
        :return: A list of serialized tables that belong to this instance.
        :rtype: list
        """

        tables = Table.objects.filter(database_id=instance.pk)
        return TableSerializer(tables, many=True).data