Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion backend/src/baserow/contrib/database/api/views/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from baserow.api.utils import serialize_validation_errors_recursive
from baserow.contrib.database.api.constants import PUBLIC_PLACEHOLDER_ENTITY_ID
from baserow.contrib.database.api.fields.serializers import FieldSerializer
from baserow.contrib.database.api.tables.serializers import (
TableWithoutDataSyncSerializer,
)
from baserow.contrib.database.fields.field_filters import (
FILTER_TYPE_AND,
FILTER_TYPE_OR,
Expand All @@ -34,8 +37,10 @@
view_ownership_type_registry,
view_type_registry,
)
from baserow.contrib.database.views.view_ownership_types import (
CollaborativeViewOwnershipType,
)

from ..tables.serializers import TableWithoutDataSyncSerializer
from .exceptions import FiltersParamValidationException


Expand Down Expand Up @@ -614,6 +619,7 @@ class PublicViewSerializer(serializers.ModelSerializer):
sortings = serializers.SerializerMethodField()
group_bys = serializers.SerializerMethodField()
show_logo = serializers.BooleanField(required=False)
ownership_type = serializers.SerializerMethodField()

@extend_schema_field(PublicViewSortSerializer(many=True))
def get_sortings(self, instance):
Expand Down Expand Up @@ -641,6 +647,13 @@ def get_group_bys(self, instance):
def get_type(self, instance):
return view_type_registry.get_by_model(instance.specific_class).type

@extend_schema_field(OpenApiTypes.STR)
def get_ownership_type(self, instance):
# The publicly shared view does not need to know which view ownership type is
# publicly shared. However, it does need to have this value in order to work
# correctly, so we can always expose the collaborative type.
return CollaborativeViewOwnershipType.type

class Meta:
model = View
fields = (
Expand All @@ -655,6 +668,7 @@ class Meta:
"slug",
"show_logo",
"allow_public_export",
"ownership_type",
)
extra_kwargs = {
"id": {"read_only": True},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ def test_get_public_gallery_view(api_client, data_fixture):
"card_cover_image_field": None,
"show_logo": True,
"allow_public_export": False,
"ownership_type": "collaborative",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3351,6 +3351,7 @@ def test_get_public_grid_view(api_client, data_fixture):
"row_height_size": grid_view.row_height_size,
"show_logo": True,
"allow_public_export": False,
"ownership_type": "collaborative",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ def test_user_with_password_can_get_info_about_a_public_password_protected_view(
"row_height_size": grid_view.row_height_size,
"show_logo": grid_view.show_logo,
"allow_public_export": grid_view.allow_public_export,
"ownership_type": "collaborative",
},
}

Expand Down Expand Up @@ -1011,6 +1012,7 @@ def test_user_with_password_can_get_info_about_a_public_password_protected_view(
"row_height_size": grid_view.row_height_size,
"show_logo": grid_view.show_logo,
"allow_public_export": grid_view.allow_public_export,
"ownership_type": "collaborative",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ def test_get_public_calendar_view_with_single_select_and_cover(
"allow_public_export": False,
"ical_public": False,
"ical_feed_url": calendar_view.ical_feed_url,
"ownership_type": "collaborative",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,7 @@ def test_get_public_kanban_without_with_single_select_and_cover(
"single_select_field": None,
"show_logo": True,
"allow_public_export": False,
"ownership_type": "collaborative",
},
}

Expand Down Expand Up @@ -1714,6 +1715,7 @@ def test_get_public_kanban_view_with_single_select_and_cover(
"single_select_field": single_select_field.id,
"show_logo": True,
"allow_public_export": False,
"ownership_type": "collaborative",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ def test_get_public_timeline_view(api_client, premium_data_fixture):
"start_date_field": start_date_field.id,
"end_date_field": end_date_field.id,
"timescale": "month",
"ownership_type": "collaborative",
},
}

Expand Down
Loading