/
offer_list_feedback.py
47 lines (39 loc) · 1.25 KB
/
offer_list_feedback.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
APIv3 feedback endpoint for feedback about offers
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from django.http import JsonResponse
if TYPE_CHECKING:
from ....cms.models import Language, Region
from ....cms.models import OfferListFeedback
from ...decorators import feedback_handler, json_response
@feedback_handler
@json_response
# pylint: disable=unused-argument
def offer_list_feedback(
data: dict,
region: Region,
language: Language,
comment: str,
rating: bool,
is_technical: bool,
) -> JsonResponse:
"""
Store feedback about offers list in database
:param data: HTTP request body data
:param region: The region of this sitemap's urls
:param language: The language of this sitemap's urls
:param comment: The comment sent as feedback
:param rating: up or downvote, neutral
:param is_technical: is feedback on content or on tech
:return: JSON object according to APIv3 offers list feedback endpoint definition
"""
OfferListFeedback.objects.create(
region=region,
language=language,
rating=rating,
comment=comment,
is_technical=is_technical,
)
return JsonResponse({"success": "Feedback successfully submitted"}, status=201)