Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#653 | Feedback API | making it available to…
Browse files Browse the repository at this point in the history
… swagger as well
  • Loading branch information
snyaggarwal committed Mar 18, 2021
1 parent 32d4f35 commit b37ee01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 0 additions & 6 deletions core/common/swagger_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@
apps_param = openapi.Parameter(
'apps', openapi.IN_FORM, description="App Names (comma separated)", type=openapi.TYPE_STRING
)
feedback_message_param = openapi.Parameter(
'message', openapi.IN_FORM, description="Feedback/Suggestion/Complaint", type=openapi.TYPE_STRING
)
feedback_url_param = openapi.Parameter(
'url', openapi.IN_FORM, description="Specific URL to point", type=openapi.TYPE_STRING
)
ids_param = openapi.Parameter(
'ids', openapi.IN_FORM, description="Resource Ids", type=openapi.TYPE_STRING
)
Expand Down
14 changes: 9 additions & 5 deletions core/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from django.core.mail import EmailMessage
from django.http import Http404
from django.shortcuts import get_object_or_404
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from elasticsearch_dsl import Q
from pydash import get
from rest_framework import response, generics, status
from rest_framework.generics import ListAPIView, RetrieveUpdateDestroyAPIView
from rest_framework.parsers import MultiPartParser
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView
Expand All @@ -19,7 +19,6 @@
LIMIT_PARAM, NOT_FOUND, MUST_SPECIFY_EXTRA_PARAM_IN_BODY, INCLUDE_RETIRED_PARAM, VERBOSE_PARAM, HEAD
from core.common.mixins import PathWalkerMixin
from core.common.serializers import RootSerializer
from core.common.swagger_parameters import feedback_message_param, feedback_url_param
from core.common.utils import compact_dict_by_values, to_snake_case, to_camel_case, parse_updated_since_param
from core.concepts.permissions import CanViewParentDictionary, CanEditParentDictionary
from core.orgs.constants import ORG_OBJECT_TYPE
Expand Down Expand Up @@ -566,12 +565,17 @@ def post(self, request, *args, **kwargs): # pylint: disable=unused-argument

class FeedbackView(APIView): # pragma: no cover
permission_classes = (AllowAny, )
parser_classes = (MultiPartParser,)

@staticmethod
@swagger_auto_schema(manual_parameters=[feedback_message_param, feedback_url_param])
@swagger_auto_schema(request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'description': openapi.Schema(type=openapi.TYPE_STRING, description='Feedback/Suggestion/Complaint'),
'url': openapi.Schema(type=openapi.TYPE_STRING, description='Specific URL to point'),
}
))
def post(request):
message = request.data.get('message', '') or ''
message = request.data.get('description', '') or ''
url = request.data.get('url', False)

if not message and not url:
Expand Down

0 comments on commit b37ee01

Please sign in to comment.