diff --git a/apps/payment/templates/payment/course_payment_success.html b/apps/payment/templates/payment/course_payment_success.html new file mode 100644 index 00000000..3edd1879 --- /dev/null +++ b/apps/payment/templates/payment/course_payment_success.html @@ -0,0 +1,12 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} +
+
+
+
Вы успешно приобрели курс!
+ +
+
+
+{% endblock content %} diff --git a/apps/payment/views.py b/apps/payment/views.py index 52ccd274..10392769 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -23,6 +23,20 @@ from .models import AuthorBalance, CoursePayment, SchoolPayment logger = logging.getLogger('django') +@method_decorator(login_required, name='dispatch') +class CourseBuySuccessView(TemplateView): + template_name = 'payment/course_payment_success.html' + + def get(self, request, pk=None, *args, **kwargs): + course = Course.objects.get(id=pk) + return self.render_to_response(context={'course': course}) + + +@method_decorator(login_required, name='dispatch') +class SchoolBuySuccessView(TemplateView): + template_name = 'payment/payment_success.html' + + @method_decorator(login_required, name='dispatch') class CourseBuyView(TemplateView): template_name = 'payment/paymentwall_widget.html' @@ -52,7 +66,7 @@ class CourseBuyView(TemplateView): 'evaluation': 1, 'demo': 1, 'test_mode': 1, - 'success_url': host + str(reverse_lazy('payment-success')), + 'success_url': host + str(reverse_lazy('course_payment_success', args=[course.id])), 'failure_url': host + str(reverse_lazy('payment-error')), } ) diff --git a/project/urls.py b/project/urls.py index bdb2290d..57d948cd 100644 --- a/project/urls.py +++ b/project/urls.py @@ -29,7 +29,11 @@ from apps.user.views import ( UserEditView, NotificationEditView, PaymentHistoryView, resend_email_verify, ) -from apps.payment.views import CourseBuyView, PaymentwallCallbackView, SchoolBuyView +from apps.payment.views import ( + CourseBuySuccessView, CourseBuyView, + PaymentwallCallbackView, SchoolBuySuccessView, + SchoolBuyView, +) from .views import IndexView @@ -52,7 +56,8 @@ urlpatterns = [ path('lesson//comment', lessoncomment, name='lessoncomment'), path('payments/ping', PaymentwallCallbackView.as_view(), name='payment-ping'), path('paymentwall/pingback', PaymentwallCallbackView.as_view(), name='payment-ping-second'), - path('payments/success', TemplateView.as_view(template_name='payment/payment_success.html'), name='payment-success'), + path('payments/course//success', CourseBuySuccessView.as_view(), name='course_payment_success'), + path('payments/school/success', SchoolBuySuccessView.as_view(), name='payment-success'), path('payments/error', TemplateView.as_view(template_name='payment/payment_error.html'), name='payment-error'), path('school/checkout', SchoolBuyView.as_view(), name='school-checkout'), path('search/', SearchView.as_view(), name='search'),