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


Python constants.WARNING属性代码示例

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


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

示例1: test_add_selected_to_grouping

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_add_selected_to_grouping(self):
        data = {
            'grouping': self.fake_grouping.id,
            'add': True,
            'isSelectAll': 'False',
            'selected-target': [self.fake_targets[0].id, self.fake_targets[1].id],
            'query_string': '',
        }
        response = self.client.post(reverse('targets:add-remove-grouping'), data=data)

        self.assertEqual(self.fake_grouping.targets.count(), 2)
        self.assertTrue(self.fake_targets[0] in self.fake_grouping.targets.all())
        self.assertTrue(self.fake_targets[1] in self.fake_grouping.targets.all())

        messages = [(m.message, m.level) for m in get_messages(response.wsgi_request)]
        self.assertIn(('1 target(s) successfully added to group \'{}\'.'.format(self.fake_grouping.name),
                       SUCCESS), messages)
        self.assertIn(('1 target(s) already in group \'{}\': {}'.format(
            self.fake_grouping.name, self.fake_targets[0].name), WARNING), messages) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:21,代码来源:tests.py

示例2: test_add_all_to_grouping_filtered_by_sidereal

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_add_all_to_grouping_filtered_by_sidereal(self):
        data = {
            'grouping': self.fake_grouping.id,
            'add': True,
            'isSelectAll': 'True',
            'selected-target': [],
            'query_string': 'type=SIDEREAL&name=&key=&value=&targetlist__name=',
        }
        response = self.client.post(reverse('targets:add-remove-grouping'), data=data)
        self.assertEqual(self.fake_grouping.targets.count(), 3)
        messages = [(m.message, m.level) for m in get_messages(response.wsgi_request)]
        self.assertIn(('2 target(s) successfully added to group \'{}\'.'.format(self.fake_grouping.name),
                       SUCCESS), messages)
        self.assertIn((
            '1 target(s) already in group \'{}\': {}'.format(self.fake_grouping.name, self.fake_targets[0].name),
            WARNING), messages
        ) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:19,代码来源:tests.py

示例3: test_remove_all_from_grouping_filtered_by_sidereal

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_remove_all_from_grouping_filtered_by_sidereal(self):
        data = {
            'grouping': self.fake_grouping.id,
            'remove': True,
            'isSelectAll': 'True',
            'selected-target': [],
            'query_string': 'type=SIDEREAL&name=&key=&value=&targetlist__name=',
        }
        response = self.client.post(reverse('targets:add-remove-grouping'), data=data)
        self.assertEqual(self.fake_grouping.targets.count(), 0)
        messages = [(m.message, m.level) for m in get_messages(response.wsgi_request)]
        self.assertIn(('1 target(s) successfully removed from group \'{}\'.'.format(self.fake_grouping.name),
                       SUCCESS), messages)
        self.assertIn(('2 target(s) not in group \'{}\': {}'.format(
            self.fake_grouping.name, self.fake_targets[1].name + ', ' + self.fake_targets[2].name
        ), WARNING), messages) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:18,代码来源:tests.py

示例4: warning

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

示例5: warning

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

示例6: test_remove_selected_from_grouping

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_remove_selected_from_grouping(self):
        data = {
            'grouping': self.fake_grouping.id,
            'remove': True,
            'isSelectAll': 'False',
            'selected-target': [self.fake_targets[0].id, self.fake_targets[1].id],
            'query_string': '',
        }
        response = self.client.post(reverse('targets:add-remove-grouping'), data=data)
        self.assertEqual(self.fake_grouping.targets.count(), 0)
        messages = [(m.message, m.level) for m in get_messages(response.wsgi_request)]
        self.assertIn(('1 target(s) successfully removed from group \'{}\'.'.format(self.fake_grouping.name),
                       SUCCESS), messages)
        self.assertIn(('1 target(s) not in group \'{}\': {}'.format(self.fake_grouping.name, self.fake_targets[1].name),
                       WARNING), messages) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:17,代码来源:tests.py

示例7: test_add_remove_from_grouping_empty_query_string

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_add_remove_from_grouping_empty_query_string(self):
        data = {
            'grouping': self.fake_grouping.id,
            'remove': True,
            'isSelectAll': 'True',
            'selected-target': [],
        }
        response = self.client.post(reverse('targets:add-remove-grouping'), data=data)
        self.assertEqual(self.fake_grouping.targets.count(), 0)
        messages = [(m.message, m.level) for m in get_messages(response.wsgi_request)]
        self.assertIn(('1 target(s) successfully removed from group \'{}\'.'.format(self.fake_grouping.name),
                       SUCCESS), messages)
        self.assertIn(('2 target(s) not in group \'{}\': {}'.format(
            self.fake_grouping.name, self.fake_targets[1].name + ', ' + self.fake_targets[2].name
        ), WARNING), messages) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:17,代码来源:tests.py

示例8: test_post_existing_pending_record_with_another_enterprise_customer

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [as 别名]
def test_post_existing_pending_record_with_another_enterprise_customer(self):
        """
        Tests that a PendingEnterpriseCustomerUser already linked with an Enterprise cannot be linked with another
        Enterprise and a warning message is created in response
        """
        # precondition checks:
        self._login()
        email = FAKER.email()  # pylint: disable=no-member
        another_ent = EnterpriseCustomerFactory()
        PendingEnterpriseCustomerUserFactory(enterprise_customer=another_ent, user_email=email)
        # Confirm that only one instance exists before post request
        assert PendingEnterpriseCustomerUser.objects.filter(user_email=email).count() == 1

        response = self.client.post(
            self.view_url,
            data=self.add_required_data({ManageLearnersForm.Fields.EMAIL_OR_USERNAME: email})
        )
        pending_user_message = (
            "Pending user with email address {user_email} is already linked with another Enterprise {ec_name}, "
            "you will be able to add the learner once the user creates account or other enterprise "
            "deletes the pending user"
        )
        self._assert_django_messages(response, {
            (messages.WARNING, pending_user_message.format(ec_name=another_ent.name, user_email=email)),
        })
        self._test_post_existing_record_response(response)
        assert PendingEnterpriseCustomerUser.objects.filter(user_email=email).count() == 1 
开发者ID:edx,项目名称:edx-enterprise,代码行数:29,代码来源:test_view.py

示例9: test_post_link_and_enroll_no_notification

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [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

示例10: message_icon

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [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

示例11: test_warning

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

示例12: warning

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

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

示例13: add_level_messages

# 需要导入模块: from django.contrib.messages import constants [as 别名]
# 或者: from django.contrib.messages.constants import WARNING [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

示例14: warning

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

示例15: warning

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


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