diff --git a/eox_nelp/payment_notifications/admin.py b/eox_nelp/payment_notifications/admin.py index 471e39b5..c4306862 100644 --- a/eox_nelp/payment_notifications/admin.py +++ b/eox_nelp/payment_notifications/admin.py @@ -1,3 +1,6 @@ +""" +... +""" from django.contrib import admin from eox_nelp.payment_notifications.models import PaymentNotification diff --git a/eox_nelp/payment_notifications/context_processor.py b/eox_nelp/payment_notifications/context_processor.py index d909db6b..9e647f2c 100644 --- a/eox_nelp/payment_notifications/context_processor.py +++ b/eox_nelp/payment_notifications/context_processor.py @@ -1,9 +1,11 @@ """ +... """ from eox_nelp.payment_notifications.views import get_payment_notifications_context def payments_notifications_context(request): """ + This function works as a payment notification context """ return get_payment_notifications_context(request) diff --git a/eox_nelp/payment_notifications/models.py b/eox_nelp/payment_notifications/models.py index 969d99ee..36c6dc74 100644 --- a/eox_nelp/payment_notifications/models.py +++ b/eox_nelp/payment_notifications/models.py @@ -43,18 +43,48 @@ class PaymentNotification(models.Model): show_msg_case1 = models.BooleanField(null=True, blank=True, help_text="Will show the case 1 msg to the user") show_msg_case2 = models.BooleanField(null=True, blank=True, help_text="Will show the case 2 msg to the user") - show_trans_info = models.BooleanField(null=True, blank=True, help_text="Will show the transaction details to the user") + show_trans_info = models.BooleanField( + null=True, + blank=True, + help_text="Will show the transaction details to the user", + ) show_msg_custom = models.BooleanField(null=True, blank=True, help_text="Will show the following html to the user") - custom_msg = models.TextField(null=True, blank=True, help_text='Use a "lang-ar" or "lang-en" class to select language') - - call_to_action_1_msg = models.CharField(max_length=1000, null=True, blank=True, help_text="Name of the button for case 1") - call_to_action_2_msg = models.CharField(max_length=1000, null=True, blank=True, help_text="Name of the button for case 2") - call_to_action_3_msg = models.CharField(max_length=1000, null=True, blank=True, help_text="Name of the button at the end of the message") - - call_to_action_1_url = models.CharField(max_length=1000, null=True, blank=True, help_text="Link of the button for case 1") - call_to_action_2_url = models.CharField(max_length=1000, null=True, blank=True, help_text="Link of the button for case 2") - call_to_action_3_url = models.CharField(max_length=1000, null=True, blank=True, help_text="Link of the button at the end of the message") + custom_msg = models.TextField( + null=True, + blank=True, + help_text='Use a "lang-ar" or "lang-en" class to select language') + + call_to_action_1_msg = models.CharField( + max_length=1000, + null=True, + blank=True, + help_text="Name of the button for case 1") + call_to_action_2_msg = models.CharField( + max_length=1000, + null=True, blank=True, + help_text="Name of the button for case 2") + call_to_action_3_msg = models.CharField( + max_length=1000, + null=True, + blank=True, + help_text="Name of the button at the end of the message") + + call_to_action_1_url = models.CharField( + max_length=1000, + null=True, + blank=True, + help_text="Link of the button for case 1") + call_to_action_2_url = models.CharField( + max_length=1000, + null=True, + blank=True, + help_text="Link of the button for case 2") + call_to_action_3_url = models.CharField( + max_length=1000, + null=True, + blank=True, + help_text="Link of the button at the end of the message") redirect_from_dashboard = models.BooleanField(null=True, blank=True, help_text="Not ready") redirect_from_course = models.BooleanField(null=True, blank=True, help_text="Not ready") diff --git a/eox_nelp/payment_notifications/views.py b/eox_nelp/payment_notifications/views.py index ca579be4..772927ec 100644 --- a/eox_nelp/payment_notifications/views.py +++ b/eox_nelp/payment_notifications/views.py @@ -7,8 +7,8 @@ from django.utils.decorators import method_decorator from django.views import View +from eox_nelp.edxapp_wrapper.edxmako import edxmako from eox_nelp.payment_notifications.models import PaymentNotification -from eox_nelp.templates_config import render_to_response @method_decorator(login_required, name='dispatch') @@ -17,12 +17,29 @@ class PaymentNotificationsView(View): Display a PaymentNotification for users that navigate to /payment-notifications """ - def get(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): # pylint: disable=unused-argument + """ + Checks whether payment notifications are enabled in the system configuration + before displaying the payment notifications page. If payment notifications + are not enabled, it raises an Http404 response. + + Args: + request (HttpRequest): The incoming HTTP request. + *args: Additional positional arguments. + **kwargs: Additional keyword arguments. + + Returns: + HttpResponse: An HTTP response that renders the "payment_notifications_with_frame.html" + template within the current context. + + Raises: + Http404: If payment notifications are not enabled in the configuration. + """ if not getattr(settings, "ENABLE_PAYMENT_NOTIFICATIONS", None): raise Http404 - return render_to_response("payment_notifications_with_frame.html", {}) + return edxmako.shortcuts.render_to_response("payment_notifications_with_frame.html", {}, "main", request) def get_payment_notifications_context(request): @@ -55,7 +72,7 @@ def get_payment_notifications_context(request): user_id = request.GET.get("showpaymentnotificationsforuser", user_id) count_view = False - all_notifications_for_user = PaymentNotification.objects.filter(cdtrans_lms_user_id=user_id) + all_notifications_for_user = PaymentNotification.objects.filter(cdtrans_lms_user_id=user_id) # pylint: disable=no-member if count_view: for notification in all_notifications_for_user: diff --git a/eox_nelp/settings/common.py b/eox_nelp/settings/common.py index 90207c44..6726919e 100644 --- a/eox_nelp/settings/common.py +++ b/eox_nelp/settings/common.py @@ -60,9 +60,9 @@ def plugin_settings(settings): if find_spec('eox_audit_model') and EOX_AUDIT_MODEL_APP not in settings.INSTALLED_APPS: settings.INSTALLED_APPS.append(EOX_AUDIT_MODEL_APP) - try: - payments_notifications_context = 'eox_nelp.payment_notifications.context_processor.payments_notifications_context' + payments_notifications_context = 'eox_nelp.payment_notifications.context_processor.payments_notifications_context' # pylint: disable=line-too-long + if payments_notifications_context not in settings.TEMPLATES[0]['OPTIONS']['context_processors']: settings.TEMPLATES[0]['OPTIONS']['context_processors'].append(payments_notifications_context) if payments_notifications_context not in settings.TEMPLATES[1]['OPTIONS']['context_processors']: @@ -72,4 +72,3 @@ def plugin_settings(settings): except AttributeError: # We must find a way to register this error pass - diff --git a/eox_nelp/signals/receivers.py b/eox_nelp/signals/receivers.py index 45319364..1862cc08 100644 --- a/eox_nelp/signals/receivers.py +++ b/eox_nelp/signals/receivers.py @@ -188,7 +188,7 @@ def enrollment_publisher(instance, **kwargs): # pylint: disable=unused-argument ) -def update_payment_notifications(instance, **kwargs): +def update_payment_notifications(instance, **kwargs): # pylint: disable=unused-argument """This update the internal status of a payment notification record, if the enrollment is active an have the no-id-professional mode this will set the internal status as resolution_by_case_1 @@ -199,7 +199,7 @@ def update_payment_notifications(instance, **kwargs): user = instance.user course_key = instance.course_id - payment_notifications = PaymentNotification.objects.filter( + payment_notifications = PaymentNotification.objects.filter( # pylint: disable=no-member cdtrans_lms_user_id=user.id, cdtrans_course_id=str(course_key), internal_status="case_1", diff --git a/eox_nelp/templates_config.py b/eox_nelp/templates_config.py deleted file mode 100644 index e69de29b..00000000