mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-04-20 14:51:06 +00:00
Remove accidental dependency on django.contrib.admin
This commit is contained in:
parent
3ddaaefba4
commit
fa86f85afc
2 changed files with 25 additions and 2 deletions
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, unicode_literals
|
|||
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.admin.util import quote
|
||||
from django.db import models
|
||||
from django.db.models import signals
|
||||
from django.utils.encoding import force_text
|
||||
|
|
@ -13,6 +12,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
|||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
|
||||
from . import permissions
|
||||
from .utils import quote
|
||||
|
||||
|
||||
class LogEntryManager(models.Manager):
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from django.db.models import ProtectedError
|
|||
from django.db.models import ManyToManyRel
|
||||
from django.db.models.deletion import Collector
|
||||
from django.db.models.related import RelatedObject
|
||||
from django.utils import six
|
||||
|
||||
|
||||
def lookup_needs_distinct(opts, lookup_path):
|
||||
|
|
@ -100,7 +101,7 @@ class NestedObjects(Collector):
|
|||
This is adopted from the Django core. django-admin2 mandates that code
|
||||
doesn't depend on imports from django.contrib.admin.
|
||||
|
||||
https://github.com/django/django/blob/1.5.1/django/contrib/admin/util.py#L144
|
||||
https://github.com/django/django/blob/1.5.1/django/contrib/admin/util.py#L144-L199
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NestedObjects, self).__init__(*args, **kwargs)
|
||||
|
|
@ -158,3 +159,25 @@ class NestedObjects(Collector):
|
|||
them to the user in confirm page.
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
def quote(s):
|
||||
"""
|
||||
Ensure that primary key values do not confuse the admin URLs by escaping
|
||||
any '/', '_' and ':' and similarly problematic characters.
|
||||
Similar to urllib.quote, except that the quoting is slightly different so
|
||||
that it doesn't get automatically unquoted by the Web browser.
|
||||
|
||||
This is adopted from the Django core. django-admin2 mandates that code
|
||||
doesn't depend on imports from django.contrib.admin.
|
||||
|
||||
https://github.com/django/django/blob/1.5.1/django/contrib/admin/util.py#L48-L62
|
||||
"""
|
||||
if not isinstance(s, six.string_types):
|
||||
return s
|
||||
res = list(s)
|
||||
for i in range(len(res)):
|
||||
c = res[i]
|
||||
if c in """:/_#?;@&=+$,"<>%\\""":
|
||||
res[i] = '_%02X' % ord(c)
|
||||
return ''.join(res)
|
||||
|
|
|
|||
Loading…
Reference in a new issue