예제 #1
0
    def render(self, obj):
        if self.attr == 'self':
            if not self.link:
                return obj.get_absolute_url()
            else:
                assert self.link
                if self.args:
                    p_args = [
                        helper.deep_getattribute(obj, arg) for arg in self.args
                    ]
                else:
                    p_args = None
                return reverse(self.link, args=p_args)

        if not self.link:
            return helper.deep_getattribute(obj, self.attr).get_absolute_url()

        assert self.link
        ref = helper.deep_getattribute(obj, self.attr)

        if self.args:
            p_args = [helper.deep_getattribute(ref, arg) for arg in self.args]
        else:
            p_args = None

        return '<a href=%s>%s</a>' % (reverse(self.link,
                                              args=p_args), self.text)
예제 #2
0
    def decorator(func):
        util_function = helper.deep_getattribute(django_utils, django_utils_function)
        if isinstance(util_function, helper.Nothing):
            raise Exception('Function {} not exist on django.utils module.'.format(django_utils_function))

        @wraps(func)
        def wrapper(*args, **kwargs):
            return util_function(func(*args, **kwargs))

        return wrapper
예제 #3
0
    def decorator(func):
        util_function = helper.deep_getattribute(django_utils,
                                                 django_utils_function)
        if isinstance(util_function, helper.Nothing):
            raise Exception(
                'Function {} not exist on django.utils module.'.format(
                    django_utils_function))

        @wraps(func)
        def wrapper(*args, **kwargs):
            return util_function(func(*args, **kwargs))

        return wrapper
예제 #4
0
    def render(self, obj):
        if self.attr == 'self':
            if not self.link:
                return obj.get_absolute_url()
            else:
                assert self.link
                if self.args:
                    p_args = [helper.deep_getattribute(obj, arg) for arg in self.args]
                else:
                    p_args = None
                return reverse(self.link, args=p_args)

        if not self.link:
            return helper.deep_getattribute(obj, self.attr).get_absolute_url()

        assert self.link
        ref = helper.deep_getattribute(obj, self.attr)

        if self.args:
            p_args = [helper.deep_getattribute(ref, arg) for arg in self.args]
        else:
            p_args = None

        return '<a href=%s>%s</a>' % (reverse(self.link, args=p_args), self.text)