Skip to content
Snippets Groups Projects
Verified Commit e3a57e85 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Remove special writable serializer

parent 9fcb3741
Branches 77-fallback-for-rebinning-is-not-subset
No related tags found
1 merge request!5Resolve "Test API"
Pipeline #7074 passed
......@@ -41,7 +41,7 @@ class UserViewSet(MaskedRelatedMixin, viewsets.ReadOnlyModelViewSet):
location = {'Location': api_url}
return {
"Link": f'{ui_url}; rel="ui"',
"Link": f'<{ui_url}>; rel="ui"',
**location
}
......@@ -81,7 +81,7 @@ class CollectionViewSet(viewsets.ModelViewSet):
location = {"Location": api_url}
return {
"Link": f'{ui_url}; rel="ui"',
"Link": f'<{ui_url}>; rel="ui"',
**location
}
......@@ -128,7 +128,7 @@ class PlotViewSet(viewsets.ModelViewSet):
permission_classes = [IsCollectionOwnerOrReadOnly]
def create(self, request, *args, **kwds):
serializer = self.get_serializer_visible(data=request.data)
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
prototype = Namespace(**serializer.validated_data)
......@@ -151,7 +151,7 @@ class PlotViewSet(viewsets.ModelViewSet):
location = {"Location": api_url}
return {
"Link": f'{ui_url}; rel="ui"',
"Link": f'<{ui_url}>; rel="ui"',
"X-Resource-UUID": uuid,
**location
}
......@@ -165,22 +165,6 @@ class PlotViewSet(viewsets.ModelViewSet):
def get_serializer(self, *args, **kwds):
serializer = super().get_serializer(*args, **kwds)
# Filter queryset for browsable API choices
patching = serializer
if hasattr(patching, "child"):
patching = patching.child
queryset = patching.fields["collection"].queryset
if self.request.user.is_authenticated:
patching.fields["collection"].queryset = queryset.filter(owner=self.request.user)
else:
patching.fields["collection"].queryset = queryset.none()
return serializer
def get_serializer_visible(self, *args, **kwds):
serializer = super().get_serializer(*args, **kwds)
# Filter queryset for browsable API choices
patching = serializer
if hasattr(patching, "child"):
......
......@@ -12,9 +12,9 @@ PRIVATE_LEVEL = 10
INTERNAL_LEVEL = 20
PUBLIC_LEVEL = 30
VISIBILITY_LEVELS = [
(PUBLIC_LEVEL, _("Publicly accessible")),
(PRIVATE_LEVEL, _("Accessible only by you")),
(INTERNAL_LEVEL, _("Accessible only by members of your collaboration")),
(PRIVATE_LEVEL, _("Accessible only by you"))
(PUBLIC_LEVEL, _("Publicly accessible")),
]
class Collection(models.Model):
......
<p>uhepp.org &ndash; home of {{ plot_count }} plots</p>
<a href="{% url 'uhepp_vault:plot-index' %}">Browser index</a>
......@@ -5,7 +5,7 @@ from . import views
app_name = 'uhepp_vault'
urlpatterns = [
# path('', views.home, name='home'),
path('', views.home, name='home'),
# path('p/', views.PlotIndex.as_view(), name='plot-index'),
# path('accounts/', views.account, name='account'),
# path('accounts/login/', auth_views.LoginView.as_view()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment