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) }
def success_url(self): return reverse("view", kwargs={ 'pk': self.parent.pk, 'model': get_model_name(self.parent) })
def status(obj): try: return render_to_string( "snippets/status/%s.html" % get_model_name(obj), {'obj': obj}) except: return ""
def icon(obj): try: return render_to_string("snippets/icon/%s.html" % get_model_name(obj), {'obj': obj}) except: return ""
def action_url(self): return reverse("inline_create", kwargs={ 'parent_pk': self.parent.id, 'parent_model': get_model_name(self.parent), 'model': self.ctype })
def detail_url(obj): try: obj = obj.detail_proxy except: pass return reverse('view', kwargs={'model': get_model_name(obj), 'pk': obj.id})
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'] })
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}
def delete_action(obj, extra_args=""): return { 'delete_url': "%s%s" % (reverse("delete", kwargs={ 'model': get_model_name(obj), 'pk': obj.id }), extra_args) }
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) }
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) }
def has_obj_perm(user_obj, perm): user, obj = user_obj return user.has_perm("beercat.%s_%s" % (perm, get_model_name(obj)))
def ctname(obj): return get_model_name(obj)