Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ecommerce/coupons/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

import unicodecsv as csv
import waffle
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
Expand All @@ -16,6 +17,7 @@
from django.views.generic import TemplateView, View
from edx_rest_framework_extensions.permissions import LoginRedirectIfUnauthenticated
from oscar.core.loading import get_class, get_model
from rest_framework import status
from rest_framework.views import APIView

from ecommerce.core.url_utils import absolute_redirect, get_ecommerce_url, get_lms_course_about_url
Expand Down Expand Up @@ -158,6 +160,18 @@ def get(self, request): # pylint: disable=too-many-statements
then applies the voucher and if the basket total is FREE places the order and
enrolls the user in the course.
"""
logger.info(
f"[CouponRedeemView] Request for user: {request.user.username}, "
f"referer: {request.META.get('HTTP_REFERER')}, "
f"client IP: {request.META.get('REMOTE_ADDR')}, "
f"and params: {request.get_full_path()}"
)

if waffle.flag_is_active(request, 'disable_ecommerce_service'):
return HttpResponse(
'Service unavailable', status=status.HTTP_503_SERVICE_UNAVAILABLE
)

template_name = 'coupons/_offer_error.html'
code = request.GET.get('code')
sku = request.GET.get('sku')
Expand Down
28 changes: 27 additions & 1 deletion ecommerce/extensions/basket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import dateutil.parser
import waffle
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.utils.html import escape
Expand All @@ -24,6 +24,7 @@
from oscar.core.prices import Price
from requests.exceptions import ConnectionError as ReqConnectionError
from requests.exceptions import RequestException, Timeout
from rest_framework import status as response_status_codes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -417,6 +418,18 @@ class BasketAddItemsView(BasketLogicMixin, APIView):
permission_classes = (LoginRedirectIfUnauthenticated,)

def get(self, request):
logger.info(
f"[BasketAddItemsView] Request for user: {request.user.username}, "
f"referer: {request.META.get('HTTP_REFERER')}, "
f"client IP: {request.META.get('REMOTE_ADDR')}, "
f"and params: {request.get_full_path()}"
)

if waffle.flag_is_active(request, 'disable_ecommerce_service'):
return HttpResponse(
'Service unavailable', status=response_status_codes.HTTP_503_SERVICE_UNAVAILABLE
)

# Send time when this view is called - https://openedx.atlassian.net/browse/REV-984
properties = {'emitted_at': time.time()}
track_segment_event(request.site, request.user, 'Basket Add Items View Called', properties)
Expand Down Expand Up @@ -818,6 +831,19 @@ class PaymentApiView(PaymentApiLogicMixin, APIView):
permission_classes = (IsAuthenticated,)

def get(self, request): # pylint: disable=unused-argument
logger.info(
f"[PaymentApiView] Request for user: {request.user.username}, "
f"referer: {request.META.get('HTTP_REFERER')}, "
f"client IP: {request.META.get('REMOTE_ADDR')}, "
f"and params: {request.get_full_path()}"
)

if waffle.flag_is_active(request, 'disable_ecommerce_service'):
return JsonResponse(
{'error': 'Service unavailable'},
status=response_status_codes.HTTP_503_SERVICE_UNAVAILABLE
)

basket = request.basket

try:
Expand Down
12 changes: 12 additions & 0 deletions ecommerce/extensions/iap/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ class MobileBasketAddItemsView(BasketLogicMixin, APIView):
permission_classes = (LoginRedirectIfUnauthenticated,)

def get(self, request):
logger.info(
f"[MobileBasketAddItemsView] Request for user: {request.user.username}, "
f"referer: {request.META.get('HTTP_REFERER')}, "
f"client IP: {request.META.get('REMOTE_ADDR')}, "
f"and params: {request.get_full_path()}"
)

if waffle.flag_is_active(request, 'disable_ecommerce_service'):
return JsonResponse(
{'error': 'Service unavailable'}, status=status.HTTP_503_SERVICE_UNAVAILABLE
)

# Send time when this view is called - https://openedx.atlassian.net/browse/REV-984
track_segment_event(request.site, request.user, SEGMENT_MOBILE_BASKET_ADD, {'emitted_at': time.time()})

Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ disable=
# the pylint import errors, since they conflict at times.
wrong-import-order,
ungrouped-imports,

logging-fstring-interpolation,
[REPORTS]

# Set the output format. Available formats are text, parseable, colorized, msvs
Expand Down
Loading