mirror of
https://github.com/Dadechin/Dashboard-XRoom.git
synced 2025-07-16 15:14:33 +00:00
42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
from rest_framework.decorators import api_view, authentication_classes, permission_classes
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from rest_framework.authentication import TokenAuthentication, SessionAuthentication
|
|
from rest_framework.response import Response
|
|
from rest_framework import status
|
|
from drf_yasg.utils import swagger_auto_schema
|
|
from drf_yasg import openapi
|
|
from core.serializers.MeetingSerializer import MeetingSerializer
|
|
|
|
|
|
@swagger_auto_schema(
|
|
method='post',
|
|
request_body=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
required=['name', 'description', 'date_time'],
|
|
properties={
|
|
'name': openapi.Schema(type=openapi.TYPE_STRING, default='Sprint Planning'),
|
|
'description': openapi.Schema(type=openapi.TYPE_STRING, default='Discuss the next sprint'),
|
|
'date_time': openapi.Schema(type=openapi.TYPE_STRING, format='date-time', default='2025-06-01T14:00:00Z'),
|
|
'space': openapi.Schema(type=openapi.TYPE_INTEGER, default=1),
|
|
'asset_bundle': openapi.Schema(type=openapi.TYPE_INTEGER, default=1),
|
|
'use_space': openapi.Schema(type=openapi.TYPE_BOOLEAN, default=False),
|
|
}
|
|
)
|
|
)
|
|
@api_view(['POST'])
|
|
@authentication_classes([SessionAuthentication, TokenAuthentication])
|
|
@permission_classes([IsAuthenticated])
|
|
def addMeeting(request):
|
|
data = request.data.copy()
|
|
data['creator_user'] = request.user.id
|
|
|
|
serializer = MeetingSerializer(data=data)
|
|
if serializer.is_valid():
|
|
meeting = serializer.save()
|
|
return Response({
|
|
"message": "Meeting created successfully.",
|
|
"meeting": serializer.data
|
|
}, status=status.HTTP_201_CREATED)
|
|
|
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|