Skip to content

Commit

Permalink
fix: error outputs when testing fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ever3tt committed Oct 2, 2023
1 parent a72ddb0 commit cc6c40c
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 19 deletions.
3 changes: 3 additions & 0 deletions eox_nelp/payment_notifications/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
...
"""
from django.contrib import admin

from eox_nelp.payment_notifications.models import PaymentNotification
Expand Down
2 changes: 2 additions & 0 deletions eox_nelp/payment_notifications/context_processor.py
Original file line number Diff line number Diff line change
@@ -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)
50 changes: 40 additions & 10 deletions eox_nelp/payment_notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
25 changes: 21 additions & 4 deletions eox_nelp/payment_notifications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions eox_nelp/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand All @@ -72,4 +72,3 @@ def plugin_settings(settings):
except AttributeError:
# We must find a way to register this error
pass

4 changes: 2 additions & 2 deletions eox_nelp/signals/receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
Empty file removed eox_nelp/templates_config.py
Empty file.

0 comments on commit cc6c40c

Please sign in to comment.