Example #1
0
File: sites.py Project: whit/ella
    def root_contenttype(self, request, contenttype, *url_parts):
        """
        prepare redirect to admin_list view, objects change_view,
        other special views (delete, history, ..) and hook our own views
        """
        get_params = request.GET and '?%s' % request.GET.urlencode() or ''
        changelist_view = '../../%s/%s' % (
            contenttype.app_label,
            contenttype.model,
        )

        if not len(url_parts):
            # redirect to admin changelist list for this contet type
            redir = '%s/%s' % (changelist_view, get_params)
            return http.HttpResponseRedirect(redir)

        if not url_parts[0].isdigit:
            # we don't handle actions on content type itself
            raise http.Http404

        if len(url_parts) == 1:
            # redirect to admin change view for specific object
            redir = '../%s/%s/%s' % (changelist_view, url_parts[0], get_params)
            return http.HttpResponseRedirect(redir)

        if len(url_parts) == 2 and url_parts[1] == 'info':
            # object_detail for some ajax raw_id widget
            mimetype = 'text/html' or 'application/json'  # ?:)
            obj = get_cached_object_or_404(contenttype, pk=url_parts[0])
            response = {
                'name': str(obj),
                'content_type_name': contenttype.name,
                'content_type': contenttype.model,
                'url': getattr(obj, 'get_absolute_url', lambda: None)(),
                'admin_url': admin_url(obj),
            }
            return http.HttpResponse(simplejson.dumps(response, indent=2),
                                     mimetype=mimetype)

        if len(url_parts) == 2:
            # some action on specific object (delete, history, ..)
            redir = '../../%s/%s/%s/%s' % (changelist_view, url_parts[0],
                                           url_parts[1], get_params)
            return http.HttpResponseRedirect(redir)

        raise http.Http404
Example #2
0
File: sites.py Project: Almad/ella
    def root_contenttype(self, request, contenttype, *url_parts):
        """
        prepare redirect to admin_list view, objects change_view,
        other special views (delete, history, ..) and hook our own views
        """
        get_params = request.GET and '?%s' % request.GET.urlencode() or ''
        changelist_view = '../../%s/%s' % (contenttype.app_label, contenttype.model,)

        if not len(url_parts):
            # redirect to admin changelist list for this contet type
            redir = '%s/%s' % (changelist_view, get_params)
            return http.HttpResponseRedirect(redir)

        if not url_parts[0].isdigit:
            # we don't handle actions on content type itself
            raise http.Http404

        if len(url_parts) == 1:
            # redirect to admin change view for specific object
            redir = '../%s/%s/%s' % (changelist_view, url_parts[0], get_params)
            return http.HttpResponseRedirect(redir)

        if len(url_parts) == 2 and url_parts[1] == 'info':
            # object_detail for some ajax raw_id widget
            mimetype = 'text/html' or 'application/json' # ?:)
            obj = get_cached_object_or_404(contenttype, pk=url_parts[0])
            response = {
                'name': str(obj),
                'content_type_name': contenttype.name,
                'content_type': contenttype.model,
                'url': getattr(obj, 'get_absolute_url', lambda:None)(),
                'admin_url': admin_url(obj),
}
            return http.HttpResponse(simplejson.dumps(response, indent=2), mimetype=mimetype)

        if len(url_parts) == 2:
            # some action on specific object (delete, history, ..)
            redir = '../../%s/%s/%s/%s' % (changelist_view, url_parts[0], url_parts[1], get_params)
            return http.HttpResponseRedirect(redir)

        raise http.Http404
Example #3
0
 def get_admin_url(self):
     return admin_url(self)
Example #4
0
 def label_for_value(self, value):
     obj = self._get_obj(value)
     label = truncate_words(obj, 14)
     adm = admin_url(obj)
     return '&nbsp;<a class="js-hashadr" href="%s">%s</a>' % (adm, label)
Example #5
0
 def label_for_value(self, value):
     obj = self.rel.to.objects.get(pk=value)
     label = truncate_words(obj, 14)
     adm = admin_url(obj)
     return '&nbsp;<a href="%s">%s</a>' % (adm, label)
Example #6
0
 def get_admin_url(self):
     from ella.ellaadmin.utils import admin_url
     return admin_url(self)
Example #7
0
 def get_admin_url(self):
     from ella.ellaadmin.utils import admin_url
     return admin_url(self)
Example #8
0
 def get_admin_url(self):
     return admin_url(self)
Example #9
0
File: widgets.py Project: whit/ella
 def label_for_value(self, value):
     obj = self.rel.to.objects.get(pk=value)
     label = truncate_words(obj, 14)
     adm = admin_url(obj)
     return '&nbsp;<a href="%s">%s</a>' % (adm, label)