Exemplo n.º 1
0
    def default_value_field(self, **kwargs):
        """Return the default value field for this choice.

        This will call out to :py:meth:`get_queryset` before returning the
        field, allowing subclasses to simply set :py:attr:`queryset` or to
        perform more dynamic queries before constructing the form field.

        Args:
            **kwargs (dict):
                Extra keyword arguments for this function, for future
                expansion.

        Returns:
            djblets.conditions.values.ConditionValueMultipleModelField:
            The form field for the value.
        """
        return ConditionValueModelField(queryset=self.get_queryset)
Exemplo n.º 2
0
    def test_deserialize_value(self):
        """Testing ConditionValueModelField.deserialize_value"""
        field = ConditionValueModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        self.assertEqual(field.deserialize_value(site.pk), site)
Exemplo n.º 3
0
    def test_deserialize_value(self):
        """Testing ConditionValueModelField.deserialize_value"""
        field = ConditionValueModelField(queryset=Site.objects.all())

        site = Site.objects.get_current()
        self.assertEqual(field.deserialize_value(site.pk), site)
Exemplo n.º 4
0
    def test_init_with_callable(self):
        """Testing ConditionValueModelField initialization with callable"""
        field = ConditionValueModelField(queryset=lambda: Site.objects.all())

        self.assertTrue(isinstance(field.field.queryset, QuerySet))