Loading AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ answer newbie questions, and generally made Django that much better: Yann Malet Frantisek Malina <vizualbod@vizualbod.com> Mike Malone <mjmalone@gmail.com> Curtis Maloney (FunkyBob) <curtis@tinbrain.net> Martin Maney <http://www.chipy.org/Martin_Maney> Michael Manfre <mmanfre@gmail.com> Javier Mansilla <javimansilla@gmail.com> Loading django/contrib/admin/__init__.py +2 −29 Original line number Diff line number Diff line Loading @@ -7,35 +7,8 @@ from django.contrib.admin.sites import AdminSite, site from django.contrib.admin.filters import (ListFilter, SimpleListFilter, FieldListFilter, BooleanFieldListFilter, RelatedFieldListFilter, ChoicesFieldListFilter, DateFieldListFilter, AllValuesFieldListFilter) from django.utils.module_loading import autodiscover_modules def autodiscover(): """ Auto-discover INSTALLED_APPS admin.py modules and fail silently when not present. This forces an import on them to register any admin bits they may want. """ import copy from importlib import import_module from django.conf import settings from django.utils.module_loading import module_has_submodule for app in settings.INSTALLED_APPS: mod = import_module(app) # Attempt to import the app's admin module. try: before_import_registry = copy.copy(site._registry) import_module('%s.admin' % app) except: # Reset the model registry to the state before the last import as # this import will have to reoccur on the next request and this # could raise NotRegistered and AlreadyRegistered exceptions # (see #8245). site._registry = before_import_registry # Decide whether to bubble up this error. If the app just # doesn't have an admin module, we can ignore the error # attempting to import it, otherwise we want it to bubble up. if module_has_submodule(mod, 'admin'): raise autodiscover_modules('admin', register_to=site) django/contrib/admin/filters.py +7 −5 Original line number Diff line number Diff line Loading @@ -33,26 +33,26 @@ class ListFilter(object): """ Returns True if some choices would be output for this filter. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a has_output() method') def choices(self, cl): """ Returns choices ready to be output in the template. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a choices() method') def queryset(self, request, queryset): """ Returns the filtered queryset. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a queryset() method') def expected_parameters(self): """ Returns the list of parameter names that are expected from the request's query string and that will be used by this filter. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method') class SimpleListFilter(ListFilter): Loading Loading @@ -89,7 +89,9 @@ class SimpleListFilter(ListFilter): """ Must be overridden to return a list of tuples (value, verbose value) """ raise NotImplementedError raise NotImplementedError( 'The SimpleListFilter.lookups() method must be overridden to ' 'return a list of tuples (value, verbose value)') def expected_parameters(self): return [self.parameter_name] Loading django/contrib/admin/sites.py +49 −37 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ from django.contrib.auth import logout as auth_logout, REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import csrf_protect from django.db.models.base import ModelBase from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.core.urlresolvers import reverse, NoReverseMatch from django.template.response import TemplateResponse from django.utils import six Loading Loading @@ -232,14 +232,25 @@ class AdminSite(object): url(r'^password_change/done/$', wrap(self.password_change_done, cacheable=True), name='password_change_done'), url(r'^jsi18n/$', wrap(self.i18n_javascript, cacheable=True), name='jsi18n'), url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$', wrap(contenttype_views.shortcut), name='view_on_site'), url(r'^(?P<app_label>\w+)/$', wrap(self.app_index), name='app_list'), ) # Add in each model's views. # Add in each model's views, and create a list of valid URLS for the # app_index valid_app_labels = [] for model, model_admin in six.iteritems(self._registry): urlpatterns += patterns('', url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls)) ) if model._meta.app_label not in valid_app_labels: valid_app_labels.append(model._meta.app_label) # If there were ModelAdmins registered, we should have a list of app # labels for which we need to allow access to the app_index view, if valid_app_labels: regex = r'^(?P<app_label>' + '|'.join(valid_app_labels) + ')/$' urlpatterns += patterns('', url(regex, wrap(self.app_index), name='app_list'), ) return urlpatterns @property Loading Loading @@ -399,10 +410,11 @@ class AdminSite(object): def app_index(self, request, app_label, extra_context=None): user = request.user has_module_perms = user.has_module_perms(app_label) if not has_module_perms: raise PermissionDenied app_dict = {} for model, model_admin in self._registry.items(): if app_label == model._meta.app_label: if has_module_perms: perms = model_admin.get_model_perms(request) # Check whether user has any perm for this module. Loading @@ -414,12 +426,12 @@ class AdminSite(object): 'object_name': model._meta.object_name, 'perms': perms, } if perms.get('change', False): if perms.get('change'): try: model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name) except NoReverseMatch: pass if perms.get('add', False): if perms.get('add'): try: model_dict['add_url'] = reverse('admin:%s_%s_add' % info, current_app=self.name) except NoReverseMatch: Loading django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +2 −1 Original line number Diff line number Diff line Loading @@ -293,8 +293,9 @@ var DateTimeShortcuts = { var date_parts = inp.value.split('-'); var year = date_parts[0]; var month = parseFloat(date_parts[1]); var selected = new Date(inp.value); if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) { DateTimeShortcuts.calendars[num].drawDate(month, year); DateTimeShortcuts.calendars[num].drawDate(month, year, selected); } } Loading Loading
AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ answer newbie questions, and generally made Django that much better: Yann Malet Frantisek Malina <vizualbod@vizualbod.com> Mike Malone <mjmalone@gmail.com> Curtis Maloney (FunkyBob) <curtis@tinbrain.net> Martin Maney <http://www.chipy.org/Martin_Maney> Michael Manfre <mmanfre@gmail.com> Javier Mansilla <javimansilla@gmail.com> Loading
django/contrib/admin/__init__.py +2 −29 Original line number Diff line number Diff line Loading @@ -7,35 +7,8 @@ from django.contrib.admin.sites import AdminSite, site from django.contrib.admin.filters import (ListFilter, SimpleListFilter, FieldListFilter, BooleanFieldListFilter, RelatedFieldListFilter, ChoicesFieldListFilter, DateFieldListFilter, AllValuesFieldListFilter) from django.utils.module_loading import autodiscover_modules def autodiscover(): """ Auto-discover INSTALLED_APPS admin.py modules and fail silently when not present. This forces an import on them to register any admin bits they may want. """ import copy from importlib import import_module from django.conf import settings from django.utils.module_loading import module_has_submodule for app in settings.INSTALLED_APPS: mod = import_module(app) # Attempt to import the app's admin module. try: before_import_registry = copy.copy(site._registry) import_module('%s.admin' % app) except: # Reset the model registry to the state before the last import as # this import will have to reoccur on the next request and this # could raise NotRegistered and AlreadyRegistered exceptions # (see #8245). site._registry = before_import_registry # Decide whether to bubble up this error. If the app just # doesn't have an admin module, we can ignore the error # attempting to import it, otherwise we want it to bubble up. if module_has_submodule(mod, 'admin'): raise autodiscover_modules('admin', register_to=site)
django/contrib/admin/filters.py +7 −5 Original line number Diff line number Diff line Loading @@ -33,26 +33,26 @@ class ListFilter(object): """ Returns True if some choices would be output for this filter. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a has_output() method') def choices(self, cl): """ Returns choices ready to be output in the template. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a choices() method') def queryset(self, request, queryset): """ Returns the filtered queryset. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide a queryset() method') def expected_parameters(self): """ Returns the list of parameter names that are expected from the request's query string and that will be used by this filter. """ raise NotImplementedError raise NotImplementedError('subclasses of ListFilter must provide an expected_parameters() method') class SimpleListFilter(ListFilter): Loading Loading @@ -89,7 +89,9 @@ class SimpleListFilter(ListFilter): """ Must be overridden to return a list of tuples (value, verbose value) """ raise NotImplementedError raise NotImplementedError( 'The SimpleListFilter.lookups() method must be overridden to ' 'return a list of tuples (value, verbose value)') def expected_parameters(self): return [self.parameter_name] Loading
django/contrib/admin/sites.py +49 −37 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ from django.contrib.auth import logout as auth_logout, REDIRECT_FIELD_NAME from django.contrib.contenttypes import views as contenttype_views from django.views.decorators.csrf import csrf_protect from django.db.models.base import ModelBase from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.core.urlresolvers import reverse, NoReverseMatch from django.template.response import TemplateResponse from django.utils import six Loading Loading @@ -232,14 +232,25 @@ class AdminSite(object): url(r'^password_change/done/$', wrap(self.password_change_done, cacheable=True), name='password_change_done'), url(r'^jsi18n/$', wrap(self.i18n_javascript, cacheable=True), name='jsi18n'), url(r'^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$', wrap(contenttype_views.shortcut), name='view_on_site'), url(r'^(?P<app_label>\w+)/$', wrap(self.app_index), name='app_list'), ) # Add in each model's views. # Add in each model's views, and create a list of valid URLS for the # app_index valid_app_labels = [] for model, model_admin in six.iteritems(self._registry): urlpatterns += patterns('', url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls)) ) if model._meta.app_label not in valid_app_labels: valid_app_labels.append(model._meta.app_label) # If there were ModelAdmins registered, we should have a list of app # labels for which we need to allow access to the app_index view, if valid_app_labels: regex = r'^(?P<app_label>' + '|'.join(valid_app_labels) + ')/$' urlpatterns += patterns('', url(regex, wrap(self.app_index), name='app_list'), ) return urlpatterns @property Loading Loading @@ -399,10 +410,11 @@ class AdminSite(object): def app_index(self, request, app_label, extra_context=None): user = request.user has_module_perms = user.has_module_perms(app_label) if not has_module_perms: raise PermissionDenied app_dict = {} for model, model_admin in self._registry.items(): if app_label == model._meta.app_label: if has_module_perms: perms = model_admin.get_model_perms(request) # Check whether user has any perm for this module. Loading @@ -414,12 +426,12 @@ class AdminSite(object): 'object_name': model._meta.object_name, 'perms': perms, } if perms.get('change', False): if perms.get('change'): try: model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name) except NoReverseMatch: pass if perms.get('add', False): if perms.get('add'): try: model_dict['add_url'] = reverse('admin:%s_%s_add' % info, current_app=self.name) except NoReverseMatch: Loading
django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +2 −1 Original line number Diff line number Diff line Loading @@ -293,8 +293,9 @@ var DateTimeShortcuts = { var date_parts = inp.value.split('-'); var year = date_parts[0]; var month = parseFloat(date_parts[1]); var selected = new Date(inp.value); if (year.match(/\d\d\d\d/) && month >= 1 && month <= 12) { DateTimeShortcuts.calendars[num].drawDate(month, year); DateTimeShortcuts.calendars[num].drawDate(month, year, selected); } } Loading