当前位置: 首页>>代码示例>>Python>>正文


Python Coupon.save方法代码示例

本文整理汇总了Python中shoppingcart.models.Coupon.save方法的典型用法代码示例。如果您正苦于以下问题:Python Coupon.save方法的具体用法?Python Coupon.save怎么用?Python Coupon.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shoppingcart.models.Coupon的用法示例。


在下文中一共展示了Coupon.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
def add_coupon(request, course_id):  # pylint: disable=W0613
    """
    add coupon in the Coupons Table
    """
    code = request.POST.get('code')

    # check if the code is already in the Coupons Table and active
    try:
        course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
        coupon = Coupon.objects.get(is_active=True, code=code, course_id=course_id)
    except Coupon.DoesNotExist:
        # check if the coupon code is in the CourseRegistrationCode Table
        course_registration_code = CourseRegistrationCode.objects.filter(code=code)
        if course_registration_code:
            return HttpResponseNotFound(_(
                "The code ({code}) that you have tried to define is already in use as a registration code").format(code=code)
            )

        description = request.POST.get('description')
        course_id = request.POST.get('course_id')
        try:
            discount = int(request.POST.get('discount'))
        except ValueError:
            return HttpResponseNotFound(_("Please Enter the Integer Value for Coupon Discount"))
        if discount > 100 or discount < 0:
            return HttpResponseNotFound(_("Please Enter the Coupon Discount Value Less than or Equal to 100"))
        coupon = Coupon(
            code=code, description=description, course_id=course_id,
            percentage_discount=discount, created_by_id=request.user.id
        )
        coupon.save()
        return HttpResponse(_("coupon with the coupon code ({code}) added successfully").format(code=code))

    if coupon:
        return HttpResponseNotFound(_("coupon with the coupon code ({code}) already exists for this course").format(code=code))
开发者ID:DevCode1,项目名称:edx-platform,代码行数:37,代码来源:coupons.py

