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


Python constants.SUCCESS属性代码示例

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


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

示例1: test_email_send_error

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def test_email_send_error(self, mock_fn):
        logging.disable(logging.CRITICAL)
        # Approve
        self.silent_submit()
        response = self.approve()
        logging.disable(logging.NOTSET)

        # An email that fails to send should return a message rather than crash the page
        self.assertEqual(response.status_code, 302)
        response = self.client.get(reverse('wagtailadmin_home'))

        # There should be one "approved" message and one "failed to send notifications"
        messages = list(response.context['messages'])
        self.assertEqual(len(messages), 2)
        self.assertEqual(messages[0].level, message_constants.SUCCESS)
        self.assertEqual(messages[1].level, message_constants.ERROR) 
开发者ID:wagtail,项目名称:wagtail,代码行数:18,代码来源:test_moderation.py

示例2: test_create_refund

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def test_create_refund(self):
        """Verify the view creates a Refund for the Order and selected Lines."""
        # Create Order and Lines
        order = self.create_order(user=self.user)
        self.assertFalse(order.refunds.exists())

        # Validate the Refund
        response = self._request_refund(order)
        refund = Refund.objects.latest()
        self.assert_refund_matches_order(refund, order)

        # Verify a message was passed for display
        data = {
            'link_start': '<a href="{}" target="_blank">'.format(
                reverse('dashboard:refunds-detail', kwargs={'pk': refund.pk})),
            'link_end': '</a>',
            'refund_id': refund.pk
        }
        expected = '{link_start}Refund #{refund_id}{link_end} created! ' \
                   'Click {link_start}here{link_end} to view it.'.format(**data)

        self.assert_message_equals(response, expected, MSG.SUCCESS) 
开发者ID:edx,项目名称:ecommerce,代码行数:24,代码来源:tests.py

示例3: success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success(request, message, extra_tags='', fail_silently=False):
    """
    Adds a message with the ``SUCCESS`` level.
    """
    add_message(request, constants.SUCCESS, message, extra_tags=extra_tags,
                fail_silently=fail_silently) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:api.py

示例4: success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success(request, message, extra_tags='', fail_silently=False):
    """Add a message with the ``SUCCESS`` level."""
    add_message(request, constants.SUCCESS, message, extra_tags=extra_tags,
                fail_silently=fail_silently) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:6,代码来源:api.py

示例5: test_post_enroll_no_course_detail

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def test_post_enroll_no_course_detail(
            self,
            forms_client,
            views_client,
            course_catalog_client,
            track_enrollment,
    ):
        catalog_instance = course_catalog_client.return_value
        catalog_instance.get_course_run.return_value = {}
        views_instance = views_client.return_value
        views_instance.enroll_user_in_course.side_effect = fake_enrollment_api.enroll_user_in_course
        forms_instance = forms_client.return_value
        forms_instance.get_course_details.side_effect = fake_enrollment_api.get_course_details

        user = UserFactory(id=2)
        course_id = "course-v1:HarvardX+CoolScience+2016"
        mode = "verified"
        response = self._enroll_user_request(user, mode, course_id=course_id)
        views_instance.enroll_user_in_course.assert_called_once_with(
            user.username,
            course_id,
            mode,
        )
        track_enrollment.assert_called_once_with('admin-enrollment', user.id, course_id)
        self._assert_django_messages(response, set([
            (messages.SUCCESS, "1 learner was enrolled in {}.".format(course_id)),
        ]))
        all_enterprise_enrollments = EnterpriseCourseEnrollment.objects.all()
        num_enterprise_enrollments = len(all_enterprise_enrollments)
        assert num_enterprise_enrollments == 1
        enrollment = all_enterprise_enrollments[0]
        assert enrollment.enterprise_customer_user.user == user
        assert enrollment.course_id == course_id
        num_messages = len(mail.outbox)
        assert num_messages == 0 
开发者ID:edx,项目名称:edx-enterprise,代码行数:37,代码来源:test_view.py

