mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-20 17:41:55 +02:00
Merge remote-tracking branch 'origin/master' into activity
# Conflicts: # note_kfet/urls.py # templates/base.html
This commit is contained in:
@ -11,7 +11,7 @@ class ActivityAdmin(admin.ModelAdmin):
|
||||
Admin customisation for Activity
|
||||
"""
|
||||
list_display = ('name', 'activity_type', 'organizer')
|
||||
list_filter = ('activity_type', )
|
||||
list_filter = ('activity_type',)
|
||||
search_fields = ['name', 'organizer__name']
|
||||
|
||||
# Organize activities by start date
|
||||
|
@ -11,6 +11,7 @@ class ActivityTypeSerializer(serializers.ModelSerializer):
|
||||
REST API Serializer for Activity types.
|
||||
The djangorestframework plugin will analyse the model `ActivityType` and parse all fields in the API.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = ActivityType
|
||||
fields = '__all__'
|
||||
@ -21,6 +22,7 @@ class ActivitySerializer(serializers.ModelSerializer):
|
||||
REST API Serializer for Activities.
|
||||
The djangorestframework plugin will analyse the model `Activity` and parse all fields in the API.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Activity
|
||||
fields = '__all__'
|
||||
@ -31,6 +33,7 @@ class GuestSerializer(serializers.ModelSerializer):
|
||||
REST API Serializer for Guests.
|
||||
The djangorestframework plugin will analyse the model `Guest` and parse all fields in the API.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Guest
|
||||
fields = '__all__'
|
||||
|
@ -1,13 +1,15 @@
|
||||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from rest_framework import viewsets
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from rest_framework.filters import SearchFilter
|
||||
from api.viewsets import ReadProtectedModelViewSet
|
||||
|
||||
from ..models import ActivityType, Activity, Guest
|
||||
from .serializers import ActivityTypeSerializer, ActivitySerializer, GuestSerializer
|
||||
from ..models import ActivityType, Activity, Guest
|
||||
|
||||
|
||||
class ActivityTypeViewSet(viewsets.ModelViewSet):
|
||||
class ActivityTypeViewSet(ReadProtectedModelViewSet):
|
||||
"""
|
||||
REST API View set.
|
||||
The djangorestframework plugin will get all `ActivityType` objects, serialize it to JSON with the given serializer,
|
||||
@ -15,9 +17,11 @@ class ActivityTypeViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
queryset = ActivityType.objects.all()
|
||||
serializer_class = ActivityTypeSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['name', 'can_invite', ]
|
||||
|
||||
|
||||
class ActivityViewSet(viewsets.ModelViewSet):
|
||||
class ActivityViewSet(ReadProtectedModelViewSet):
|
||||
"""
|
||||
REST API View set.
|
||||
The djangorestframework plugin will get all `Activity` objects, serialize it to JSON with the given serializer,
|
||||
@ -25,9 +29,11 @@ class ActivityViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
queryset = Activity.objects.all()
|
||||
serializer_class = ActivitySerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filterset_fields = ['name', 'description', 'activity_type', ]
|
||||
|
||||
|
||||
class GuestViewSet(viewsets.ModelViewSet):
|
||||
class GuestViewSet(ReadProtectedModelViewSet):
|
||||
"""
|
||||
REST API View set.
|
||||
The djangorestframework plugin will get all `Guest` objects, serialize it to JSON with the given serializer,
|
||||
@ -35,3 +41,5 @@ class GuestViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
queryset = Guest.objects.all()
|
||||
serializer_class = GuestSerializer
|
||||
filter_backends = [SearchFilter]
|
||||
search_fields = ['$name', ]
|
||||
|
Reference in New Issue
Block a user