Пример #1
0
def inline_edit_action(obj, parent, extra_args=""):

    return {
        'edit_url':
        "%s%s" % (reverse("inline_edit",
                          kwargs={
                              'parent_pk': parent.id,
                              'parent_model': get_model_name(parent),
                              'pk': obj.id,
                              'model': get_model_name(obj)
                          }), extra_args)
    }
Пример #2
0
    def success_url(self):

        return reverse("view",
                       kwargs={
                           'pk': self.parent.pk,
                           'model': get_model_name(self.parent)
                       })
Пример #3
0
def status(obj):

    try:
        return render_to_string(
            "snippets/status/%s.html" % get_model_name(obj), {'obj': obj})
    except:
        return ""
Пример #4
0
def icon(obj):

    try:
        return render_to_string("snippets/icon/%s.html" % get_model_name(obj),
                                {'obj': obj})
    except:
        return ""
Пример #5
0
    def action_url(self):

        return reverse("inline_create",
                       kwargs={
                           'parent_pk': self.parent.id,
                           'parent_model': get_model_name(self.parent),
                           'model': self.ctype
                       })
Пример #6
0
def detail_url(obj):

    try:
        obj = obj.detail_proxy
    except:
        pass

    return reverse('view', kwargs={'model': get_model_name(obj), 'pk': obj.id})
Пример #7
0
    def action_url(self):

        return reverse("inline_edit",
                       kwargs={
                           'parent_pk': self.parent.id,
                           'parent_model': get_model_name(self.parent),
                           'model': self.ctype,
                           'pk': self.kwargs['pk']
                       })
Пример #8
0
def edit_action(obj):

    model_name = get_model_name(obj)

    try:
        _url = reverse("edit_%s" % model_name, kwargs={'pk': obj.id})
    except NoReverseMatch:
        _url = reverse("edit", kwargs={'model': model_name, 'pk': obj.id})
    return {'edit_url': _url}
Пример #9
0
def delete_action(obj, extra_args=""):

    return {
        'delete_url':
        "%s%s" %
        (reverse("delete", kwargs={
            'model': get_model_name(obj),
            'pk': obj.id
        }), extra_args)
    }
Пример #10
0
def inline_add_action(model_name, parent, extra_args=""):

    return {
        'create_url':
        "%s%s" % (reverse("inline_create",
                          kwargs={
                              'parent_pk': parent.id,
                              'parent_model': get_model_name(parent),
                              'model': model_name
                          }), extra_args)
    }
Пример #11
0
def merge_action(obj, extra_args=""):

    return {
        'merge_url':
        "%s%s" % (reverse("inline_create",
                          kwargs={
                              'parent_pk': obj.id,
                              'parent_model': get_model_name(obj),
                              'model': 'brewerymerge'
                          }), extra_args)
    }
Пример #12
0
def has_obj_perm(user_obj, perm):

    user, obj = user_obj

    return user.has_perm("beercat.%s_%s" % (perm, get_model_name(obj)))
Пример #13
0
def ctname(obj):

    return get_model_name(obj)