當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。