Example #1
0
 def test_get_enterprise_customer_uuid_non_existing_conditional_offer(self):
     """
     Verify that None is returned if voucher exists but conditional offer
     does not exist.
     """
     voucher = VoucherFactory()
     self.assertIsNone(get_enterprise_customer_uuid(voucher.code))
    def _get_reply_to_email(site, nudge_email):
        """
        Returns the reply_to email address of an Enterprise Customer.

        Arguments:
            nudge_email (CodeAssignmentNudgeEmails): A nudge email sent to the learner.
        """
        enterprise_customer_uuid = get_enterprise_customer_uuid(nudge_email.code)
        return get_enterprise_customer_reply_to_email(site, enterprise_customer_uuid)
    def _get_sender_alias(site, nudge_email):
        """
        Returns the sender alias of an Enterprise Customer.

        Arguments:
            nudge_email (CodeAssignmentNudgeEmails): A nudge email sent to the learner.
        """
        enterprise_customer_uuid = get_enterprise_customer_uuid(nudge_email.code)
        return get_enterprise_customer_sender_alias(site, enterprise_customer_uuid)
Example #4
0
    def test_get_enterprise_customer_uuid(self):
        """
        Verify that enterprise customer UUID is returned for a voucher with an associated enterprise customer.
        """
        enterprise_customer_uuid = uuid.uuid4()
        voucher, __ = prepare_voucher(enterprise_customer=enterprise_customer_uuid)

        self.assertEqual(
            enterprise_customer_uuid,
            get_enterprise_customer_uuid(voucher.code),
        )
Example #5
0
    def _decorated(request, *args, **kwargs):
        code, enterprise_customer_uuid = request.GET.get('code'), None
        if code:
            enterprise_customer_uuid = utils.get_enterprise_customer_uuid(code)

        response = func(request, *args, **kwargs)

        # Set enterprise customer cookie if enterprise customer uuid is available.
        if enterprise_customer_uuid:
            response = utils.set_enterprise_customer_cookie(request.site, response, enterprise_customer_uuid)

        return response
 def _create_email_sent_record(site, nudge_email):
     """
     Creates an instance of OfferAssignmentEmailSentRecord with the given data.
     Arguments:
         nudge_email (CodeAssignmentNudgeEmails): A nudge email sent to the learner.
     """
     OfferAssignmentEmailSentRecord.create_email_record(
         enterprise_customer_uuid=get_enterprise_customer_uuid(nudge_email.code),
         email_type=nudge_email.email_template.email_type,
         template=nudge_email.email_template,
         sender_category=AUTOMATIC_EMAIL,
         code=nudge_email.code,
         user_email=nudge_email.user_email,
         receiver_id=User.get_lms_user_attribute_using_email(site, nudge_email.user_email)
     )
Example #7
0
    def _decorated(request, *args, **kwargs):
        response = func(request, *args, **kwargs)

        # Set enterprise customer cookie if enterprise customer uuid is available.
        # The max_age of the cookie is set to a relatively short 60 seconds to
        # maintain the Enterprise context across jumps over to other Open edX
        # services, e.g. LMS, but also to ensure that the Enterprise context
        # does not linger longer than it should.
        code, enterprise_customer_uuid = request.GET.get('code'), None
        if code:
            enterprise_customer_uuid = utils.get_enterprise_customer_uuid(code)
            if enterprise_customer_uuid:
                response = utils.set_enterprise_customer_cookie(
                    request.site,
                    response,
                    enterprise_customer_uuid,
                    max_age=60)

        return response
Example #8
0
 def test_get_enterprise_customer_uuid_non_existing_voucher(self):
     """
     Verify that None is returned when voucher with given code does not exist.
     """
     voucher = VoucherFactory()
     self.assertIsNone(get_enterprise_customer_uuid(voucher.code))