added first public views - no check for access rights at the moment
This commit is contained in:
1
content/views/__init__.py
Normal file
1
content/views/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .api import QuestionViewSet
|
||||
50
content/views/api.py
Normal file
50
content/views/api.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.utils import swagger_auto_schema, status
|
||||
from rest_framework import viewsets
|
||||
|
||||
from content.models import Question
|
||||
from content.serializers import QuestionSerializer
|
||||
from lib.api.permissions import IsAuthorOrReadOnly
|
||||
|
||||
|
||||
class QuestionViewSet(viewsets.ModelViewSet):
|
||||
queryset = Question.objects.all()
|
||||
serializer_class = QuestionSerializer
|
||||
permission_classes = (
|
||||
IsAuthorOrReadOnly,
|
||||
)
|
||||
|
||||
@swagger_auto_schema(
|
||||
request_body=openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
"question": openapi.Schema(
|
||||
type=openapi.TYPE_STRING, description="Email Address"
|
||||
),
|
||||
"awnser": openapi.Schema(
|
||||
type=openapi.TYPE_STRING, description="Previous Password"
|
||||
),
|
||||
"label": openapi.Schema(
|
||||
type=openapi.TYPE_STRING, description="New Password"
|
||||
),
|
||||
},
|
||||
),
|
||||
responses={
|
||||
status.HTTP_202_ACCEPTED: openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
"status": openapi.Schema(type=openapi.TYPE_NUMBER),
|
||||
"message": openapi.Schema(type=openapi.TYPE_STRING),
|
||||
},
|
||||
),
|
||||
status.HTTP_401_UNAUTHORIZED: openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
"status": openapi.Schema(type=openapi.TYPE_NUMBER),
|
||||
"message": openapi.Schema(type=openapi.TYPE_STRING),
|
||||
},
|
||||
),
|
||||
},
|
||||
)
|
||||
def create(self, request):
|
||||
pass
|
||||
13
content/views/public.py
Normal file
13
content/views/public.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
from content.models import Question
|
||||
|
||||
|
||||
def search_question(request):
|
||||
term = request.GET.get('term')
|
||||
items = []
|
||||
if term:
|
||||
items = Question.get_by_tearchterm(term)
|
||||
else:
|
||||
items = Question.objects.all()[:10]
|
||||
return render(request, 'questions.html', {'items': items})
|
||||
Reference in New Issue
Block a user