mirror of
https://github.com/django/django.git
synced 2025-06-16 17:09:12 +00:00
magic-removal: Tiny refactoring/reformatting of admin code
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1829 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1885443c82
commit
3802561731
@ -58,8 +58,7 @@ def find_model(mod, remaining):
|
|||||||
|
|
||||||
def get_app_label(mod):
|
def get_app_label(mod):
|
||||||
#HACK
|
#HACK
|
||||||
modcomps = mod.__name__.split('.')
|
return mod.__name__.split('.')[-2]
|
||||||
return modcomps[-2]
|
|
||||||
|
|
||||||
def get_model_and_app(path):
|
def get_model_and_app(path):
|
||||||
comps = path.split('/')
|
comps = path.split('/')
|
||||||
@ -87,7 +86,7 @@ def url_for_model(model):
|
|||||||
url = "%s%s/%s/" % (ADMIN_PREFIX, '/'.join(comps) , model.__name__.lower())
|
url = "%s%s/%s/" % (ADMIN_PREFIX, '/'.join(comps) , model.__name__.lower())
|
||||||
_model_urls[model] = url
|
_model_urls[model] = url
|
||||||
return url
|
return url
|
||||||
raise ImproperlyConfigured('%s is not a model in an installed app' % model.__name__ )
|
raise ImproperlyConfigured, '%s is not a model in an installed app' % model.__name__
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=Context(request))
|
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=Context(request))
|
||||||
|
@ -3,6 +3,7 @@ from django.contrib.admin.views.decorators import staff_member_required
|
|||||||
from django.contrib.admin.views.main import get_model_and_app
|
from django.contrib.admin.views.main import get_model_and_app
|
||||||
from django.contrib.admin.views.stages.modify import render_change_form
|
from django.contrib.admin.views.stages.modify import render_change_form
|
||||||
from django.core import formfields, template
|
from django.core import formfields, template
|
||||||
|
from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
|
||||||
from django.core.extensions import DjangoContext as Context
|
from django.core.extensions import DjangoContext as Context
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
|
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.contrib.admin.views.main import get_model_and_app
|
from django.contrib.admin.views.main import get_model_and_app
|
||||||
from django.core import formfields, template
|
from django.core import formfields, template
|
||||||
|
from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
|
||||||
from django.core.extensions import DjangoContext as Context
|
from django.core.extensions import DjangoContext as Context
|
||||||
from django.contrib.admin.views.stages.modify import render_change_form
|
from django.contrib.admin.views.stages.modify import render_change_form
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -11,8 +12,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImproperlyConfigured, "You don't have 'django.contrib.admin' in INSTALLED_APPS."
|
raise ImproperlyConfigured, "You don't have 'django.contrib.admin' in INSTALLED_APPS."
|
||||||
|
|
||||||
from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist
|
|
||||||
|
|
||||||
def log_change_message(user, opts, manipulator, new_object):
|
def log_change_message(user, opts, manipulator, new_object):
|
||||||
pk_value = getattr(new_object, opts.pk.column)
|
pk_value = getattr(new_object, opts.pk.column)
|
||||||
# Construct the change message.
|
# Construct the change message.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user