示例6: test_post_link_and_enroll_no_notification

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def test_post_link_and_enroll_no_notification(
            self,
            forms_client,
            views_client,
            track_enrollment,
    ):
        """
        Test bulk upload with linking and enrolling
        """
        views_instance = views_client.return_value
        views_instance.enroll_user_in_course.side_effect = fake_enrollment_api.enroll_user_in_course
        forms_instance = forms_client.return_value
        forms_instance.get_course_details.side_effect = fake_enrollment_api.get_course_details
        self._login()
        user = UserFactory.create()
        unknown_email = FAKER.email()  # pylint: disable=no-member
        columns = [ManageLearnersForm.CsvColumns.EMAIL]
        data = [(user.email,), (unknown_email,)]
        course_id = "course-v1:EnterpriseX+Training+2017"
        course_mode = "professional"

        response = self._perform_request(columns, data, course=course_id, course_mode=course_mode, notify=False)

        views_instance.enroll_user_in_course.assert_called_once_with(
            user.username,
            course_id,
            course_mode
        )
        track_enrollment.assert_called_once_with('admin-enrollment', user.id, course_id)
        pending_user_message = (
            "The following learners do not have an account on Test platform. They have not been enrolled in {}. "
            "When these learners create an account, they will be enrolled automatically: {}"
        )
        self._assert_django_messages(response, set([
            (messages.SUCCESS, "2 new learners were added to {}.".format(self.enterprise_customer.name)),
            (messages.SUCCESS, "1 learner was enrolled in {}.".format(course_id)),
            (messages.WARNING, pending_user_message.format(course_id, unknown_email)),
        ]))
        assert PendingEnterpriseCustomerUser.objects.all()[0].pendingenrollment_set.all()[0].course_id == course_id
        num_messages = len(mail.outbox)
        assert num_messages == 0 
开发者ID:edx,项目名称:edx-enterprise,代码行数:43,代码来源:test_view.py

示例7: message_icon

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def message_icon(msg):
    """
        Returns the string class name of a message icon
        which feeds directly into Patternfly.
    """
    icons = {
        messages.ERROR: 'error-circle-o',
        messages.WARNING: 'warning-triangle-o',
        messages.SUCCESS: 'ok',
        messages.INFO: 'info',
    }
    return 'pficon-' + icons[msg.level] 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:14,代码来源:extra_filters.py

示例8: test_success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def test_success(self):
        messages.success(self.user, "Hello")
        self.assertMessageOk(constants.SUCCESS) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:5,代码来源:tests.py

示例9: success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success(user, message):
    """
    Adds a message with the ``SUCCESS`` level.

    :param user: User instance
    :param message: Message to show
    """
    message_user(user, message, constants.SUCCESS) 
开发者ID:Inboxen,项目名称:Inboxen,代码行数:10,代码来源:messages.py

示例10: add_level_messages

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def add_level_messages(storage):
    """
    Add 6 messages from different levels (including a custom one) to a storage
    instance.
    """
    storage.add(constants.INFO, 'A generic info message')
    storage.add(29, 'Some custom level')
    storage.add(constants.DEBUG, 'A debugging message', extra_tags='extra-tag')
    storage.add(constants.WARNING, 'A warning')
    storage.add(constants.ERROR, 'An error')
    storage.add(constants.SUCCESS, 'This was a triumph.') 
开发者ID:nesdis,项目名称:djongo,代码行数:13,代码来源:base.py

示例11: __init__

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def __init__(self, msg=None, level=constants.SUCCESS):
        if msg:
            self.add_message(level, msg) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:5,代码来源:utils.py

示例12: success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success(self, msg):
        self.add_message(constants.SUCCESS, msg) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:4,代码来源:utils.py

示例13: success

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success(request, message, extra_tags='', fail_silently=False):
    """Adds a message with the ``SUCCESS`` level."""
    add_message(request, constants.SUCCESS, message, extra_tags=extra_tags,
                fail_silently=fail_silently) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:6,代码来源:messages.py

示例14: level_to_bootstrap

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def level_to_bootstrap(message):
    map = {
        constants.DEBUG: 'alert-info',
        constants.INFO: 'alert-info',
        constants.SUCCESS: 'alert-success',
        constants.WARNING: 'alert-warning',
        constants.ERROR: 'alert-danger',
    }
    return map.get(message.level, 'alert-info') 
开发者ID:CroceRossaItaliana,项目名称:jorvik,代码行数:11,代码来源:base_tags.py

示例15: success_render_to_response

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import SUCCESS [as 别名]
def success_render_to_response(self, obj, msg, msg_level):
        msg_level = msg_level or constants.SUCCESS
        msg = msg or self.get_message(msg_level, obj)
        if self.is_popup_form:
            return JsonHttpResponse({'messages': {msg_level: msg}, 'obj': self.get_popup_obj(obj)})
        elif self.is_ajax_form:
            add_message(self.request, msg_level, msg)
            location = self.get_success_url(obj)
            response = JsonHttpResponse({'location': location}, status=202)
            response['Location'] = location
            return response
        else:
            add_message(self.request, msg_level, msg)
            return HttpResponseRedirect(self.get_success_url(obj)) 
开发者ID:matllubos,项目名称:django-is-core,代码行数:16,代码来源:form_views.py


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