示例2: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10, created_by=self.instructor
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse('get_coupon_info', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id) in response.content)

        response = self.client.post(edit_url, {'id': 444444})
        self.assertTrue('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=444444) in response.content)

        response = self.client.post(edit_url, {'id': ''})
        self.assertTrue('coupon id not found"' in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertTrue("coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id) in response.content)
开发者ID:victorchi2009,项目名称:edx-platform,代码行数:27,代码来源:test_ecommerce.py

示例3: test_update_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_update_coupon(self):
        """
        Test Update Coupon Info Scenarios. Handle all the HttpResponses return by update_coupon view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=text_type(self.course.id),
            percentage_discount=10, created_by=self.instructor
        )
        coupon.save()
        response = self.client.post(self.url)
        self.assertIn('<td>AS452</td>', response.content)
        data = {
            'coupon_id': coupon.id, 'code': 'AS452', 'discount': '10', 'description': 'updated_description',
            'course_id': text_type(coupon.course_id)
        }
        # URL for update_coupon
        update_coupon_url = reverse('update_coupon', kwargs={'course_id': text_type(self.course.id)})
        response = self.client.post(update_coupon_url, data=data)
        self.assertIn(
            'coupon with the coupon id ({coupon_id}) updated Successfully'.format(coupon_id=coupon.id),
            response.content
        )

        response = self.client.post(self.url)
        self.assertIn('<td>updated_description</td>', response.content)

        data['coupon_id'] = 1000  # Coupon Not Exist with this ID
        response = self.client.post(update_coupon_url, data=data)
        self.assertIn('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=1000), response.content)

        data['coupon_id'] = ''  # Coupon id is not provided
        response = self.client.post(update_coupon_url, data=data)
        self.assertIn('coupon id not found', response.content)
开发者ID:EDUlib,项目名称:edx-platform,代码行数:35,代码来源:test_ecommerce.py

示例4: test_soft_delete_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_soft_delete_coupon(self):  # pylint: disable=E1101
        self.add_coupon(self.course_key, True)
        coupon = Coupon(code='TestCode', description='testing', course_id=self.course_key,
                        percentage_discount=12, created_by=self.user, is_active=True)
        coupon.save()
        self.assertEquals(coupon.__unicode__(), '[Coupon] code: TestCode course: MITx/999/Robot_Super_Course')
        admin = User.objects.create_user('Mark', '[email protected]', 'foo')
        admin.is_staff = True
        get_coupon = Coupon.objects.get(id=1)
        request = HttpRequest()
        request.user = admin
        setattr(request, 'session', 'session')  # pylint: disable=E1101
        messages = FallbackStorage(request)  # pylint: disable=E1101
        setattr(request, '_messages', messages)  # pylint: disable=E1101
        coupon_admin = SoftDeleteCouponAdmin(Coupon, AdminSite())
        test_query_set = coupon_admin.queryset(request)
        test_actions = coupon_admin.get_actions(request)
        self.assertTrue('really_delete_selected' in test_actions['really_delete_selected'])
        self.assertEqual(get_coupon.is_active, True)
        coupon_admin.really_delete_selected(request, test_query_set)  # pylint: disable=E1101
        for coupon in test_query_set:
            self.assertEqual(coupon.is_active, False)
        coupon_admin.delete_model(request, get_coupon)  # pylint: disable=E1101
        self.assertEqual(get_coupon.is_active, False)

        coupon = Coupon(code='TestCode123', description='testing123', course_id=self.course_key,
                        percentage_discount=22, created_by=self.user, is_active=True)
        coupon.save()
        test_query_set = coupon_admin.queryset(request)
        coupon_admin.really_delete_selected(request, test_query_set)  # pylint: disable=E1101
        for coupon in test_query_set:
            self.assertEqual(coupon.is_active, False)
开发者ID:Appius,项目名称:edx-platform,代码行数:34,代码来源:test_views.py

示例5: add_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
def add_coupon(request, course_id):  # pylint: disable=W0613
    """
    add coupon in the Coupons Table
    """
    code = request.POST.get('code')

    # check if the code is already in the Coupons Table and active
    coupon = Coupon.objects.filter(is_active=True, code=code)

    if coupon:
        return HttpResponseNotFound(_("coupon with the coupon code ({code}) already exist").format(code=code))

    description = request.POST.get('description')
    course_id = request.POST.get('course_id')
    try:
        discount = int(request.POST.get('discount'))
    except ValueError:
        return HttpResponseNotFound(_("Please Enter the Integer Value for Coupon Discount"))
    if discount > 100:
        return HttpResponseNotFound(_("Please Enter the Coupon Discount Value Less than or Equal to 100"))
    coupon = Coupon(
        code=code, description=description, course_id=course_id,
        percentage_discount=discount, created_by_id=request.user.id
    )
    coupon.save()
    return HttpResponse(_("coupon with the coupon code ({code}) added successfully").format(code=code))
开发者ID:AsylumCorp,项目名称:edx-platform,代码行数:28,代码来源:coupons.py

示例6: test_delete_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_delete_coupon(self):
        """
        Test Delete Coupon Scenarios. Handle all the HttpResponses return by remove_coupon view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10, created_by=self.instructor
        )

        coupon.save()

        response = self.client.post(self.url)
        self.assertTrue('<td>AS452</td>' in response.content)

        # URL for remove_coupon
        delete_coupon_url = reverse('remove_coupon', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(delete_coupon_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id) in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(delete_coupon_url, {'id': coupon.id})
        self.assertTrue('coupon with the coupon id ({coupon_id}) is already inactive'.format(coupon_id=coupon.id) in response.content)

        response = self.client.post(delete_coupon_url, {'id': 24454})
        self.assertTrue('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=24454) in response.content)

        response = self.client.post(delete_coupon_url, {'id': ''})
        self.assertTrue('coupon id is None' in response.content)
开发者ID:victorchi2009,项目名称:edx-platform,代码行数:32,代码来源:test_ecommerce.py

示例7: add_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
 def add_coupon(self, course_key, is_active):
     """
     add dummy coupon into models
     """
     coupon = Coupon(code=self.coupon_code, description='testing code', course_id=course_key,
                     percentage_discount=self.percentage_discount, created_by=self.user, is_active=is_active)
     coupon.save()
开发者ID:Appius,项目名称:edx-platform,代码行数:9,代码来源:test_views.py

示例8: add_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
def add_coupon(request, course_id):  # pylint: disable=unused-argument
    """
    add coupon in the Coupons Table
    """
    code = request.POST.get('code')

    # check if the code is already in the Coupons Table and active
    try:
        course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
        coupon = Coupon.objects.get(is_active=True, code=code, course_id=course_id)
    except Coupon.DoesNotExist:
        # check if the coupon code is in the CourseRegistrationCode Table
        course_registration_code = CourseRegistrationCode.objects.filter(code=code)
        if course_registration_code:
            return JsonResponse(
                {'message': _("The code ({code}) that you have tried to define is already in use as a registration code").format(code=code)},
                status=400)  # status code 400: Bad Request

        description = request.POST.get('description')
        course_id = request.POST.get('course_id')
        try:
            discount = int(request.POST.get('discount'))
        except ValueError:
            return JsonResponse({
                'message': _("Please Enter the Integer Value for Coupon Discount")
            }, status=400)  # status code 400: Bad Request

        if discount > 100 or discount < 0:
            return JsonResponse({
                'message': _("Please Enter the Coupon Discount Value Less than or Equal to 100")
            }, status=400)  # status code 400: Bad Request
        expiration_date = None
        if request.POST.get('expiration_date'):
            expiration_date = request.POST.get('expiration_date')
            try:
                expiration_date = datetime.datetime.strptime(expiration_date, "%m/%d/%Y").replace(tzinfo=pytz.UTC) + datetime.timedelta(days=1)
            except ValueError:
                return JsonResponse({
                    'message': _("Please enter the date in this format i-e month/day/year")
                }, status=400)  # status code 400: Bad Request

        coupon = Coupon(
            code=code, description=description,
            course_id=course_id,
            percentage_discount=discount,
            created_by_id=request.user.id,
            expiration_date=expiration_date
        )
        coupon.save()
        return JsonResponse(
            {'message': _("coupon with the coupon code ({code}) added successfully").format(code=code)}
        )

    if coupon:
        return JsonResponse(
            {'message': _("coupon with the coupon code ({code}) already exists for this course").format(code=code)},
            status=400)  # status code 400: Bad Request
开发者ID:189140879,项目名称:edx-platform,代码行数:59,代码来源:coupons.py

示例9: test_update_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_update_coupon(self):
        """
        Test Update Coupon Info Scenarios. Handle all the HttpResponses return by update_coupon view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10, created_by=self.instructor
        )
        coupon.save()
        response = self.client.post(self.url)
        self.assertTrue('<td>AS452</td>' in response.content)
        data = {
            'coupon_id': coupon.id, 'code': 'update_code', 'discount': '12',
            'course_id': coupon.course_id.to_deprecated_string()
        }
        # URL for update_coupon
        update_coupon_url = reverse('update_coupon', kwargs={'course_id': self.course.id.to_deprecated_string()})
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('coupon with the coupon id ({coupon_id}) updated Successfully'.format(coupon_id=coupon.id)in response.content)

        response = self.client.post(self.url)
        self.assertTrue('<td>update_code</td>' in response.content)
        self.assertTrue('<td>12</td>' in response.content)

        data['coupon_id'] = 1000  # Coupon Not Exist with this ID
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=1000) in response.content)

        data['coupon_id'] = coupon.id
        data['discount'] = 123
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('Please Enter the Coupon Discount Value Less than or Equal to 100' in response.content)

        data['discount'] = '25%'
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('Please Enter the Integer Value for Coupon Discount' in response.content)

        data['coupon_id'] = ''  # Coupon id is not provided
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('coupon id not found' in response.content)

        coupon1 = Coupon(
            code='11111', description='coupon', course_id=self.course.id.to_deprecated_string(),
            percentage_discount=20, created_by=self.instructor
        )
        coupon1.save()
        data = {'coupon_id': coupon.id, 'code': '11111', 'discount': '12'}
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue('coupon with the coupon id ({coupon_id}) already exist'.format(coupon_id=coupon.id) in response.content)
开发者ID:AsylumCorp,项目名称:edx-platform,代码行数:51,代码来源:test_ecommerce.py

示例10: test_coupon_codes_features

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_coupon_codes_features(self):
        query_features = [
            'course_id', 'percentage_discount', 'code_redeemed_count', 'description', 'expiration_date',
            'total_discounted_amount', 'total_discounted_seats'
        ]
        for i in range(10):
            coupon = Coupon(
                code='test_code{0}'.format(i),
                description='test_description',
                course_id=self.course.id, percentage_discount='{0}'.format(i),
                created_by=self.instructor,
                is_active=True
            )
            coupon.save()
        #now create coupons with the expiration dates
        for i in range(5):
            coupon = Coupon(
                code='coupon{0}'.format(i), description='test_description', course_id=self.course.id,
                percentage_discount='{0}'.format(i), created_by=self.instructor, is_active=True,
                expiration_date=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2)
            )
            coupon.save()

        active_coupons = Coupon.objects.filter(
            Q(course_id=self.course.id),
            Q(is_active=True),
            Q(expiration_date__gt=datetime.datetime.now(pytz.UTC)) |
            Q(expiration_date__isnull=True)
        )
        active_coupons_list = coupon_codes_features(query_features, active_coupons, self.course.id)
        self.assertEqual(len(active_coupons_list), len(active_coupons))
        for active_coupon in active_coupons_list:
            self.assertEqual(set(active_coupon.keys()), set(query_features))
            self.assertIn(active_coupon['percentage_discount'], [coupon.percentage_discount for coupon in active_coupons])
            self.assertIn(active_coupon['description'], [coupon.description for coupon in active_coupons])
            if active_coupon['expiration_date']:
                self.assertIn(active_coupon['expiration_date'], [coupon.display_expiry_date for coupon in active_coupons])
            self.assertIn(
                active_coupon['course_id'],
                [text_type(coupon.course_id) for coupon in active_coupons]
            )
开发者ID:luisvasq,项目名称:edx-platform,代码行数:43,代码来源:test_basic.py

示例11: test_update_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_update_coupon(self):
        """
        Test Update Coupon Info Scenarios. Handle all the HttpResponses return by update_coupon view
        """
        coupon = Coupon(
            code="AS452",
            description="asdsadsa",
            course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10,
            created_by=self.instructor,
        )
        coupon.save()
        response = self.client.post(self.url)
        self.assertTrue("<td>AS452</td>" in response.content)
        data = {
            "coupon_id": coupon.id,
            "code": "AS452",
            "discount": "10",
            "description": "updated_description",  # pylint: disable=no-member
            "course_id": coupon.course_id.to_deprecated_string(),
        }
        # URL for update_coupon
        update_coupon_url = reverse("update_coupon", kwargs={"course_id": self.course.id.to_deprecated_string()})
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) updated Successfully".format(coupon_id=coupon.id)
            in response.content
        )

        response = self.client.post(self.url)
        self.assertTrue("<td>updated_description</td>" in response.content)

        data["coupon_id"] = 1000  # Coupon Not Exist with this ID
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) DoesNotExist".format(coupon_id=1000) in response.content
        )

        data["coupon_id"] = ""  # Coupon id is not provided
        response = self.client.post(update_coupon_url, data=data)
        self.assertTrue("coupon id not found" in response.content)
开发者ID:dmohrC,项目名称:edx-platform,代码行数:43,代码来源:test_ecommerce.py

示例12: add_coupon

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
def add_coupon(request, course_id):  # pylint: disable=W0613
    """
    add coupon in the Coupons Table
    """
    code = request.POST.get('code')

    # check if the code is already in the Coupons Table and active
    coupon = Coupon.objects.filter(is_active=True, code=code)

    if coupon:
        return HttpResponseNotFound(_("coupon with the coupon code ({code}) already exist").format(code=code))

    description = request.POST.get('description')
    course_id = request.POST.get('course_id')
    discount = request.POST.get('discount')
    coupon = Coupon(
        code=code, description=description, course_id=course_id,
        percentage_discount=discount, created_by_id=request.user.id
    )
    coupon.save()
    return HttpResponse(_("coupon with the coupon code ({code}) added successfully").format(code=code))
开发者ID:AshWilliams,项目名称:edx-platform,代码行数:23,代码来源:coupons.py

示例13: test_coupon_codes_features

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
 def test_coupon_codes_features(self):
     query_features = [
         'course_id', 'percentage_discount', 'code_redeemed_count', 'description'
     ]
     for i in range(10):
         coupon = Coupon(
             code='test_code{0}'.format(i), description='test_description', course_id=self.course.id,
             percentage_discount='{0}'.format(i), created_by=self.instructor, is_active=True
         )
         coupon.save()
     active_coupons = Coupon.objects.filter(course_id=self.course.id, is_active=True)
     active_coupons_list = coupon_codes_features(query_features, active_coupons)
     self.assertEqual(len(active_coupons_list), len(active_coupons))
     for active_coupon in active_coupons_list:
         self.assertEqual(set(active_coupon.keys()), set(query_features))
         self.assertIn(active_coupon['percentage_discount'], [coupon.percentage_discount for coupon in active_coupons])
         self.assertIn(active_coupon['description'], [coupon.description for coupon in active_coupons])
         self.assertIn(
             active_coupon['course_id'],
             [coupon.course_id.to_deprecated_string() for coupon in active_coupons]
         )
开发者ID:adlnet-archive,项目名称:edx-platform,代码行数:23,代码来源:test_basic.py

示例14: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code="AS452",
            description="asdsadsa",
            course_id=self.course.id.to_deprecated_string(),
            percentage_discount=10,
            created_by=self.instructor,
            expiration_date=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2),
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse("get_coupon_info", kwargs={"course_id": self.course.id.to_deprecated_string()})
        response = self.client.post(edit_url, {"id": coupon.id})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) updated successfully".format(coupon_id=coupon.id)
            in response.content
        )
        self.assertIn(coupon.display_expiry_date, response.content)

        response = self.client.post(edit_url, {"id": 444444})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) DoesNotExist".format(coupon_id=444444) in response.content
        )

        response = self.client.post(edit_url, {"id": ""})
        self.assertTrue('coupon id not found"' in response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {"id": coupon.id})
        self.assertTrue(
            "coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id)
            in response.content
        )
开发者ID:dmohrC,项目名称:edx-platform,代码行数:40,代码来源:test_ecommerce.py

示例15: test_get_coupon_info

# 需要导入模块: from shoppingcart.models import Coupon [as 别名]
# 或者: from shoppingcart.models.Coupon import save [as 别名]
    def test_get_coupon_info(self):
        """
        Test Edit Coupon Info Scenarios. Handle all the HttpResponses return by edit_coupon_info view
        """
        coupon = Coupon(
            code='AS452', description='asdsadsa', course_id=text_type(self.course.id),
            percentage_discount=10, created_by=self.instructor,
            expiration_date=datetime.datetime.now(pytz.UTC) + datetime.timedelta(days=2)
        )
        coupon.save()
        # URL for edit_coupon_info
        edit_url = reverse('get_coupon_info', kwargs={'course_id': text_type(self.course.id)})
        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertIn(
            'coupon with the coupon id ({coupon_id}) updated successfully'.format(coupon_id=coupon.id),
            response.content
        )
        self.assertIn(coupon.display_expiry_date, response.content)

        response = self.client.post(edit_url, {'id': 444444})
        self.assertIn(
            'coupon with the coupon id ({coupon_id}) DoesNotExist'.format(coupon_id=444444),
            response.content
        )

        response = self.client.post(edit_url, {'id': ''})
        self.assertIn('coupon id not found"', response.content)

        coupon.is_active = False
        coupon.save()

        response = self.client.post(edit_url, {'id': coupon.id})
        self.assertIn(
            "coupon with the coupon id ({coupon_id}) is already inactive".format(coupon_id=coupon.id),
            response.content
        )
开发者ID:EDUlib,项目名称:edx-platform,代码行数:38,代码来源:test_ecommerce.py


注:本文中的shoppingcart.models.Coupon.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。