Ticket #14450: options.py.patch
File options.py.patch, 5.4 KB (added by , 14 years ago) |
---|
-
options.py
old new 23 23 from django.utils.translation import ugettext as _ 24 24 from django.utils.translation import ungettext, ugettext_lazy 25 25 from django.utils.encoding import force_unicode 26 from django.conf import settings 26 27 27 28 HORIZONTAL, VERTICAL = 1, 2 28 29 # returns the <ul> class for a given radio_admin field … … 265 266 urls = property(urls) 266 267 267 268 def _media(self): 268 from django.conf import settings269 270 269 js = ['js/core.js', 'js/admin/RelatedObjectLookups.js', 271 270 'js/jquery.min.js', 'js/jquery.init.js'] 272 271 if self.actions is not None: … … 605 604 def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): 606 605 opts = self.model._meta 607 606 app_label = opts.app_label 607 app_name = app_label.title() 608 try: 609 app_name = settings.APP_NAMES[app_label] 610 except: 611 pass 608 612 ordered_objects = opts.get_ordered_objects() 609 613 context.update({ 610 614 'add': add, … … 617 621 'ordered_objects': ordered_objects, 618 622 'form_url': mark_safe(form_url), 619 623 'opts': opts, 624 'app_name': app_name, 620 625 'content_type_id': ContentType.objects.get_for_model(self.model).id, 621 626 'save_as': self.save_as, 622 627 'save_on_top': self.save_on_top, … … 836 841 inline_admin_formsets.append(inline_admin_formset) 837 842 media = media + inline_admin_formset.media 838 843 844 app_name = opts.app_label.title() 845 try: 846 app_name = settings.APP_NAMES[app_label] 847 except: 848 pass 849 839 850 context = { 840 851 'title': _('Add %s') % force_unicode(opts.verbose_name), 841 852 'adminform': adminForm, … … 846 857 'errors': helpers.AdminErrorList(form, formsets), 847 858 'root_path': self.admin_site.root_path, 848 859 'app_label': opts.app_label, 860 'app_name': app_name, 849 861 } 850 862 context.update(extra_context or {}) 851 863 return self.render_change_form(request, context, form_url=form_url, add=True) … … 927 939 inline_admin_formsets.append(inline_admin_formset) 928 940 media = media + inline_admin_formset.media 929 941 942 app_name = opts.app_label.title() 943 try: 944 app_name = settings.APP_NAMES[app_label] 945 except: 946 pass 947 930 948 context = { 931 949 'title': _('Change %s') % force_unicode(opts.verbose_name), 932 950 'adminform': adminForm, … … 938 956 'errors': helpers.AdminErrorList(form, formsets), 939 957 'root_path': self.admin_site.root_path, 940 958 'app_label': opts.app_label, 959 'app_name': app_name, 941 960 } 942 961 context.update(extra_context or {}) 943 962 return self.render_change_form(request, context, change=True, obj=obj) … … 948 967 from django.contrib.admin.views.main import ERROR_FLAG 949 968 opts = self.model._meta 950 969 app_label = opts.app_label 970 971 app_name = opts.app_label.title() 972 try: 973 app_name = settings.APP_NAMES[app_label] 974 except: 975 pass 976 951 977 if not self.has_change_permission(request, None): 952 978 raise PermissionDenied 953 979 … … 1077 1103 'has_add_permission': self.has_add_permission(request), 1078 1104 'root_path': self.admin_site.root_path, 1079 1105 'app_label': app_label, 1106 'app_name': app_name, 1080 1107 'action_form': action_form, 1081 1108 'actions_on_top': self.actions_on_top, 1082 1109 'actions_on_bottom': self.actions_on_bottom, … … 1095 1122 "The 'delete' admin view for this model." 1096 1123 opts = self.model._meta 1097 1124 app_label = opts.app_label 1125 app_name = opts.app_label.title() 1126 try: 1127 app_name = settings.APP_NAMES[app_label] 1128 except: 1129 pass 1098 1130 1099 1131 obj = self.get_object(request, unquote(object_id)) 1100 1132 … … 1130 1162 "opts": opts, 1131 1163 "root_path": self.admin_site.root_path, 1132 1164 "app_label": app_label, 1165 "app_name": app_name, 1133 1166 } 1134 1167 context.update(extra_context or {}) 1135 1168 context_instance = template.RequestContext(request, current_app=self.admin_site.name) … … 1145 1178 model = self.model 1146 1179 opts = model._meta 1147 1180 app_label = opts.app_label 1181 app_name = opts.app_label.title() 1182 try: 1183 app_name = settings.APP_NAMES[app_label] 1184 except: 1185 pass 1148 1186 action_list = LogEntry.objects.filter( 1149 1187 object_id = object_id, 1150 1188 content_type__id__exact = ContentType.objects.get_for_model(model).id … … 1158 1196 'object': obj, 1159 1197 'root_path': self.admin_site.root_path, 1160 1198 'app_label': app_label, 1199 'app_name': app_name, 1161 1200 } 1162 1201 context.update(extra_context or {}) 1163 1202 context_instance = template.RequestContext(request, current_app=self.admin_site.name) … … 1224 1263 self.verbose_name_plural = self.model._meta.verbose_name_plural 1225 1264 1226 1265 def _media(self): 1227 from django.conf import settings1228 1266 js = ['js/jquery.min.js', 'js/jquery.init.js', 'js/inlines.min.js'] 1229 1267 if self.prepopulated_fields: 1230 1268 js.append('js/urlify.js')